Commit Graph

318 Commits

Author SHA1 Message Date
Oliver Gugger
55b53555e9
multi: improve readability of goroutine defers
This commit fixes the readability of some of the defer calls in
goroutines by making sure the defer stands out properly.
2022-11-21 13:54:24 +01:00
Matt Morehouse
e15d3e898e
brontide,lnwire,wtwire,zpay32: appease linter
Address all linter complaints for the newly migrated fuzz tests.
2022-11-11 08:44:30 -06:00
Matt Morehouse
5a48568806
brontide,lnwire,wtwire,zpay32: use CamelCase
Rename fuzz test functions to use CamelCase.
2022-11-11 08:44:24 -06:00
Conner
1ed2a1bc28
wtwire: migrate fuzz tests 2022-11-11 08:44:01 -06:00
Elle Mouton
3ff5abc9e3
watchtower: allow removal during session negotiation
In this commit, the bug demonstrated in the previous commit is fixed.
The locking capabilities of the AddressIterator are used to lock
addresses if they are being used for session negotiation. So now, when a
request comes through to remove a tower address then a check is first
done to ensure that the address is not currently in use. If it is not,
then the request can go through.
2022-10-20 15:46:56 +02:00
Elle Mouton
b2039f245e
watchtower: demo cant remove tower during negotiation bug
In this commit, a new test is added to demonstrate that an error is
thrown if a user attempts to remove a tower during session negotiation
even if no current negotiation is taking place with the tower.
2022-10-20 15:46:55 +02:00
Elle Mouton
8a7329b988
watchtower: make use of the new AddressIterator
This commit upgrades the wtclient package to make use of the new
`AddressIterator`. It does so by first creating new `Tower` and
`ClientSession` types. The new `Tower` type has an `AddressIterator`
instead of a list of addresses. The `ClientSession` type contains a
`Tower`.
2022-10-20 15:46:52 +02:00
Elle Mouton
7924542500
watchtower: add AddressIterator and tests
In this commit, a new AddressIterator type is added. It is a type that
can be used to iterate over a list of addresses. It strictly disallows
the list of addresses it holds to be empty. It also allows callers to
place locks on certain addresses in order to prevent other callers from
removing the addresses in question from the iterator.
2022-10-20 15:46:03 +02:00
Elle Mouton
5bc8ee48fc
watchtower: demo that client cant update tower address
In this commit, a test is added to demonstrate that if a client tries to
update the address of a tower for an active tower session, then this new
address will not be used until the client restarts. This is a bug that
will be fixed in a future commit.
2022-10-20 11:32:08 +02:00
Elle Mouton
60f58b7812
watchtower: simplify the newHarness test function 2022-10-19 18:49:18 +02:00
Elle Mouton
4828fd902d
wtclient: allow multiplie callback dial functions
This commit is a step towards prepping the watchtower client test
harness to be able to handle the case where the client connects to
multiple mock servers.
2022-10-19 18:49:18 +02:00
Elle Mouton
ab4d4a19be
watchtower/wtclient: upgrade pkg to use require
Upgrade all the tests in the wtclient package to make use of the
`require` package.
2022-10-19 18:49:17 +02:00
Elle Mouton
d29a55bbb5
watchtower: make use of t.Cleanup funcs in tests
Make use of the t.Cleanup helper function to clean up watchtower client
tests instead of relying on defer calls.
2022-10-19 18:39:26 +02:00
Carsten Otto
378478eb1a multi: fix typos and grammar issues in comments [skip ci] 2022-10-17 09:40:22 +02:00
Carsten Otto
2a56f602db wtclient: fix documentation [skip ci]
the implementation also returns exhausted sessions
2022-10-17 09:40:22 +02:00
Elle Mouton
75e5339217
watchtower: remove CommittedUpdates from ClientSession
In this commit, the new ListClientSession functional options and new
FetchSessionCommittedUpdates function are utilised in order to allow us
to completely remove the CommittedUpdates member from the ClientSession
struct.
2022-10-13 14:41:26 +02:00
Elle Mouton
fe3d9174ea
watchtower: add FetchSessionCommittedUpdates func to DB
In this commit, a new tower client db function is added that can be used
to fetch all the committed updates for a given session ID. This is done
in preparation for an upcoming commit where the CommittedUpdates will be
removed from the ClientSession struct.
2022-10-13 14:39:23 +02:00
Elle Mouton
15858cae1c
watchtower+lnrpc: remove AckedUpdates from ClientSession struct
In this commit, we start making use of the new ListClientSession
functional options added in the previous commit. We use the functional
options in order to calculate the max commit heights per channel on the
construction of the tower client. We also use the options to count the
total number of acked and committed updates. With this commit, we are
also able to completely remove the AckedUpdates member of the
ClientSession since it is no longer used anywhere in the code.
2022-10-13 14:36:33 +02:00
Elle Mouton
40e0ebf417
watchtower: add ListClientSessions functional options
This commit adds functional options to the ListClientSessions call that
can be used to perform a variety of extra operations during the DB
query. These functional options are not yet used in this commit.
2022-10-13 14:35:34 +02:00
Elle Mouton
3ac3b6a90d
watchtower: refactor getClientSession helper funcs
Small refactor to some of the tower client db helper functions in order
to simplify upcoming commits.
2022-10-13 14:35:03 +02:00
Oliver Gugger
707546e2f0
Merge pull request #6972 from ellemouton/wtclientTowerDb
watchtower: add towerID-to-sessionID index
2022-10-13 13:09:12 +02:00
Eng Zer Jun
228f1e36c4
watchtower: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-13 17:47:04 +08:00
Elle Mouton
105c44df9b
watchtower: use more efficient session query on startup
In this commit, the functions used to fetch candidate sessions and
towers on creation of the watchtower Client are changed to make use of
the more efficient lookup functions. Previously, all sessions were
listed from the DB and then these were used to collect the active
towers which in certain situations lead to some users getting the
"tower not found" error on start up. With this commit, we instead first
list all Towers in the DB and then we fetch the sessions for each of
those towers.
2022-10-13 11:30:27 +02:00
Elle Mouton
ecd2eb965a
watchtower: make use of the new tower-to-session index
In this commit, the towerID-to-sessionID index added in the previous
commit is put to use in order to make session lookup more efficient in
certain places. In the process, 2 TODO's are also removed from the code.
2022-10-13 11:30:27 +02:00
Elle Mouton
354a3b16bd
watchtower/wtdb: add new towerID-to-sessionID index
This commit adds a new towerID-to-sessionID index to the wtclient DB.
The commit also contains the necessary migration required in order to
build the index for an existing client.
This index will greatly improve the lookup of sessions for a given tower
ID.
2022-10-13 11:30:27 +02:00
Elle Mouton
c60ecaccbf
watchtower: always populate Tower in ClientSession
In this commit, we make sure to always populate the Tower member of a
ClientSession. This is done for consistency.
2022-10-13 11:30:27 +02:00
Elle Mouton
e150bb83d1
watchtower/wtdb: check tower exists on session create
Before creating a new session, first check that the TowerID that the
ClientSession is referencing refers to an existing tower. This is done
to prevent the situation where RemoveTower is called right before
CreateClientSession is called which would, before this commit, lead to
the session being created with a tower ID that does not refer to any
existing tower.
2022-10-13 11:30:26 +02:00
Elle Mouton
5dabf7cb3e
watchtower/wtdb: update tests to use require package
In this commit, all the tests in the wtdb package are updated in order
to make use of the `require` package where appropriate.
2022-10-13 11:30:26 +02:00
Elle Mouton
f815c88ee4
watchtower: fix formatting
In order to make upcoming commits in the PR easier to parse, this commit
makes some basic formatting changes to some of the watchtower files.
2022-10-13 11:30:22 +02:00
Orbital
073c990c75
multi: Add --tor.encryptkey flag functionality to encrypt the Tor private key on disk
It's possible that a user might not want the Tor private key to sit on the disk in plaintext (it is a private key after all). So this commit adds a new flag to encrypt the Tor private key on disk using the wallet's seed. When the --tor.encryptkey flag is used, LND will still write the Tor key to the same file, however it will now be encrypted intead of plaintext. This essentially uses the same method to encrypt the Tor private key as is used to encrypt the Static Channel Backup file.
2022-09-30 01:53:46 -05:00
ueno
c6c7f94668 docs: fix typo in watchtower document and code comment [skip ci] 2022-09-13 22:06:30 +09:00
Eng Zer Jun
6d00cdea45
watchtower/wtdb: use T.TempDir to create temporary test directory
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-24 09:03:06 +08:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
Olaoluwa Osuntokun
dc16f5df53
watchtower: uses P2TR for sweep, delivery, and reward addresses
In this commit, we modify the watch tower to use P2TR addrs for just
about anything sweep related.

