Commit Graph
100 Commits
Author SHA1 Message Date
Wilmer Paulino 6bbe790535 lnwallet: prevent anchor reserve enforcement on legacy inbound channel
This commit aims to address a flaw in our anchor reserve enforcement
logic in which an inbound "legacy" channel (i.e. a channel with a
commitment type that precedes anchors) would be rejected by the
recipient if they have at least one opened channel using the anchors
commitment type and do not have enough on-chain funds to meet the
anchors reserve.
2021-06-23 18:24:31 -07:00
Wilmer Paulino d7299802d4 itest: extend testAnchorReservedValue to open additional channels
We do this to trigger a bug that will be resolved in a follow-up commit.
This bug prevents inbound legacy channels from being rejected by the
recipient if they have at least one anchor channel already opened
without an on-chain balance.
2021-06-23 18:24:30 -07:00
Wilmer Paulino 0bd6f32867 chainreg: handle missing case for bitcoind signet rpc connectivity
This allows lnd to connect to bitcoind's expected signet RPC port.
2021-06-01 16:22:36 -07:00
Wilmer Paulino b213402722 config: support auto rpc config with bitcoind signet
This allows lnd to automatically retrieve the RPC credentials when
attempting to connect to a signet bitcoind node.
2021-06-01 16:22:10 -07:00
Wilmer Paulino 186237ca73 discovery: demote err log to debug from processZombieUpdate
This log can be "spammy" while nodes throughout the network have yet to
upgrade to v0.13.0-beta, which includes several enhancements to prevent
the broadcast of zombie edges/updates.
2021-05-26 13:33:41 -07:00
Wilmer Paulino f195f21c8c lncli: remove RPC name from list wallet accounts command description 2021-05-26 11:20:31 -07:00
Wilmer Paulino 8745cf03c1 lnwallet: check if requested address type is compatible with account 2021-05-26 11:20:30 -07:00
Wilmer Paulino 798113a024 lnwallet: refactor common logic between NewAddress and LastUnusedAddress 2021-05-26 11:20:28 -07:00
Wilmer Paulino 3b22bd9064 docs: add introductory documentation for new key import feature 2021-05-21 14:39:35 -07:00
Wilmer Paulino b01437d24e rpc: fix policy order for GetNodeInfo
GetNodeInfo retrieves the policies for every edge the node belongs to.
When these policies are retrieved from the database, they're returned
in the following order: the first policy is the outgoing policy from the
node, and the second is the incoming policy to the node. This ordering
is not consistent with the ordering we have within our other RPCs like
GetChanInfo and DescribeGraph, where policies are sorted based on the
smaller public key of the nodes within an edge.

We fix this by maintaining the same order as our other RPCs.
2021-05-12 18:24:38 -07:00
Wilmer Paulino e079a9583c walletrpc: use bytes to represent master key fingerprint
The integer representation is not common and using bytes allows users to
easily confirm whether their master key fingerprint is correct.
2021-05-07 13:07:10 -07:00
Wilmer Paulino f7b130b5ca lncli: add dry run flag for wallet account import command 2021-05-07 13:07:10 -07:00
Wilmer Paulino e180023843 walletrpc: expose dry run support for ImportAccount 2021-05-07 13:06:27 -07:00
Wilmer Paulino 994405709a lnwallet: expose dry run support for ImportAccount 2021-05-06 19:04:21 -07:00
Wilmer Paulino 64699d8538 build: update btcwallet dependency with dry run account import support 2021-05-06 19:00:32 -07:00
Wilmer Paulino 0ada2288cc discovery: prevent logging certain validation barrier errors 2021-04-29 15:53:07 -07:00
Wilmer Paulino eb4413154d routing: return err on validation failure of network update
This ensures the waiting receiving channel always receives an error to
prevent a deadlock when processing a network update that fails due to
the validation barrier.

On commit d5aedbcbd9:

