Commit graph

1703 commits

Author SHA1 Message Date
Elle Mouton
caec0742db
db/sqlc: add account related tables and queries
This commit also contains the sqlc.yaml file, the `make sqlc` command
and the script for generating sqlc code. This must be done in this
commit as the script only works if there are queries to generate from.
2025-01-29 16:37:20 +02:00
Oliver Gugger
09c1c16fb7
Merge pull request #952 from lightninglabs/dep-update
Update faraday to v0.2.14-alpha
2025-01-23 05:41:31 -06:00
Oliver Gugger
6040a21d1e
README+docs: update release notes and README 2025-01-23 12:24:00 +01:00
Oliver Gugger
396b898acf
Merge pull request #951 from lightninglabs/compilation-fix
GitHub+accounts: fix i386 compilation issue
2025-01-23 05:18:19 -06:00
Oliver Gugger
415e589c63
GitHub: cancel jobs for previous pushes of PR
This takes over two more settings we have in the lnd repo. The first is
to cancel existing CI runs for the same PR if it is pushed again before
the previous run has completed.

The second is just for consistency, to make sure all shells are bash
shells.
2025-01-23 10:15:43 +01:00
Oliver Gugger
2f72da0490
GitHub: fix permission denied in lint CI step
This attempts to fix the following error that sometimes occurs on the
GitHub runners:

 go: github.com/lightninglabs/lightning-terminal imports
	github.com/lightningnetwork/lnd/kvdb imports
	github.com/lightningnetwork/lnd/kvdb/etcd imports
	go.etcd.io/etcd/server/v3/embed: mkdir /home/runner/go/pkg/mod/cache/download/go.etcd.io/etcd/server: permission denied

