Commit Graph

11655 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
525ef594c7
routing: don't return an error from failPayment within handleSendError
In this commit, we fix a regression introduced by a recent bug fix in
this area. Before this change, we'd inspect the error returned by
`processSendError`, and then fail the payment from the PoV of mission
control using the returned error.

A recent refactoring removed `processSendError` and combined the logic
with `tryApplyChannelUpdate` in order to introduce a new
`handleSendError` method that consolidates the logic within the
`shardHandler`. Along the way, the behavior of the prior check was
replicated in the form of a new internal `failPayment` closure. However,
the new function closure ends up returning a `channeldb.FailureReason`
instance, which is actually an `error`.

In the wild, when `SendToRoute` fails due to an error at the
destination, then this new logic caused the `handleSendErorr` method to
fail with an error, returning an unstructured error back to the caller,
instead of the usual payment failure details.

We fix this by no longer checking the `handleSendErorr` for an error as
normal. The `handleSendErorr` function as is will always return an error
of type `*channeldb.FailureReason`, therefore we don't need to treat it
as a normal error. Instead, we check for the type of error returned, and
update the control tower state accordingly.

With this commit, the test added in the prior commit now passes.

Fixes #5477.
2021-07-07 15:31:22 -07:00
Olaoluwa Osuntokun
b24edb2833
routing: modify TestSendToRouteStructuredError to return non-second chance error
In this commit, we modify the existing `TestSendToRouteStructuredError`
test to return an error that doesn't trigger the second chance logic.
Otherwise, we'll get a nil failure result from the mission control
interpretation, meaning we won't exercise the full code path. Instead,
we use a terminal error to ensure that the expected code path is hit.

As is, this test will fail as a recent refactoring causes us to return a
`channeldb.FailureReason` error, since the newly added `handleSendError`
code path in the `SendToRoute` method will return the raw error, rather
than the `shardError`, which is of the expected type.
2021-07-07 15:31:19 -07:00
Olaoluwa Osuntokun
9c9f821ded
Merge pull request #5478 from Roasbeef/fix-may-add-htlc
lnwallet: fix payment regression introduced by MayAddOutgoingHtlc
2021-07-07 14:35:03 -07:00
Olaoluwa Osuntokun
af43a863cb
lnwallet: ensure MayAddOutgoingHtlc doesn't add zero-value HTLCs
In this commit, in order to allow the test added in the prior commit to
pass, we'll increment the mockHTLCAmt value by 1 to ensure we never
attempt to add a zero value HTLC.

Fixes #5468
2021-07-06 16:50:19 -07:00
Olaoluwa Osuntokun
49b18b4d35
lnwallet: add test case to exercise MayAddOutgoingHtlc bug
As is, if the remote party proposes a min HTLC of 0 `mSat` to us, then
we won't ever be able to _send outgoing_ in the channel as the
`MayAddOutgoingHtlc` will attempt to add a zero-value HTLC, which isn't
allowed within the protocol.

