Commit Graph

230 Commits

Author SHA1 Message Date
carla
2a614cc596
multi: add labels to lnd native transactions
Follow up labelling of external transactions with labels for the
transaction types we create within lnd. Since these labels will live
a life of string matching, a version number and rigid format is added
so that string matching is less painful. We start out with channel ID,
where available, and a transaction "type". External labels, added in a
previous PR, are not updated to this new versioned label because they
are not lnd-initiated transactions. Label matching can check this case,
then check for a version number.
2020-07-29 13:46:07 +02:00
Conner Fromknecht
455ddfebdb
multi: rename: ReadBucket to RBucket 2020-05-26 18:21:08 -07:00
Conner Fromknecht
d0d2ca403d
multi: rename ReadTx to RTx 2020-05-26 18:20:37 -07:00
Oliver Gugger
f97e7b9951
watchtower: use ECDH interface for watchtower session 2020-05-20 09:06:57 +02:00
Oliver Gugger
535a22c590
server+brontide: use ECDH interface for brontide handshake 2020-05-20 09:06:56 +02:00
Oliver Gugger
6f702a43aa
watchtower: extend and rename SecretKeyRing 2020-05-20 09:05:15 +02:00
Oliver Gugger
b0cb110e86
watchtower: rename SessionPrivKey to SessionKeyECDH 2020-05-20 09:05:15 +02:00
Oliver Gugger
140731af00
lnd+watchtower: rename NodePrivKey to NodeKeyECDH 2020-05-20 09:05:14 +02:00
carla
75370ce6b4
multi: update WalletController PublishTransaction to include label
Add label parameter to PublishTransaction in WalletController
interface. A labels package is added to store generic labels that are
used for the different types of transactions that are published by lnd.

To keep commit size down, the two endpoints that require a label
parameter be passed down have a todo added, which will be removed in
subsequent commits.
2020-05-19 13:30:00 +02:00
Wilmer Paulino
c760700545
wtmock: prevent race conditions by not using ClientSession pointers
These race conditions originate from the mock database storing and
returning pointers, rather than returning a copy.

Observed on Travis:

WARNING: DATA RACE
Read at 0x00c0003222b8 by goroutine 149:
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).drainBackups()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:288 +0xed
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*sessionQueue).sessionManager()
      /home/runner/work/lnd/lnd/watchtower/wtclient/session_queue.go:281 +0x450

Previous write at 0x00c0003222b8 by goroutine 93:
  github.com/lightningnetwork/lnd/watchtower/wtclient.getClientSessions()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:365 +0x24f
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).handleNewTower()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:1063 +0x23e
  github.com/lightningnetwork/lnd/watchtower/wtclient.(*TowerClient).backupDispatcher()
      /home/runner/work/lnd/lnd/watchtower/wtclient/client.go:784 +0x10b9
2020-05-14 15:39:03 -07:00
Wilmer Paulino
f6f0d3819f
wtclient: test case re-add removed tower 2020-05-14 13:48:08 -07:00
Wilmer Paulino
ec5c941512
wtclient: filter out inactive sessions upon adding existing/new tower 2020-05-14 13:35:02 -07:00
Wilmer Paulino
75c2ebd794
wtclient: load missing info into client sessions upon new tower
This addresses a potential panic in where we relied on this missing info
being populated.
2020-05-14 13:35:00 -07:00
Wilmer Paulino
01ab551b22
wtclient: refactor existing candidate session filtering into method 2020-05-14 13:34:59 -07:00
Andras Banki-Horvath
f3f482d9f9 watchtower: one append instead of appends in a loop 2020-04-24 19:15:08 +02:00
Andras Banki-Horvath
e1385af5a6 watchtower: remove dead logging code 2020-04-24 19:15:08 +02:00
Conner Fromknecht
c1b9b272cd
input/size: assert witness size constants
This commit introduces a new test case that asserts all of the witness
size constants currently in the codebase. We also reintroduce the
AcceptedHtlcSuccessWitnessSize and OfferedHtlcTimeoutWitnessSize
constants that were recently removed for the sake of completeness.