1000 @ 0x43a285 0x44a38f 0xc42e86 0xc80fda 0xc8682d 0xc976c9 0x46fce1
github.com/lightningnetwork/lnd/routing.(*ChannelRouter).AddNode+0x245                      github.com/lightningnetwork/lnd/routing/router.go:2218
github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).addNode+0x3b9            github.com/lightningnetwork/lnd/discovery/gossiper.go:1510
github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).processNetworkAnnouncement+0x574c github.com/lightningnetwork/lnd/discovery/gossiper.go:1554
github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).networkHandler.func1+0x24github.com/lightningnetwork/lnd/discovery/gossiper.go:1043
2021-04-29 15:52:24 -07:00
Wilmer Paulino c59c8d9c19 build: increase global test timeout to 60m
This doesn't affect our travis builds as much as our integration suite
is ran in parellel, but it is needed when running it sequentially.
2021-04-29 13:56:21 -07:00
Wilmer Paulino f26cfac440 itest: use wait predicate for balance assertion in assertDLPExecuted
This assertion would at times fail if the wallet balance hadn't been
updated yet.
2021-04-29 13:56:20 -07:00
Wilmer Paulino 6bb7b00a80 lntest: decrease broadcast timeout for neutrino-backed integration tests
Since we don't have to worry about network latency within our
integration tests, we can shorten the broadcast timeout for neutrino
integration tests from 5s to 1s.
2021-04-29 13:56:19 -07:00
Wilmer Paulino 2084cb0ad5 lncfg: add config options for new neutrino options 2021-04-29 13:56:17 -07:00
Wilmer Paulino 7517243d6d wtclient: decrement pending tasks stats upon accepted task
We'd never decrement the number of pending backups upon a watchtower
accepting one, making it confusing for users to determine whether their
backups have actually been accepted. Along the way, we also rename
NumTasksReceived to NumTasksPending to better reflect its purpose.
2021-04-14 17:18:25 -07:00
Wilmer Paulino 2f1f616c65 lntest: use validatechannels config option for itests 2021-04-09 15:47:04 -07:00
Wilmer Paulino 56c536583f lncfg: add new PrunedNodeMaxPeers config option/flag 2021-04-06 14:55:19 -07:00
Wilmer Paulino 82fe5d9bba build: update btcwallet dependency introducing pruned bitcoind support
This is achieved by some recent work within the BitcoindClient enabling
it to retrieve pruned blocks from its server's peers.
2021-04-06 14:55:14 -07:00
Wilmer Paulino 983f402369 itest: add wallet import cases 2021-04-05 15:41:12 -07:00
Wilmer Paulino cb3e179eaf rpc: break down wallet balance by accounts 2021-04-05 15:41:12 -07:00
Wilmer Paulino 4964801c6f lncli: add wallet import related commands 2021-04-05 15:41:11 -07:00
Wilmer Paulino 5301c7e83f walletrpc: expose wallet import related RPCs 2021-04-05 15:41:10 -07:00
Wilmer Paulino 2d163b788b lnwallet: expose wallet import related methods to WalletController 2021-04-05 15:41:09 -07:00
Wilmer Paulino c7bed34bca lncli: add account flag to wallet related commands 2021-04-05 15:41:08 -07:00
Wilmer Paulino a7211b34c3 rpc: expose account parameter for several wallet RPCs 2021-04-05 15:41:07 -07:00
Wilmer Paulino f91e7cde59 lnwallet: expose optional account filter for several WalletController methods 2021-04-05 15:41:06 -07:00
Wilmer Paulino f38bf4d7fa lnwallet: expose required account parameter for WalletController methods 2021-04-05 15:41:05 -07:00
Wilmer Paulino a620ce3682 build: update btcd and btcwallet dependencies 2021-04-05 15:41:04 -07:00
Wilmer Paulino 393111cea9 discovery+routing: cancel dependent jobs if parent validation fails
Previously, we would always allow dependent jobs to be processed,
regardless of the result of its parent job's validation. This isn't
correct, as a parent job contains actions necessary to successfully
process a dependent job. A prime example of this can be found within the
AuthenticatedGossiper, where an incoming channel announcement and update
are both processed, but if the channel announcement job fails to
complete, then the gossiper is unable to properly validate the update.
This commit aims to address this by preventing the dependent jobs to
run.
2021-03-23 11:56:51 -07:00
Wilmer Paulino e713205eea discovery: add missing error channel sends in processNetworkAnnouncement
Without the error channel sends, we would block the gossip message
stream upon receiving a premature channel announcement.
2021-03-23 11:56:31 -07:00
Wilmer Paulino 022d44f776 itest: test new channel update rate limiting options 2021-03-16 12:08:18 -07:00
Wilmer Paulino dcac5a87f4 lncfg: expose channel update rate limiting options 2021-03-16 11:42:29 -07:00
Wilmer Paulino 83a0d03c0b discovery: use token bucket based rate limiting to throttle gossip
The recently added gossip throttling was shown to be too aggressive,
especially with our auto channel enable/disable signaling. We switch to
a token bucket based system instead as it's based on time, rather than a
block height which isn't constantly updated at a given rate.
2021-02-10 16:21:13 -08:00
Wilmer Paulino 1f1f7be770 Revert "lncfg: add new legacy protocol option to turn off gossip throttling"
This reverts commit b1fbbcf562.
2021-02-10 15:45:49 -08:00
Wilmer Paulino bfc8523873 Revert "discovery: add new option to toggle gossip rate limiting"
This reverts commit 13a2598ded.
2021-02-10 15:45:48 -08:00
Wilmer Paulino d4fa430ca6 Revert "lntest: always turn off gossip throttling for nodes created in itests"
This reverts commit 447c9f2c0b.
2021-02-10 15:45:47 -08:00
Wilmer Paulino 904003fbcb discovery: use source of ann upon confirmed channel ann batch
We do this instead of using the source of the AnnounceSignatures
message, as we filter out the source when broadcasting any
announcements, leading to the remote node not receiving our channel
update. Note that this is done more for the sake of correctness and to
address a flake within the integration tests, as channel updates are
sent directly and reliably to channel counterparts.
2021-02-10 13:22:28 -08:00
Wilmer Paulino 023f327cdd lntest: add rebroadcast stale announcements err to whitelist 2021-01-06 14:33:41 -08:00
Wilmer Paulino 7ef1f3f636 discovery: use source of ann upon confirmed channel ann batch
We do this instead of using the source of the AnnounceSignatures
message, as we filter out the source when broadcasting any
announcements, leading to the remote node not receiving our channel
update. Note that this is done more for the sake of correctness and to
address a flake within the integration tests, as channel updates are
sent directly and reliably to channel counterparts.
2021-01-06 13:16:44 -08:00
Wilmer Paulino 00d4e92362 discovery: prevent rebroadcast of premature channel updates
As similarly done with premature channel announcements, we'll no longer
allow premature channel updates to be rebroadcast once mature. This is
no longer necessary as channel announcements that we're not aware of are
usually broadcast to us with their accompanying channel updates.
2021-01-06 12:52:41 -08:00
Wilmer Paulino 871a6f1690 discovery: prevent rebroadcast of previously premature announcements 2020-12-08 15:18:08 -08:00
Wilmer Paulino a4f33ae63c discovery: adhere to proper channel chunk splitting for ReplyChannelRange 2020-12-08 15:18:07 -08:00
Wilmer Paulino c5fc7334a4 discovery: limit NumBlocks to best known height for outgoing QueryChannelRange
This is done to ensure we don't receive replies for channels in blocks
not currently known to us, which we wouldn't be able to process.
2020-12-08 15:18:06 -08:00
Wilmer Paulino 791ba3eb50 discovery: rate limit incoming channel updates
This change was largely motivated by an increase in high disk usage as a
result of channel update spam. With an in memory graph, this would've
gone mostly undetected except for the increased bandwidth usage, which
this doesn't aim to solve yet. To minimize the effects to disks, we
begin to rate limit channel updates in two ways. Keep alive updates,
those which only increase their timestamps to signal liveliness, are now
limited to one per lnd's rebroadcast interval (current default of 24H).
Non keep alive updates are now limited to one per block per direction.
2020-11-25 15:38:08 -08:00
Wilmer Paulino d3157bcaf8 watchtower: prevent removal of last tower addr
This addresses a potential panic when a tower has one of its candidate
sessions chosen, but its only reachable address was removed by a
user-initiated RPC before the fact.
2020-11-04 15:43:18 -08:00
Wilmer Paulino 1ad0dbade9 btcwallet: return chain best timestamp while backend is syncing
A while back, changes were made to the wallet such that it waits for the
backend to be synced before beginning to store the latest 10,000 blocks
of the chain. This inherently broke sync progress implementations based
on the best_header_timestamp result from the GetInfo RPC for
neutrino-based nodes as the wallet is no longer tracking all blocks in
the chain. To work around this, we now make sure to return the backend's
best header timestamp instead of the wallet's, allowing said sync
progress implementations to work again.
2020-10-19 13:57:30 -07:00
Wilmer Paulino a5c5304c09 Merge pull request #4452 from yyforyongyu/add-connection-timeout
lnrpc+tor: add network connection timeout
2020-09-16 12:28:29 -07:00
Wilmer Paulino a85c4feb17 btcwallet: skip unsupported addresses in ListTransasctionDetails
A transaction with an unsupported address would prevent the method from
returning any other transactions and would instead return an error.
2020-08-25 11:21:29 -07:00
Wilmer Paulino 90af440380 Merge pull request #4451 from yyforyongyu/fix-go-fmt
lnd: fix go fmt
2020-07-08 10:14:47 -07:00
Wilmer Paulino 9e8c39d4a2 Merge pull request #971 from vctt94/addMaxValueFlag
Add max value in flight flag
2020-07-07 10:29:51 -07:00
Wilmer Paulino 6075997ebc multi: add relative thaw height interpretation
This is useful when we wish to have a channel frozen for a specific
amount of blocks after its confirmation. This could also be done with an
absolute thaw height, but it does not suit cases where a strict block
delta needs to be enforced, as it's not possible to know for certain
when a channel will be included in the chain. To work around this, we
add a relative interpretation of the field, where if its value is below
500,000, then it's interpreted as a relative height. This approach
allows us to prevent further database modifications to account for a
relative thaw height.
2020-07-02 12:05:49 -07:00
Wilmer Paulino a998d5d647 Merge pull request #4106 from yyforyongyu/display-recovery-progress
multi: add a rpc endpoint to track the recovery process
2020-06-26 11:06:46 -07:00
Wilmer Paulino 8c79359247 Merge pull request #4395 from bmancini55/reply-channel-range-query
discovery: prevent endBlock overflow in replyChanRangeQuery
2020-06-18 15:19:52 -07:00
Wilmer Paulino d808ec0d17 itest: add sync error to whitelist 2020-06-18 14:51:45 -07:00
Wilmer Paulino d23be59f53 channeldb: remove graph insertion of restored channels
This was initially done as there were a few assertions throughout the
codebase requiring a channel's policy to be known. Now that these have
been addressed, we no longer need to store restored channels in the
graph, as their policies where incomplete anyway.
2020-06-18 14:51:44 -07:00
Wilmer Paulino 2a5b66ec00 lnwallet: note requirement of global coin selection lock 2020-06-12 11:22:30 -07:00
Wilmer Paulino c2f1fe26c1 rpc: acquire global coin select lock in related RPCs
This ensures proper coin selection synchronization between lnd and users
of the RPC to avoid potential double spend errors.
2020-06-12 11:22:29 -07:00
Wilmer Paulino 9d9e54f83e btcwallet: ensure output isn't locked by in-memory impl in LeaseOutput
The current implementation of LeaseOutput already checked whether the
output had already been leased by the persisted implementation, but not
the in-memory one used by lnd internally. Without this check, we could
potentially end up with a double spend error if lnd acquired the UTXO
internally before the LeaseOutput call.
2020-06-12 11:22:28 -07:00
Wilmer Paulino 6e8021f858 scripts: bump bitcoind version to 0.20 2020-06-12 10:46:20 -07:00
Wilmer Paulino d49c6fba87 build: update btcwallet dependency for bitcoind v0.20 compat 2020-06-12 10:46:16 -07:00
Wilmer Paulino 69b8a356b2 chainntnfs: remove queued confirmation notification in CancelConf
This addresses a panic when a notification is canceled after its been
detected as included in a block and before its confirmation notification
is dispatched.
2020-06-10 13:45:45 -07:00
Wilmer Paulino 98da6c61c1 signrpc: parse both KeyDescriptor fields for SignOutputRaw requests
This is meant to handle a quirk in which key descriptors obtained
through walletrpc.DeriveKey don't result in the derived key being
persisted to the wallet's database, unlike with DeriveNextKey. Due to
this and some fallback logic in the wallet with regards to empty key
locators, if a request only specified the compressed public key, the
signature returned would be over a different key, namely the one derived
from (family=0, index=0).
2020-06-04 17:44:25 -07:00
Wilmer Paulino 146611d1c1 lnrpc: mark existing ListUnspent RPC as deprecated in favor of walletrpc 2020-06-03 19:03:05 -07:00
Wilmer Paulino acfd432602 walletrpc: add ListUnspent RPC 2020-06-03 19:03:04 -07:00
Wilmer Paulino 7616a3dc7f rpc: refactor request validation and response marshal into functions 2020-06-03 18:50:11 -07:00
Wilmer Paulino 9dcaf4fbc6 walletrpc: add output leases RPCs 2020-06-03 18:50:09 -07:00
Wilmer Paulino ae7335ce3b lnwallet: expose output leases on WalletController interface 2020-06-03 18:49:39 -07:00
Wilmer Paulino 94629b6c73 build: update btcwallet version to expose output leases 2020-06-03 18:31:53 -07:00
Wilmer Paulino c7dad7a8dd Merge pull request #4341 from wpaulino/log-raw-funding-tx
fundingmanager: log raw transaction on broadcast
2020-06-03 15:45:22 -07:00
Wilmer Paulino 96dc30ae70 fundingmanager: log raw transaction on braodcast 2020-06-03 14:57:13 -07:00
Wilmer Paulino d0fe8b737b netann: decode features when creating chan ann from stored chan info
This was the only field not properly set when creating a
lnwire.ChannelAnnouncement from a channeldb.ChannelEdgeInfo.
2020-06-01 17:30:23 -07:00
Wilmer Paulino 77a4bc97a7 Merge pull request #4304 from guggero/peer-alignment
peer: fix struct alignment
2020-05-21 19:05:21 +00:00
Wilmer Paulino f287ac3cea btcwallet: add transaction outputs bounds check to FetchInputInfo
This prevents a panic when providing an incompatible output index for
the transaction.
2020-05-20 11:42:12 -07:00
Wilmer Paulino db2589ee8d itest: add disconnection error to whitelist 2020-05-18 16:14:31 -07:00
Wilmer Paulino 0e3fc4c7a6 build: update to latest btcd and btcwallet versions
This update introduces backwards compatibility for btcd nodes running
versions prior to v0.20.1-beta.
2020-05-15 17:00:16 -07: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 b195d39ad7 rpc: use existing rpc logger for wtclientrpc
The logger string used to identify the wtclient and wtclientrpc loggers
was the same, leading to being unable to modify the log level of the
wtclient logger as it would be overwritten with the wtclientrpc's one.
To simplify things, we decide to use the existing RPC logger for
wtclientrpc.
2020-05-14 13:35:03 -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
Wilmer Paulino 4e93d3036d Merge pull request #4282 from carlaKC/walletrpc-comments
lnrpc: remove double asterix comments
2020-05-13 10:15:23 -07:00
Wilmer Paulino c039aee059 chainregistry: increase zmq connection timeout with bitcoind backend
There seems to be a misinterpretation of a variable between the
btcwallet and gozmq libraries. When establish a ZMQ connection, it
expects a timeout, which is used to set read deadlines and determine how
long we should wait before attempting a reconnection. Within btcwallet
and lnd however, this is is interpreted as a polling duration,
explaining the current value of 100ms. Under load, especially on
less-capable hardware, this leads to high resource usage as we get into
a constant reconnection loop. To remedy this, we use a timeout of 5s
instead, which is a much more reasonable value for read timeouts, and is
also what's used for LN peers.
2020-04-28 11:15:44 -07:00
Wilmer Paulino c503b82e91 server: ignore reconnection for unadvertised inbound peers over Tor
A peer's remote address isn't known to us if we accepted the connection
over Tor, instead we know the address the onion service used to dial to
lnd. If said peer also doesn't have any advertised addresses, then we
don't have enough information to attempt a reconnect, so we avoid doing
so. Allowing the reconnection to happen isn't necessarily an issue, but
not allowing it prevents the configured SOCKS proxy from dialing to
private addresses.
2020-04-14 16:16:26 -07:00
Wilmer Paulino f48c4cae37 fundingmanager: check remote peer upfront shutdown support before reservation
This addresses a bug in which a funding reservation wasn't cleaned up
properly if the remote peer didn't support upfront shutdown.
Alternatively, we could just cancel the reservation on error, but
instead we move the check above so that we don't attempt coin selection
in the first place.
2020-04-13 11:45:02 -07:00
Wilmer Paulino 893c0cf843 rpcserver: omit uptime in ListChannels response if server not started
If the server hasn't fully started yet, it's possible that the channel
event store hasn't either, so it won't be able to consume any requests
until then. To prevent blocking, we'll just omit the uptime related
fields for now.
2020-04-10 18:31:46 -07:00
Wilmer Paulino 17ca1d78f0 rpcserver: include upfront shutdown script in ListChannels response
This field could be omitted from the response if we were unable to
calculate the channel's uptime.
2020-04-10 18:26:31 -07:00
Wilmer Paulino f6ff3131d8 lntest/itest: add change address recovery case to onchain recovery test
This is mainly motivated by a now fixed bug in the wallet in which
change addresses could at times be created outside of the default key
scopes. Recovery only used to be performed on the default key scopes, so
ideally this test case would've caught the bug earlier.
2020-04-03 15:26:19 -07:00
Wilmer Paulino 1a1e8b6dad build: update btcwallet dependency to scan/recover all key scopes 2020-04-03 15:26:18 -07:00
Wilmer Paulino d04bc200e7 Merge pull request #4144 from cfromknecht/frozen-chan-fixups
multi: frozen chan fixups
2020-04-03 11:21:22 -07:00
Wilmer Paulino 40f97e6c47 peer: send local node announcement upon establishing peer connections
We'll only do so when we have at least one confirmed advertised channel
with the remote peer. This ensures that our node announcement can
propagate throughout the network even for nodes that were offline when
we initially broadcast it.
2020-04-02 10:04:45 -07:00
Wilmer Paulino f996203883 Merge pull request #4079 from guggero/psbt-chanfunding
wallet: PSBT channel funding
2020-03-31 10:03:46 -07:00
Wilmer Paulino a8ba417dfc Merge pull request #4122 from yyforyongyu/typo_fix
trivial:typo fix and add coverage.txt to gitignore
2020-03-27 10:20:39 -07:00