The default channels created actually already use a min HTLC value of
zero within the tests, so this test case fails as is.
2021-07-06 16:50:14 -07:00
Olaoluwa Osuntokun
bb5c3f3b51
Merge pull request #5447 from bhandras/etcd_le_docs
docs: leader election docs
2021-07-06 16:43:40 -07:00
Andras Banki-Horvath
f41771ce54
docs: leader election docs 2021-07-06 16:21:26 +02:00
Olaoluwa Osuntokun
756a0ab392
Merge pull request #5463 from Roasbeef/v0.13.1-rc1-branch-prep
lnd: v0.13.1 rc1 branch prep
2021-07-02 17:40:46 -07:00
Olaoluwa Osuntokun
f67d4d346b
docs/release-notes: update release notes for 0.13.1 2021-07-01 18:26:10 -07:00
Olaoluwa Osuntokun
39ac0ebe41
lntest/itest: add new whitelisted error 2021-07-01 18:26:04 -07:00
Olaoluwa Osuntokun
2a59c43d14
Merge pull request #5457 from guggero/wallet-password-file-fallback
lnd+config+sample-lnd.conf: add wallet-unlock-allow-create flag
2021-07-01 18:04:38 -07:00
Olaoluwa Osuntokun
6d5ab035c5
Merge pull request #5280 from champo/interceptor_dont_leak_htlcs
htlcswitch: set sourceRef when resolving packets through interceptor
2021-07-01 17:35:26 -07:00
Oliver Gugger
6ca38bc815
lnd+config+sample-lnd.conf: add wallet-unlock-allow-create flag
As requested by users of node bundle software. They want to use the
wallet-unlock-password-file configuration option in their
default/template config file. This makes the first-time lnd setup a bit
more tricky since lnd will fail with an error if no wallet exists yet
while that config option is used.
The new wallet-unlock-allow-create option instructs lnd to not fail if
no wallet exists yet but instead spin up its unlocker RPC as it would
without the wallet-unlock-password-file being present.
This is not recommended for auto-provisioned or high-security systems
because the wallet creation RPC is unauthenticated and an attacker could
inject a seed while lnd is in that state.
2021-07-01 11:10:25 +02:00
Olaoluwa Osuntokun
b04efec130
Merge pull request #5452 from guggero/export-aezeed
aezeed: export wordlist and properties
2021-06-30 17:58:11 -07:00
Olaoluwa Osuntokun
3dc375603f
Merge pull request #5441 from joostjager/cli-fix-fund-psbt
lncli: fix psbt fund parameter parsing
2021-06-30 17:56:34 -07:00
Olaoluwa Osuntokun
0ff5187dfe
Merge pull request #5371 from bitcoincore-dev/docs-dev-testing
docs: bump docker lnd dev and testing version
2021-06-30 17:56:04 -07:00
Juan Pablo Civile
6e4528515e lntest/itest: verify HTLC interceptor renotification bug 2021-06-30 09:42:52 -03:00
Oliver Gugger
5904efe9ed
aezeed: export wordlist and properties
To make it possible to use the wordlist used for aezeed outside of the
aezeed package we export certain properties of the word list and the
word list itself.
2021-06-30 14:20:32 +02:00
Olaoluwa Osuntokun
20ef37d87d
Merge pull request #5148 from yyforyongyu/4215-deadline-aware
sweeper+contractcourt: deadline aware in sweeping anchors
2021-06-29 16:39:12 -07:00
yyforyongyu
c081707a5b
docs/release-notes: add deadline aware to 0.13.1 2021-06-29 20:30:58 +08:00
yyforyongyu
7c64e0445a
itest: test anchor sweep with commitment deadline 2021-06-29 20:30:53 +08:00
yyforyongyu
26858da59d
itest: change feeServiceTarget to be 1 2021-06-29 20:25:47 +08:00
yyforyongyu
a77225ba9e
itest: allow set fee rate with conf target
In this commit, we add a method in fee service to allow specifying a fee
rate with a conf target.
2021-06-29 20:25:47 +08:00
yyforyongyu
614884dcb8
contractcourt: test commitment deadline logic
This commit adds two tests to check that a) the correct deadline is used
given different HTLC sets and b) when sweeping anchors the correct
deadlines are used.
2021-06-29 20:25:47 +08:00
yyforyongyu
0dc3190fec
contractcourt: update TestChannelArbitratorAnchors
This commit adds a deadline field to mockSweeper that can be used to
track the customized conf target (deadline) used for sweeping anchors.
The relevant test, TestChannelArbitratorAnchors is updated to reflect
that the deadlines are indeed taking effect.
2021-06-29 20:25:47 +08:00
yyforyongyu
391f240ccb
contractcourt: make anchor sweep deadline aware
In this commit, we made the change so that when sweeping anchors for the
commitment transactions, we will be aware of the deadline which is
derived from its HTLC set. It's very likely we will use a much larger
conf target from now on, and save us some sats.
2021-06-29 20:25:47 +08:00
yyforyongyu
adddc1442e
multi: refactor NewAnchorResolutions to return fixed values
This commit adds a new struct AnchorResolutions which wraps the anchor
resolutions for local/remote/pending remote commitment transactions. It
is then returned from NewAnchorResolutions. Thus the caller knows how to
retrieve a certain anchor resolution.
2021-06-29 20:25:47 +08:00
yyforyongyu
21626fed7c
lnwallet: remove unused variable zeroHash 2021-06-29 20:25:46 +08:00
yyforyongyu
1abc5f8b00
chainfee: change min conf target to be 1
This commit changes the minBlockTarget used by the WebAPIEstimator to be
1, inline with the bitcoind's accepted min conf target.
2021-06-29 20:25:46 +08:00
yyforyongyu
5f0561fdbc
chainfee: replace conf target when it exceeds the maxBlockTarget
In this commit, we add a check inside EstimateFeePerKW for bitcoind so
that when the conf target exceeds the maxBlockTarget, we will use
maxBlockTarget instead.
2021-06-29 20:25:46 +08:00
yyforyongyu
6242158d51
chainfee: fix maxBlockTarget value 2021-06-29 20:25:45 +08:00
Olaoluwa Osuntokun
cafa6246a9
Merge pull request #5431 from yyforyongyu/5259-follow-up
routing: rename method and add err check when launch shard
2021-06-28 16:16:13 -07:00
Olaoluwa Osuntokun
44e461b233
Merge pull request #5428 from wpaulino/enforce-anchor-reserve
lnwallet: prevent anchor reserve enforcement on legacy inbound channel
2021-06-28 16:08:43 -07:00
Olaoluwa Osuntokun
dac0797857
Merge pull request #5420 from yyforyongyu/itest-use-require-net
itest: use require inside net.EnsureConnected/net.ConnectNodes
2021-06-28 16:07:33 -07:00
Olaoluwa Osuntokun
1910e263a8
lncli: check for existence of tls file (#5416) 2021-06-28 16:06:55 -07:00
Linus Curiel Xanoni
dc7d79abc2
doc/sample-lnd.conf: remove deprecated protocol.anchors flag
Remove deprecated "protocol.anchors" setting from sample-lnd.conf
2021-06-28 12:25:04 -07:00
yyforyongyu
310e923170
itest: use require inside net.EnsureConnected/net.ConnectNodes 2021-06-29 01:41:48 +08:00
Joost Jager
9b1b92bf98
lncli: fix psbt fund parameter parsing
The sat_per_vbyte parameter was ignored because of a default value for
conf_target.
2021-06-28 11:23:13 +02:00
yyforyongyu
4a23c08b60
routing: rename method and add err check when launch shard
A followup commit for PR#5332. In this commit we add more docs, rename
function updatePaymentState to fetchePaymentState, and add back the
check for channeldb.ErrPaymentTerminal after we launch shard.
2021-06-27 17:48:32 +08:00
Olaoluwa Osuntokun
e62f0e1f3a
Merge pull request #5429 from Roasbeef/itest-recovery-shutdown
lntest: retry node shutdown attempts to recovery tests
2021-06-24 18:43:39 -07:00
Olaoluwa Osuntokun
198ac3482c
Merge pull request #5332 from yyforyongyu/5259-routing-fix-state
routing: fix payment state and refactor payment lifecycle tests
2021-06-24 18:42:17 -07:00
Olaoluwa Osuntokun
6a97e6432d
Merge pull request #5419 from LN-Zap/upstream/fix-no-payment-address
lnd: only set payment address if not empty in PaymentRequest
2021-06-24 15:46:41 -07:00
Olaoluwa Osuntokun
5bd84e2a60
lntest: retry node shutdown attempts to recovery tests
In #5364 we added a new error path in the `StopDaemon` method to return
an error if shutdown was attempted while a rescan/recover instance was
in progress. Since the wallet actually won't fully stop (atm)
mid-recovery, the call effectively didn't do anything in that scenario,
so we started to return an error to properly reflect that. However this
causes certain itests to fail, as during recovery, the stop attempt will
fail leading to the test itself failing.

In this commit, we wrap the calls to stop a running daemon within a
`wait.NoError` call so we'll continually try to shut down the daemon
rather than quit on the first try.

Fixes #5423.
2021-06-24 15:37:32 -07:00
Olaoluwa Osuntokun
6dd7321a3f
Merge pull request #5355 from carlaKC/4656-maxhtlcnumber
multi: set zero bandwidth hint for channels that do not have any available slots
2021-06-24 15:18:20 -07:00
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
Olaoluwa Osuntokun
1287328678
Merge pull request #5335 from guggero/abandonchannel-no-dev
RPC/CLI: Allow abandonchannel to be used in regular build
2021-06-23 16:05:34 -07:00
yyforyongyu
cd35981569
routing: refactor update payment state tests
This commit refactors the resumePayment to extract some logics back to
paymentState so that the code is more testable. It also adds unit tests
for paymentState, and breaks the original MPPayment tests into independent tests
so that it's easier to maintain and debug. All the new tests are built
using mock so that the control flow is eaiser to setup and change.
2021-06-23 20:35:29 +08:00
yyforyongyu
e79e46ed21
routing: add mock structs for testing
This commit uses the package mock to create new mock structs, replacing
the old ones for better control when writing tests.
2021-06-23 20:35:29 +08:00
yyforyongyu
f5de56a40d
mod: add package stretchr/testify mock 2021-06-23 20:35:29 +08:00