One eye sore in this diff are the changes to
`backup_task_internal_test.go`. All the values are hard coded, and now
either differ by a value of 48, or needed to be modified to account for
the new assumptions propagated to rewards values and fees.
2022-08-11 17:26:13 -07:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Olaoluwa Osuntokun
0ec88b5346
Merge pull request #6347 from yyforyongyu/5388-rm-revc-log
lnwallet+channeldb: store minimal info in revocation log bucket
2022-05-05 15:52:59 -07:00
Oliver Gugger
95ff670c0e
multi: add MuSig2Cleanup method to MuSig2 signer 2022-05-04 19:23:58 +02:00
Oliver Gugger
f7275c7fc4
multi: implement MuSig2 RPCs and remote signing 2022-04-29 11:41:09 +02:00
yyforyongyu
953767961e
multi: use txid instead of tx in BreachRetribution
This commit replaces the field `BreachTransaction` with `BreachTxHash`
as there's no need to pass that large raw transaction.
2022-04-20 01:18:14 +08:00
Oliver Gugger
f130eddb92
multi: use prev output fetcher where possible 2022-03-24 18:02:37 +01:00
Oliver Gugger
72c9582b85
multi: bump btcd to taproot aware version 2022-03-24 15:00:25 +01:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Olaoluwa Osuntokun
10fba3d859
Merge pull request #6214 from yyforyongyu/server-start-order
server: start htlcswitch early in the pipeline
2022-02-24 15:32:46 -08:00
Oliver Gugger
67f5957c5e
tlv+watchtower: move bench test
The benchmark tests import both the tlv and watchtower packages. To make
it possible to extract the tlv package into its own submodule, this test
is better located in the watchtower package.
2022-02-21 13:48:31 +01:00
yyforyongyu
1ad6bbfbc2
multi: add logs when subservers are starting
Also unified the log messages.
2022-02-11 21:17:03 +08:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Oliver Gugger
dfdc2bff8b
multi: run gosimports 2022-02-10 11:02:01 +01:00
Dimitris Apostolou
530a2059e5
multi: Fix typos [skip ci] 2022-01-24 12:19:02 +02:00
eugene
fdcd726f9a
multi: replace DefaultDustLimit with script-specific DustLimitForSize
This commit updates call-sites to use the proper dust limits for
various script types. This also updates the default dust limit used
in the funding flow to be 354 satoshis instead of 573 satoshis.
2021-09-29 13:33:10 -04:00
ErikEk
d5463818a8 bbolt sync-freelist ignored 2021-09-27 06:49:56 +01:00