The suspicion is that the lint step that runs as root within docker
changes the permissions of some of the module cache directories.
So by simply changing the order of operations, this should be fixed.
2025-01-23 10:10:56 +01:00
Oliver Gugger
1657584eb9
accounts: fix compilation issue for i386 systems
Apparently the %d formatting directive implicitly uses `int` as its data
type, which on i386 systems is int32. So the value math.MaxInt64
overflows that value, which causes the compilation to fail.
2025-01-23 10:07:10 +01:00
Elle
91bc912201
Merge pull request #941 from ellemouton/sql4Accounts4
[sql-4] accounts: remove last usages of `UpdateAccount`
2025-01-23 11:05:00 +02:00
Oliver Gugger
380f2f3c8f
mod: update to latest faraday version 2025-01-23 09:29:22 +01:00
Oliver Gugger
4a3a628b83
GitHub: add Golang cross compilation check 2025-01-23 09:26:40 +01:00
Oliver Gugger
f8881cc1a5
GitHub: add key-prefix and use-build-cache to setup-go action
This allows us to control the cache key and whether we want to cache the
Go build cache (which can grow very large).
2025-01-23 09:18:06 +01:00
Oliver Gugger
474080fa31
GitHub: update actions/checkout to v4 2025-01-23 09:18:05 +01:00
Elle Mouton
ef78bc4d9d
accounts: assert no startup error in tests
In the case where no startup error is expected, we should assert that no
error is returned from Start.
2025-01-23 09:20:09 +02:00
Elle Mouton
957c9a3a52
accounts: remove UpdateAccount and last usages
We remove the last few calls to UpdateAccount from the
TestAccountService test. Previously, the UpdateAccount call was used in
this test to also _insert_ new accounts and to force the account ID to
be set to specific values. So here we need to instead call the store's
NewAccount method to insert a new account, then we get the AccountID
from the returned value and we need to then use this returned ID (which
is no longer forceable) in the remainder of the tests.
2025-01-23 09:20:09 +02:00
Elle Mouton
e965f4f6af
accounts: remove UpdateAccount calls from store_test
Remove the call to UpdateAccount from the TestAccountStore test and
instead replace it with all the other calls we have added.
2025-01-23 09:20:09 +02:00
Elle Mouton
8b1c9a2893
accounts: revert UpdateAccountBalanceAndExpiry balance type to be int64
In our mission to replace UpdateAccount, we need
UpdatAccountBalanceAndExpiry to take a negative balance so that we can
use it to replace the behaviour of UpdateAccount as it stands today.
2025-01-23 09:00:49 +02:00
Elle
272416100c
Merge pull request #944 from ellemouton/sql5Accounts5
[sql-5] accounts: use clock.Clock
2025-01-23 08:58:09 +02:00
Elle Mouton
42a4c826cf
accounts: use clock.Clock
In this commit, we use the clock.Clock type instead of directly calling
time.Now().
2025-01-23 08:24:21 +02:00
Oliver Gugger
e7dc483013
Merge pull request #950 from lightninglabs/bump-tapd-0-5-1-rc1
Update tapd to v0.5.1-alpha.rc1, bump version to v0.14.1-alpha.rc1
2025-01-22 13:52:54 -06:00
Oliver Gugger
db23a1b691
version: bump version to v0.14.1-alpha.rc1 2025-01-22 20:34:03 +01:00
Oliver Gugger
90d6bdf7e3
docs: update release notes 2025-01-22 20:34:03 +01:00
Oliver Gugger
5e41fccafc
mod: update to latest tapd version 2025-01-22 18:04:56 +01:00
András Bánki-Horváth
85143d9ee6
Merge pull request #949 from bhandras/litrpc-bump
build: bump litrpc to v1.0.1
2025-01-21 13:50:07 +01:00
Andras Banki-Horvath
a1449e371b
build: bump litrpc to v1.0.1 2025-01-21 13:27:57 +01:00
Elle
76c63dbfcc
Merge pull request #939 from ellemouton/sql3Accounts3
[sql-3] accounts: replace calls to UpdateAccount
2025-01-21 12:41:57 +02:00
Elle Mouton
a4506c9e1f
accounts: safe check of pendingPayments in tests
In this commit, we avoid race conditions that can happen for tests that
directly access the service's `pendingPayment` map.
2025-01-21 12:20:33 +02:00
Elle Mouton
4d8d4e1fa3
accounts: use UpsertAccountPayment in removePayment
Instead of UpdateAccount.
2025-01-21 12:20:33 +02:00
Elle
e2c4da25b4
Merge pull request #948 from lightninglabs/netBump
mod: bump net dep to v0.33.0
2025-01-21 12:19:23 +02:00
Elle Mouton
7fb7faa124
accounts: add DeleteAccountPayment method to Store
And use it instead of UpdateAccount.
2025-01-21 12:02:29 +02:00
Elle Mouton
c386008fe6
accounts: use UpsertAccountPayment for TrackPayment
Instead of useing UpdateAccount.
2025-01-21 12:02:19 +02:00
Elle Mouton
340dc5d5b0
accounts: add new UpsertAccountPayment Store method
And use it in the InterceptorService's paymentUpdate method.
2025-01-21 12:01:33 +02:00
Elle Mouton
860edec7be
mod: bump net dep to v0.33.0 2025-01-21 10:59:01 +02:00
Oliver Gugger
b6ff0590ab
Merge pull request #943 from bhandras/tag-autopilotserverrpc
build: bump autopilotserverrpc to v0.0.2
2025-01-21 02:44:20 -06:00
Andras Banki-Horvath
6a9385aedd
build: bump autopilotserverrpc to v0.0.2 2025-01-20 18:27:14 +01:00
Oliver Gugger
a87d20071e
Merge pull request #942 from jiangmencity/master
chore: fix some typos in comment
2025-01-20 06:52:47 -06:00
jiangmencity
fb9d3f51f7 chore: fix some typos in comment
Signed-off-by: jiangmencity <jiangmen@52it.net>
2025-01-20 19:57:29 +08:00
Elle
edaf59d2cc
Merge pull request #938 from ellemouton/sql2Accounts2
[sql-2] accounts: start replacing calls to UpdateAccount
2025-01-17 16:30:31 +02:00
Elle Mouton
34d1f67dd0
accounts: update the service's UpdateAccount method
... to take a more strict btcutil.Amount type for the account balance
parameter.
2025-01-17 14:17:53 +02:00
Elle Mouton
0580d9acf0
accounts: add new IncreaseAccountBalance Store method
And use it instead of UpdateAccount in the InterceptorService's
invoiceUpdate method.
2025-01-17 14:17:53 +02:00
Elle Mouton
5a4b22f6e7
accounts: add new AddAccountInvoice Store method
And use it instead of UpdateAccount for the InterceptorService's
AssociateInvoice method.
2025-01-17 14:17:53 +02:00
Elle Mouton
64606f0132
accounts: add new UpdateAccountBalanceAndExpiry Store method
In this commit, we remove one call to the UpdateAccount store method and
replace it with a call to a new UpdateAccountBalanceAndExpiry method
which updates an accounts balance and/or expiry fields and finds the
account via the given ID. This method signature is more appropriate for
a SQL backend than the UpdateAccount method.
2025-01-17 14:11:38 +02:00
Elle
211865a6c7
Merge pull request #934 from ellemouton/sql1Accounts1
[sql-1]accounts: preparatory commits for  SQL-izing accounts
2025-01-16 10:46:41 +02:00
Elle Mouton
6f131a14a4
accounts+refactor: improve test readability 2025-01-16 09:19:05 +02:00
Elle Mouton
7fa370ebc7
accounts: return consistent error for duplicate label
In preparation for when we have a SQL DB implementation, we want our
unit tests to run smoothly against all DB backends and have the same
results. To achieve this, we need to turn some errors into global error
variables that can be matched against instead.

