Commit Graph

9101 Commits

Author SHA1 Message Date
carla
71fdd755b4
htlcswitch: notify local receive settles 2020-02-19 18:06:00 +02:00
carla
6bd0de257a
htlcswitch: notify incoming link failures
This commit adds link failure notifications for failures which occur
on our incoming link. These failures may be receives which we failed or
forwards which we could not parse.
2020-02-19 18:05:49 +02:00
carla
22d370aa51
htlcswitch: notify send forward failures and settles
Add notifications for local initiated sends settles and forwarding
failures. As with link failures, local send settles and forwarding
failures are reported directly to the router so must have their own
notification handling.
2020-02-19 18:05:45 +02:00
carla
79a890fa48
htlcswitch: notify outgoing link failures for local sends
Notify link failures for our own payments. Separate handling code is
required for local payment link failures because we do not pass these
failures back through the switch (like we do for link failures for
forwards), but rather send them straight back to the router. Our own
sends have the payment ID saved in the incoming htlc ID of the packet's
incoming circuit. This change replaces that value with for the sake
of consistent notifying of sends and receives from our node.
2020-02-19 18:05:12 +02:00
carla
937062b6d3
htlcswitch: refactor handleLocalDispatch
Split handleLocalDispatch into an extra handleLocalAddHTLC function so
we can easily notify an error should one occur adding the htlc.
2020-02-19 18:04:51 +02:00
carla
fc0ee06a99
htlcswitch: add notifications for forwards
This commit adds notifications for htlcs which are forwarded through
our node. Forwards are notified when the htlc is added on our ougoing
link, settles when we send a settle message to the downstream peer.
If a failure occurs, we check whether it occurred at our node, then
notify a link or forwarding failure accordingly.

Note that this change also adds forward event notifications for sends
which are initiated by our node because the handling code for adding
a htlc which originates from our node is the same as that for handling
forwards. Htlcs for our locally initiated sends have our internal pid
set in the incoming htlcs id field, so we extract this value and notify
with a zero htlc id to be consistent with receives (which have zero
outgoing circuits). Subsequent settles or failures are not noitfied
for local sends in this commit, and will be handled in a follow up.
2020-02-19 18:03:22 +02:00
carla
b70080a267
htlcswitch: failAddPacket with full packet information
This commit sets more fields on the htlcPacket created to fail adding
a htlc packet to the switch for notification purposes. This new data is
copied by value from the original packet. The packet is then failed
back to the peer that forwarded us the packet, which is handled by
handledownstream packet. The values added to the packet are not used
in the handling of a failed packet.
2020-02-19 17:51:53 +02:00
carla
abf780bf03
multi: add htlcNotifier interface to switch and link
In this commit, a htlcNotifier interface is added to allow for easy
unit testing. Instances of the HtlcNotifier are added to the server,
switch and link.
2020-02-19 17:50:28 +02:00
carla
2074820d85
htlcswitch: add htlcnotifier
This commit adds a HTLCNotifier to htlcswitch which HTLC events
will be piped through to provide clients with subscriptions to
HTLC level events.

The event types added are forward events (which occur for sends
from and forwards through our node), forward failues (when a
send or forward fails down the line), settles for forwards or
receives to our node and link failures which occur when a htlc
is failed at our node (which may occur for a send, receive or
foreward).
2020-02-19 17:50:19 +02:00
Johan T. Halseth
3e5f2e437d
lnwallet/channel: add TODO 2020-02-19 12:27:42 +01:00
Johan T. Halseth
e398544b8b
lnwallet/channel: take remote commitment view into availableBalance calculation
Since our HTLC must also be added to the remote commitment, we do the
balance caluclation also from the remote chain perspective and report
our minimum balance from the two commit views as our available balance.
2020-02-19 12:27:42 +01:00
Johan T. Halseth
f94464d987
lnwallet: take remote initiator's balance into account
When we send non-dust HTLCs as the non-initiator, the remote party will
have to pay the extra commitment fee. To account for this we figure out
if they can afford paying this fee, if not we report that we only have
balance available for dust HTLCs, since these HTLCs won't increase the
commitment fee.
2020-02-19 12:27:42 +01:00
Johan T. Halseth
9ff79ae595
lnwallet/channel: account for HTLC fee when reporting available balance 2020-02-19 12:27:42 +01:00
Johan T. Halseth
5e89d5b6c2
link+lnwallet: move bandwidth channel reserve validation into channel
Since we want to handle the edge case where paying the HTLC fee would
take the initiator below the reserve, we move the subtraction of the
reserve into availableBalance where this calculation will be performed.
2020-02-19 12:27:42 +01:00
Johan T. Halseth
58dec10680
lnwallet/channel: break up availableBalance 2020-02-19 12:27:41 +01:00
Johan T. Halseth
0d9a1b8656
lnwallet: check local commitment sanity when adding HTLC
This commit adds an extra validation step when adding HTLCs. Previously
we would only validate the remote commitment resulting from adding an
HTLC, which in most cases is enough. However, there are situations where
the dustlimits are different, which could lead to the resulting remote
commitment from adding the HTLC being valid, but not the local
commitment.

