Commit graph

2968 commits

Author SHA1 Message Date
Matt Corallo
da498d7974
Merge pull request #1120 from jkczyz/2021-10-test-refactors
Pre-scoring test clean-ups
2021-10-14 00:16:27 +00:00
Jeffrey Czyz
d4ec090bb8
Move mpp_failure test to payment_tests.rs 2021-10-13 18:37:05 -05:00
Jeffrey Czyz
0a5ccd1f13
Replace get_route with get_route_and_payment_hash
The interface for get_route will change to take a scorer. Using
get_route_and_payment_hash whenever possible allows for keeping the
scorer inside get_route_and_payment_hash rather than at every call site.

Replace get_route with get_route_and_payment_hash wherever possible.
Additionally, update get_route_and_payment_hash to use the known invoice
features and the sending node's logger.
2021-10-13 18:37:01 -05:00
Matt Corallo
9a5c9b3680 Include the user channel id counter in Event::ChannelClosed
This makes it more practical for users to track channels using
their own IDs, especially across funding.
2021-10-13 21:44:58 +00:00
Matt Corallo
be82239181 Return the temporary channel id in success from create_channel
This makes it more practical for users to track channels prior to
funding, especially if the channel fails because the peer rejects
it for a parameter mismatch.
2021-10-13 21:44:58 +00:00
Matt Corallo
2144166bc6
Merge pull request #1115 from TheBlueMatt/2021-10-expose-addr-vec
Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result
2021-10-13 16:54:09 +00:00
Jeffrey Czyz
3fc035267c
Fix unused variable warnings in fuzzer 2021-10-13 10:26:32 -05:00
Jeffrey Czyz
d7c8c8c572
Speed up test_timer_tick_called 2021-10-13 10:25:18 -05:00
Matt Corallo
d2b7f6cc08 Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result
We cannot expose ReadOnlyNetworkGraph::get_addresses as is in C as
it returns a list of references to an enum, which the bindings
dont support. Instead, we simply clone the result so that it
doesn't contain references.
2021-10-13 01:18:43 +00:00
Matt Corallo
fe8c10db95
Merge pull request #1077 from jkczyz/2021-09-failing-route-hop
Include short channel id in PaymentPathFailed
2021-10-13 01:13:41 +00:00
Jeffrey Czyz
202acd9e16
Add failing short channel id to PaymentPathFailed
This will be useful for scoring channels when a payment fails.
2021-10-12 18:40:06 -05:00
Matt Corallo
5a356cad69
Merge pull request #1116 from TheBlueMatt/2021-10-test-local-chan-routing
Use local channel state when constructing routes in test macro  + Fix compile-warning
2021-10-12 18:29:05 +00:00
Matt Corallo
00ffa4397d Fix loop label shadowing warning 2021-10-12 02:29:56 +00:00
Matt Corallo
74a9be6956 Use local channel state when constructing routes in test macro
This is a bit more realistic and needed to route over non-public
channels.
2021-10-12 02:29:01 +00:00
Jeffrey Czyz
1e2ca5233b
Clean up fee_insufficient computation 2021-10-11 13:47:04 -05:00
Matt Corallo
d66574803e
Merge pull request #1098 from 1nF0rmed/2021-09-adds-discard-funding-event
Add Event::DiscardFunding generation
2021-10-09 17:17:55 +00:00
1nF0rmed
1955008d6d Adds DiscardFunding event
During the event of a channel close, if the funding transaction
is yet to be broadcasted then a DiscardFunding event is issued
along with the ChannelClose event.
2021-10-09 16:43:50 +05:30
Matt Corallo
843d25d750
Merge pull request #1107 from dunxen/2021-10-swap-pubkey-for-bytearray
Replace PublicKey with [u8; 33] in NetworkGraph
2021-10-08 21:02:53 +00:00
Matt Corallo
e635db0da3
Merge pull request #1062 from galderz/t_payment_hash_999 2021-10-08 20:49:19 +00:00
Duncan Dean
fce631ca21
Replace PublicKey with [u8; 33] in NetworkGraph 2021-10-08 18:37:55 +02:00
Galder Zamarreño
204bfd260c Add payment_hash to PaymentSent #999 2021-10-08 06:53:10 +02:00
Matt Corallo
6582aaebae
Merge pull request #1109 from TheBlueMatt/2021-10-init-fail-payment-retry-leak
Move pending payment tracking to after the new HTLC flies
2021-10-07 23:14:06 +00:00
Matt Corallo
a58c617c42 Correct error returned when retry_payment doesn't have a payment 2021-10-07 22:27:58 +00:00
Matt Corallo
928bfb12d2 Move pending payment tracking to after the new HTLC flies
If we attempt to send a payment, but the HTLC cannot be send due to
local channel limits, we'll provide the user an error but end up
with an entry in our pending payment map. This will result in a
memory leak as we'll never reclaim the pending payment map entry.
2021-10-07 22:27:58 +00:00
Jeffrey Czyz
f5abc93978
Pass hop index in construct_onion_keys_callback
This simplifies failing route hop calculation, which will be useful for
later identifying the failing hop for PaymentFailed events.
2021-10-06 23:31:59 -05:00
Jeffrey Czyz
42bb0af11d
Remove special case for onion error expiry_too_far
With channel scoring and payment retries, it is no longer necessary to
have expiry_too_far imply a payment failure.
2021-10-06 23:31:27 -05:00
Matt Corallo
ab0739e3ea
Merge pull request #1079 from TheBlueMatt/2021-09-stale-docs
Update Event::PaymentReceived docs since we require payment secret
2021-10-05 23:16:20 +00:00
Matt Corallo
7478207d5c Update Event::PaymentReceived docs since we require payment secret
Users no longer need to verify the amounts of received payments as
the payment secret will protect us against the probing attacks such
verification was intended to fix.
2021-10-05 22:35:04 +00:00
Matt Corallo
bb4ff74da1 Move tests of payment retries into a new module 2021-10-05 19:26:45 +00:00
Matt Corallo
17d75a845a
Merge pull request #1100 from TheBlueMatt/2021-09-multihop-route-hint-fix
Consider many first-hop paths to the same counterparty in routing
2021-10-05 18:43:39 +00:00
Matt Corallo
7aa2caccd8
Merge pull request #1096 from valentinewallace/2021-09-mpp-retries 2021-09-30 01:19:04 +00:00
Valentine Wallace
3e6297a664
Expire outbound payments after 3 blocks if no parts are pending 2021-09-29 20:25:42 -04:00
Valentine Wallace
207479f32f
Don't remove failed payments when all paths fail
This is because we want the ability to retry completely failed
payments.