In this commit, we do this for the unique constraint violation of the
account label.
2025-01-16 09:19:05 +02:00
Elle Mouton
9f08daf948
accounts: let storeAccount set the LastUpdate timestamp
In later commits, we will use this `storeAccount` helper quite often.
Instead of needing to remember to update the timestamp outside the call,
it make sense to instead update the timestamp within the function. Yes
this does mean that sometimes we make no overall changes but do update
the timestamp but this is a pretty standard pattern that a "last
updated" timestamp is updated at any point that we re-write a record
(even if it does not have a net change).
2025-01-16 09:19:05 +02:00
Elle Mouton
2012fbaa41
accounts: update comments for the BoltStore Store impl 2025-01-16 09:19:05 +02:00
Elle Mouton
51d864a24c
accounts: DB constructors for tests
This commit adds two new test helpers, NewTestDB and NewTestDBFromPath
in a file that is only built when the test_db_postgres and
test_db_sqlite build flags are not set. When we add sql backends, we
will add helpers with the same names for each new backend. We will then
use the appropriate build flags to run our unit tests against all
backends.
2025-01-16 09:19:04 +02:00
Elle Mouton
82eeadd819
accounts: pass Store impl to NewService
We want to be able to pass different DB implementations to NewService.
In preparation for this, we make it implementation agnostic by letting
it take a `Store` instead of constructing one itself.

This this change, we also let LiT handle the closing of the accounts
Store instead of the accounts service
2025-01-16 09:19:04 +02:00
Elle Mouton
86fc2ccf79
accounts: let interface methods take a context
Update the accounts `Store` and `Service` interfaces take a context.
This is in preparation for when the backend DB of the accounts service
is a SQL store which will have methods that take a context.
2025-01-16 09:19:04 +02:00
Elle Mouton
62e1a7eb61
accounts: rename store file
We rename the `store.go` file to `store_kvdb.go` to indicate that this
file contains the kvdb implementation of the accounts DB. This is in
preparation for adding a sql-backed implementation later on.

We do this early on in the PR so that any changes that need to be made
during the review process can be easily addressed with fix-up commits
that edit the newly named file.
2025-01-14 18:26:08 +02:00