Now we also validate the local commitment. A test to trigger the case is
added.
2020-02-19 12:27:41 +01:00
Johan T. Halseth
4ea822efeb
lnwallet tests: add test for dipping remote below chan reserve
This commit adds a test that was previously not performed, namely that
adding a HTLC would dip the remote initiator below its channel reserve.
2020-02-19 12:27:41 +01:00
Johan T. Halseth
05fb272deb
lnwallet/channel: make validateCommitmentSanity take our/their predict
add

To ba able to validate the commitment sanity both for remote and local
commitments, and at the same time predict both our and their add, we let
validateCommitmentSanity take an extra payment descriptor to make this
possible.
2020-02-19 12:27:41 +01:00
Olaoluwa Osuntokun
92b79f6b6a
Merge pull request #3910 from Crypt-iQ/htlc_add_0113
lnwallet: limit received htlc's to MaxAcceptedHTLCs
2020-02-18 17:35:42 -08:00
Olaoluwa Osuntokun
d091f24316
build: update to latest btcwallet version with rescan addr fix
In this commit, we update to the latest `btcwallet` version that
includes a fix for how we perform rescans. Before this commit, the
wallet would load ALL the created keys into the wallet to perform a
rescan. This is unnecessary, as many of the keys we create are actually
used in contracts, so the wallet can't spend them directly anyway.

For neutrino nodes, this would've caused them to attempt o match more
items in the filter than necessary, possibly resulting in an increased
number of false positive block fetches.
2020-02-18 17:12:32 -08:00
Johan T. Halseth
3da5ca0bd2
Merge pull request #4012 from halseth/mpp-paymentid-error
[trivial] channeldb: remove unused payments status serialization
2020-02-18 21:37:02 +01:00
fguisso
3b5d12fd6c make: remove remaining wtclientrpc flags 2020-02-18 10:23:39 -03:00
Johan T. Halseth
cdf3a49c54
channeldb: remove unused payments status serialization 2020-02-18 13:01:57 +01:00
Olaoluwa Osuntokun
3e9087a0f4
Merge pull request #3988 from yancyribbens/fix-docker-terminal-documentation
docs: add terminal symbol to docker readme example commands
2020-02-17 14:37:12 -08:00
Olaoluwa Osuntokun
fce472e820
Merge pull request #3876 from breez/allow-timeouted-initiated-htlc
contractcourt: keep channels with timed-out initiated htlcs.
2020-02-17 14:08:44 -08:00
Johan T. Halseth
13ca3f4ff9
Merge pull request #3998 from halseth/panic-addentry
Fix TestNewBreachRetributionSkipsDustHtlcs incorrect state transtion
2020-02-17 12:21:19 +01:00
Carla Kirk-Cohen
00f1cb91f8
Merge pull request #4007 from carlaKC/gomod-tidy
gosum: remove old btcwallet dependencies
2020-02-17 10:11:55 +02:00
carla
746fdd3d30
gosum: tidy up old btcwallet dependencies
Run go mod tidy to clean up dependencies that were upgraded in #3927.
2020-02-16 15:00:24 +02:00
Roei Erez
0407b37fce contractcourt+switch: keep channels with timed-out initiated htlcs.
This commit enables the user to specify he is not interested in
automatically close channels with pending payments that their
corresponding htlcs have timed-out.
By requiring a configurable grace period uptime of our node
before closing such channels, we give a chance to the other node to
properly cancel the htlc and avoid unnecessary on-chain transaction.
In mobile it is very important for the user experience as otherwise
channels will be force closed more frequently.
2020-02-16 09:08:03 +02:00
nsa
5a5e095684
lnwallet: adding TestMaxAsynchronousHtlcs unit test
Adds a new test which asserts that the new ReceiveHTLC logic can
handle proper commitment overflow calculation in the face of
asynchronous updates.
2020-02-15 09:59:50 -05:00
nsa
4af00c6b25
lnwallet: fixing unit tests to properly handle new receive validation
This commit fixes the TestMaxAcceptedHTLCs, TestMaxPendingAmount,
TestMinHTLC, & TestChanReserve unit tests to pass with the new
ReceiveHTLC logic. Instead of asserting specific failures upon
receiving a new commitment signature, the various assertions were
moved to assert on the error returned from ReceiveHTLC.
2020-02-15 09:59:50 -05:00
nsa
56c07a52d8
lnwallet: call valdiateCommitmentSanity in ReceiveHTLC
This commit checks the commitment sanity when receiving an HTLC so
that if a commitment transaction will overflow from an ADD, it is
caught earlier rather than in ReceiveNewCommitment.
2020-02-15 09:59:49 -05:00
Joost Jager
b75259a3e2
Merge pull request #3951 from joostjager/exclusive-group-sweeper
sweep: add exclusive groups
2020-02-14 12:30:53 +01:00
Oliver Gugger
182835d504
fundingmgr+channelnotifier: add channel config to pending chan ntfn
To be able to write a new channel backup file for pending channels,
we need to include the channel configuration in the pending channel
notification event.
2020-02-14 10:04:26 +01:00
Johan T. Halseth
8904b68626
Merge pull request #3932 from halseth/tls-oudated-check
Re-create TLS files if IPs or domains changed
2020-02-13 10:47:11 +01:00
Joost Jager
9dc349488b
sweep: add exclusive groups
Allows certain sweep inputs to be kept in separate transactions at all
times. This is a preparation for anchor outputs. Before the commitment
tx confirms, there are three potential anchors that can be cpfp'ed. We
want to cpfp them all, but if done in the same transaction, the
transaction would guaranteed to be invalid. Exponential backoff would
eventually get the txes published, but having exclusive groups makes the
process faster.
2020-02-13 09:52:21 +01:00
Johan T. Halseth
5943e5d8b1
lnwallet: state transition from correct node during test, remove panic
The unit test TestNewBreachRetributionSkipsDustHtlcs triggered a state
transition from Bob, even though it was Alice that had added the HTLCs.
This is wrong since it will lead to Bob still owing Alice a commitment,
which is not accounted for in the unit tests.