In asserting the witnes sizes, there were three uncovered discrepancies:
 * OfferedHtlcSuccessWitnessSize overestimated by about 30% because it
   included an extra signature in the calculation.

 * ToLocalPenaltyWitnessSize was underestimated by one byte, because it
   was missing the length byte for the OP_TRUE. This has implications
   the watchtower protocol since the client and server are assumed to
   share the same weight estimates used for signing. This commit keeps
   the current behavior, with the intention of rolling out negotiation
   for which weight estimate to use for a given session.

 * AcceptedHtlcScriptSize was underestimated by one byte because it was
   missing a length byte for the value 32 pushed on the stack when
   asserting the preimage's length. This affects all AcceptedHtlc*
   witness sizes.
2020-04-10 15:34:27 -07:00
Conner Fromknecht
0f94b8dc62
multi: return input.Signature from SignOutputRaw 2020-04-10 14:27:35 -07:00
nsa
ada0b78dfc lnd+server+watchtower: allow Standalone access to the tor controller
This commit lets the watchtower automatically create hidden services
by giving it a pointer to a TorController. The server was also slightly
refactored so that it was not the sole owner of the TorController.
2020-03-29 12:36:54 -04:00
Olaoluwa Osuntokun
557b930c5f
watchtower: convert to use new kvdb abstraction 2020-03-18 19:35:01 -07:00
Conner Fromknecht
2510ec00f5
watchtower/wtwire/init: use feature.ValidateRequired
This allows us to remove the custom error type originally implemented
for this purpose.
2020-01-08 12:26:00 -08:00
Johan T. Halseth
4fde31229c
lnwallet: rename DelayKey->ToLocalKey, NoDelayKey->ToRemoteKey
Since both parties are going to have their ouputs delayed, we move way
from the DelayKey naming, and instead use ToLocalKey and ToRemoteKey.
2020-01-06 12:08:01 +01:00
Conner Fromknecht
8b5f16387c
watchtower/lookout: fix double-hex encoded chainhash 2019-11-05 15:05:20 -08:00
Olaoluwa Osuntokun
777ed104a3
chainfee: create new chainfee package extracting fees from lnwallet
In this commit, we create a new chainfee package, that houses all fee
related functionality used within the codebase. The creation of this new
package furthers our long-term goal of extracting functionality from the
bloated `lnwallet` package into new distinct packages. Additionally,
this new packages resolves a class of import cycle that could arise if a
new package that was imported by something in `lnwallet` wanted to use
the existing fee related functions in the prior `lnwallet` package.
2019-10-31 16:41:57 -07:00
Olaoluwa Osuntokun
4b65aea306
watchtower+htlcswitch: update client tower logic to recognize safu commitments
In this commit, we update the tower+link logic to tag a commitment as
the new (tweakless) format if it applies. In order to do this, the
BackupTask method has gained an additional parameter to indicate the
type of commitment that we're attempting to upload. This new tweakless
bool is then threaded through all the way to back up task creation to
ensure that we make the proper input.Input.

Finally, we've added a new test case for each existing test case to test
each case w/ and w/o the tweakless modifier.
2019-09-25 18:25:55 -07:00
Joost Jager
3d7de2ad39
multi: remove dead code 2019-09-10 17:21:59 +02:00
Johan T. Halseth
21baa7bf18
multi: fix linter errors 2019-08-07 10:53:10 +02:00
Olaoluwa Osuntokun
8c9c4b52e8
Merge pull request #3184 from wpaulino/wtclient-subserver
multi: add watchtower client RPC subserver
2019-07-30 17:26:22 -07:00
Olaoluwa Osuntokun
69c9e2b732
Merge pull request #3278 from Crypt-iQ/bbolt_options_0707
channeldb: specify freelist bbolt options by default
2019-07-30 16:52:28 -07:00
Wilmer Paulino
0690c8f627
watchtower/wtclient: only reset iterator once we've exhausted all candidates
Doing so allows us to load balance sessions better amongst all of the
tower candidates.
2019-07-30 15:18:18 -07:00
Wilmer Paulino
0431701262
multi: only allow specifying towers to TowerClient through RPC
With the introduction of the WatchtowerClient RPC subserver, the lnd
configuration flag to specify private watchtowers for the client is no
longer needed and can lead to confusion upon users. Therefore, we remove
the flag completely, and only rely on the watchtower client being active
through a new --wtclient.active flag.
2019-07-30 15:18:17 -07:00
Wilmer Paulino
359b2049b6
watchtower: load persisted towers upon TowerClient creation
We do this as a convenience for WatchtowerClient users so that they do
not need to re-add towers upon restarts. We ensure not to re-add towers
that have been previously removed by determining whether it has any
lingering active sessions.
2019-07-30 15:18:17 -07:00
Wilmer Paulino
c57128097e
watchtower/wtclient: extend TowerClient with CRUD operations for towers
In this commit, we extend the wtclient.Client interface with the
following methods:

  * AddTower
  * RemoveTower
  * RegisteredTowers
  * LookupTower
  * Stats