Upcoming commits will remove these payments on timeout to prevent
DoS issues

Also test that this removal allows retrying single-path payments
2021-09-29 20:25:42 -04:00
Valentine Wallace
8db9c50b8b
Add method to retry payments 2021-09-29 20:25:39 -04:00
Matt Corallo
730d5639a4
Merge pull request #1080 from valentinewallace/2021-09-dup-chan-outpoint
Fix fuzzer-found panic from duplicate channel outpoint
2021-09-30 00:01:35 +00:00
Matt Corallo
cc704465c3 f readability improvements from val 2021-09-29 23:16:22 +00:00
Matt Corallo
2352587811
Merge pull request #1076 from TheBlueMatt/2021-09-forwardable-regen 2021-09-29 20:24:37 +00:00
Matt Corallo
0fcc34b9b5 Regenerate PendingHTLCsForwardable on reload instead of serializing
When we are prepared to forward HTLCs, we generate a
PendingHTLCsForwardable event with a time in the future when the
user should tell us to forward. This provides some basic batching
of forward events, improving privacy slightly.

After we generate the event, we expect users to spawn a timer in
the background and let us know when it finishes. However, if the
user shuts down before the timer fires, the user will restart and
have no idea that HTLCs are waiting to be forwarded/received.

To fix this, instead of serializing PendingHTLCsForwardable events
to disk while they're pending (before the user starts the timer),
we simply regenerate them when a ChannelManager is deserialized
with HTLCs pending.

Fixes #1042
2021-09-29 19:20:38 +00:00
Matt Corallo
56c75f0bac Consider many first-hop paths to the same counterparty in routing
Previously we'd simply overwritten "the" first hop path to each
counterparty when routing, however this results in us ignoring all
channels except the last one in the `ChannelDetails` list per
counterparty.
2021-09-29 19:15:16 +00:00
Matt Corallo
6edb4fe42f Correct step number in get_route 2021-09-29 18:51:14 +00:00
Valentine Wallace
bf527b0ddb
channelmanager: Add retry data to pending_outbound_payments 2021-09-28 19:39:37 -04:00
Valentine Wallace
72e1c91d46
Refactor send_payment internals for retries 2
Retrying a partial payment means send_payment_internal needs to be parameterized
by a total payment amount, else 'HTLC values do not match' errors
2021-09-28 19:39:37 -04:00
Valentine Wallace
5d316302df
Refactor send_payment internals for retries
We want to reuse send_payment internal functions for retries,
so some need to now be parameterized by PaymentId to avoid
generating a new PaymentId on retry
2021-09-28 19:39:37 -04:00
Valentine Wallace
a1fc379151
Return PaymentId from send_*payment functions
Used in upcoming commits for retries
2021-09-28 19:39:37 -04:00
Valentine Wallace
28eea12bbe
Rename MppId to PaymentId
Leftover from previous PR Jeff feedback.

Useful in upcoming commits as we'll expose this to users for payment retries
2021-09-28 19:39:34 -04:00
Matt Corallo
ad819ea705
Merge pull request #1065 from TheBlueMatt/2021-08-bump-dust
Increase our default/minimum dust limit and decrease our max
2021-09-27 20:39:02 +00:00
Matt Corallo
2da0d6c0c9 Rename MIN_DUST_LIMIT_SATOSHIS constant to disambiguate chan vs P2P
While channel and P2P network dust limits are related, they're
ultimately two different things, and thus their constant names
should reference that.
2021-09-27 18:19:51 +00:00
Matt Corallo
9279890089 Force-close channels if closing transactions may be non-standard
If a counterparty (or an old channel of ours) uses a non-segwit
script for their cooperative close payout, they may include an
output which is unbroadcastable due to not meeting the network dust
limit.

Here we check for this condition, force-closing the channel instead
if we find an output in the closing transaction which does not meet
the limit.
2021-09-27 18:19:51 +00:00
Matt Corallo
1b70d9ee8f Require user cooperative close payout scripts to be Segwit
There is little reason for users to be paying out to non-Segwit
scripts when closing channels at this point. Given we will soon, in
rare cases, force-close during shutdown when a counterparty closes
to a non-Segwit script, we should also require it of our own users.
2021-09-27 18:19:51 +00:00
Matt Corallo
c43db96062 Reduce the maximum allowed counterparty dust limit to 546 sat/vbyte
546 sat/vbyte is the current default dust limit on most
implementations, matching the network dust limit for P2SH outputs.
Implementations don't currently appear to send any larger dust
limits, and allowing a larger dust limit implies higher payment
failure risk, so we'd like to be as tight as we can here.
2021-09-27 18:19:51 +00:00