We add a sanity check that the add heights has been set for all entries
found in the logs, and return an error otherwise. This won't happen
during normal operation, but it does reveal the mistake in the unit
test, which is fixed by making Alice trigger the transition.

In addition we resolve a long standing TODO by removing a (purposeful)
panic in the channel state machine. Old version of lnd had a bug that
could lead to the parent entries being lost during channel restore. A
panic was added to get to the bottom of if.

This is now fixed, so new nodes shouldn't encounter it. However, to be
on the safe side, instead of panicking we return an error back to
gracefully exit the channel state machine.
2020-02-12 11:10:19 +01:00
Johan T. Halseth
e114f58b5e
lnwallet: unify remote and local update log fetch 2020-02-12 11:10:18 +01:00
Johan T. Halseth
ba38bda5f0
lnd: reload cert data after renewal
After renewing the certificate, the new certificate wasn't actually
loaded and used, causing the old one to be used until lnd was restarted.
This fixes that by reloading it after it has been written.
2020-02-12 10:59:52 +01:00
Johan T. Halseth
f7a85e07b0
lnd+cert: recreate TLS files if IPs or DNS changed
This commit makes lnd recreate its TLS certificate if the config's
tlsextradomains or tlsextraips changed. This is useful, since earlier
user would have to manually delete the files to trigger lnd to recreate
them.

To ensure users don't accidentally have their TLS certificate recreated,
we gate it behind a flag --tlsautorefresh that defaults to false.
2020-02-12 10:59:51 +01:00
Johan T. Halseth
83dcf95f92
cert+test: IsOutdated check for TLS files if IPs or DNS changed
This commit creates a new utility method IsOutdated that can be used to
check whether a TLS certificate mathces the extra IPs and domains given
in the lnd config.
2020-02-12 10:59:51 +01:00
Johan T. Halseth
d316107749
cert: extract IP and DNS parsing into methods 2020-02-12 10:59:51 +01:00
Joost Jager
69a6107d06
sweep: log full parameter struct 2020-02-12 09:59:43 +01:00
Joost Jager
2c08a8b9a8
Merge pull request #3992 from joostjager/restore-update-fix
lnwallet: fix invalid value use in restoreUpdate
2020-02-11 18:26:51 +01:00
Joost Jager
0a27361a77
Merge pull request #3964 from joostjager/routing-multi-unit-test
routing/test: integrated routing test
2020-02-11 16:12:54 +01:00
Joost Jager
29476ec6a3
routing/test: test probability extrapolation
Adds an integrated routing test of probability extrapolation for untried
channels. The larger part of this commit is mock code to simulate the
Lightning Network.

The difference between this test and the existing pathfinding tests, is that
this test focuses on the feedback loop from result interpretation via
mission control updates and probability estimation back to pathfinding.
Improvements like probability extrapolation were previously only
validated by reasoning, while this setup makes it possible to assert the
improvement in a test and guard it for the future.
2020-02-11 14:19:13 +01:00
Johan T. Halseth
2a73dabdee
Merge pull request #3995 from halseth/trivial-chanpoint-log
[trivial] contractcourt/chainwatcher: add missing chanpoint log
2020-02-11 14:12:31 +01:00
Joost Jager
06bdeb56e2
routing: add graph interface 2020-02-11 13:35:38 +01:00
Johan T. Halseth
99ebe50f4c
contractcourt/chainwatcher: add missing chanpoint log 2020-02-11 13:23:34 +01:00
Johan T. Halseth
5556735fb6
Merge pull request #3990 from yaslama/signrpc-input-index-fix
Copy InputIndex into the underlying SignDescriptor struct
2020-02-11 08:47:03 +01:00