Care has been taken to ensure that any in-memory state updates are
_only_ performed after a successful database update.

These methods are currently unused, but they serve as a dependency for
the upcoming WatchtowerClient RPC subserver.
2019-07-30 15:18:13 -07:00
Wilmer Paulino
06d10d8100
watchtower/wtclient: extend TowerCandidateIterator to update candidates 2019-07-30 15:13:24 -07:00
Wilmer Paulino
1d73a6564f
watchtower: extend client databse with CRUD operations for towers
These operations are currently unused, but will be integrated into the
TowerClient at a later point as future preparation for the
WatchtowerClient RPC subserver, which will allow users to add, remove,
and list the watchtowers currntly in use.
2019-07-30 15:13:23 -07:00
Wilmer Paulino
56d66c80a1
watchtower: extend client db to filter sessions for a specific tower
This currently takes O(N) time as there does not exist an index of
active client sessions for each watchtower within the client's database.
This index is likely to be added in the future.
2019-07-30 15:13:22 -07:00
Wilmer Paulino
4abadc82f3
watchtower/wtclient: export clientStats 2019-07-30 15:13:21 -07:00
Wilmer Paulino
159883665d
wtclient: refactor client creation after database calls 2019-07-30 15:13:20 -07:00
Wilmer Paulino
76f9c9bd52
watchtower/wtclient: remove stale sessionQueue TODO
The state updates that are pending to be acked by the tower are already
loaded within newSessionQueue.
2019-07-30 15:13:17 -07:00
Wilmer Paulino
1d2aba8cd4 watchtower/wtpolicy: properly set DefaultSweepFeeRate and MinSweepFeeRate
These values were intended to be 10 sat/vbyte and 4 sat/vbyte
respectively, but the conversion was done incorrectly.
2019-07-24 18:12:48 -07:00
nsa
66d15c8e76 channeldb + wtdb: specify freelist bbolt options by default
This commit specifies two bbolt options when opening the underlying
channel and watchtower databases so that there is reduced heap
pressure in case the bbolt database has a lot of free pages in the
B+ tree.
2019-07-08 18:41:25 -04:00
Conner Fromknecht
4b549cb43c
watchtower/wtpolicy/policy: bump default fee rate to 10 sat/byte 2019-07-01 15:56:03 -07:00
Conner Fromknecht
05107ce969
watchtower/wtdb: fix double hex encoding of chanid 2019-07-01 13:11:58 -07:00
Olaoluwa Osuntokun
7f48ff6717 watchtower: fix linter errors 2019-06-28 16:10:41 -07:00
Conner Fromknecht
bf042f1271
watchtower/wtclient: filter non-target towers from candidates 2019-06-20 18:17:23 -07:00
Olaoluwa Osuntokun
0506b1e587
Merge pull request #3224 from cfromknecht/wtserver-key-family
watchtower: use separate key family for wtserver public key, add watchtower subserver
2019-06-20 18:01:21 -07:00
Conner Fromknecht
c06d71530a
watchtowerrpc/standalone: implement watchtowerrpc.WatchtowerBackend iface 2019-06-20 17:04:04 -07:00
Conner Fromknecht
fa966a4901
watchtower: add externalip CLI configuration 2019-06-20 17:04:03 -07:00
Conner Fromknecht
7e81a5144e
watchtower: rename DefaultPeerPortStr -> DefaultListenAddr 2019-06-20 17:04:03 -07:00
Conner Fromknecht
997023cd7a
Merge pull request #3226 from cfromknecht/wtclient-log-fixups
watchtower/multi: fix logging in wtclient
2019-06-20 14:10:02 -07:00