Commit graph

6177 commits

Author SHA1 Message Date
Elias Rohrer
8c99e34b93
Assert query's and route's final_value_msat are equal 2023-09-28 19:45:31 +02:00
Elias Rohrer
fb2c959b40
Refactor mpp_retry[_overpay] tests to use SendEvent::from_event
.. as a follow-up from #2417.
2023-09-28 19:45:30 +02:00
Elias Rohrer
39c5bbc0bb
Make ignored candidate counts u32
.. as a follow-up from #2417.
2023-09-28 19:45:30 +02:00
Elias Rohrer
c480b0c857
Avoid adding duplicate hint candidates if they are first hops
If we have a direct channel to a node generating an invoice with route
hints, we'd previously happily add multiple candidates that all refer to
the same channel. To keep our candidate set small and unify our tracking
where possible, we now check if its `short_channel_id` is an
`outbound_scid_alias` of any of our first hops and refrain from adding
another candidate if it's the case.
2023-09-28 19:45:30 +02:00
Elias Rohrer
7a6d3097a6
Also add route hints if we are the source
Previously, we would only consider route hints if we had a direct
channel to the first node in the hint or if the first node in the hint
was part of the public network graph.

However, this left out the possiblity of us being part of the first hop,
especially if our own node is not announced and part of the graph.
2023-09-28 19:45:29 +02:00
Matt Corallo
3141630f78
Merge pull request #2607 from DhananjayPurohit/civkit-branch
Issue in adding rust lightning as dependency on windows
2023-09-28 16:54:44 +00:00
Matt Corallo
336d815dd6
Merge pull request #2606 from wpaulino/anchors-counterparty-htlc-claim-sequence
Use correct input sequence for HTLC claims from counterparty commitments
2023-09-28 16:32:18 +00:00
Matt Corallo
d66d38e5fb Log full channel_update messages received for our channels 2023-09-28 16:30:02 +00:00
Elias Rohrer
a8eef297fc
Extend logging of ignored candidates 2023-09-28 10:14:35 +02:00
Elias Rohrer
391da3f3b2
Use saturating_add when adding inflight HTLCs values
Previously this calculation could overflow, leading to panicking in `debug`.
2023-09-28 10:14:35 +02:00
DhananjayPurohit
cf0cef81b3 chore: remove time_utils.rs
No longer needed time_utils in lightning-invoice
2023-09-28 13:29:48 +05:30
Matt Corallo
18ef80f78a Refer to top-level persistence namespaces as primary_namespace
This fixes a bindings build error as `namespace` is a C++ keyword
which cannot be used as an argument, and while this could be fixed
in the bindings rather than here, separating the term `namespace`
between the concept (which refers to the primary and sub
namespaces) and the primary namespace makes the documentation more
readable.
2023-09-28 02:41:51 +00:00
Matt Corallo
910a00e3d0 Use Result<_, io::Error> over io::Result<_>
Personally I've always found the overload of a prelude enum to be
confusing, and never bothered to handle it properly in bindings as
a result. To avoid needing to do so now, we simply move the
newly-introduced `io::Result` usages over to
`Result<_, io::Error>`.
2023-09-28 02:41:51 +00:00
Matt Corallo
9123d6d41b Don't FC when a channel_update has a bogus htlc_minimum_msat
If a peer sends us a `channel_update` for our own channel with an
`htlc_minimum_msat` which is more than the channel's amount, that's
dumb, but there's no reason to force-close the channel. We don't
even use the field.

Here we simply drop the unnecessary check.
2023-09-28 00:47:43 +00:00
Matt Corallo
7b4fb9da88
Merge pull request #2570 from valentinewallace/2023-08-router-fuzz-fail
Fix router fuzz failure
2023-09-27 20:40:32 +00:00
Wilmer Paulino
3c83783800
Use correct input sequence for HTLC claims from counterparty commitments
HTLC outputs, like the `to_remote` output, in commitment transactions
with anchor outputs also have an additional `1 CSV` constraint on the
counterparty. When spending such outputs, their corresponding input
needs to have their sequence set to 1. This was done for HTLC claims
from holder commitments, but unfortunately not for counterparty
commitments as we were lacking test coverage.
2023-09-27 11:49:57 -07:00
Valentine Wallace
f3857d0f53
get_route: fix path value contribution to include min htlc overpay
Previously, the fuzzer hit a debug panic because we wouldn't include the amount
overpaid to meet a last hop's min_htlc in the total collected paths value. We
now include this value and also penalize hops along the overpaying path to
ensure that it gets deprioritized in path selection.
2023-09-27 13:19:51 -04:00
Valentine Wallace
ea38b938bb
get_route: fix path_min for first_hop<>network_node candidates
Previously, we would add a first_hop<>network_node channel that did not have
enough contribution amount to cover the next channel's min htlc plus fees,
because we were storing the next hop as having a path_min that did not include
fees, and would add a connecting first_hop node that did not have enough
contribution amount, leading to a debug panic upon invalid path construction.
2023-09-27 13:19:51 -04:00
Valentine Wallace
d83295ff5c
get_route: fix path_min for first_hop<>blinded_hint candidates
See previous commit, but the bug where we would underestimate how much a first
hop candidate needed to be able to relay was also present in blinded paths.
2023-09-27 13:19:51 -04:00
Valentine Wallace
2aacbae67a
get_route: fix path_min when adding first_hop<>route_hint candidates
Previously, we would add a candidate hop to the list of potential hops even
though its available contribution wasn't sufficient to meet the next hop's
min_htlc. We'd subsequently build an invalid path using this hop and hit a
debug assertion.
2023-09-27 13:19:51 -04:00
Valentine Wallace
5263b07b55
get_route: fix outdated var name
Previously this variable was a bool, but has since been updated to be an
Option, so rename accordingly.
2023-09-27 13:19:51 -04:00
Valentine Wallace
29c67d5246
Pathfinding: ignore blinded route hints where we are the intro node
See tests, but the fuzzer found several panics from not fully ignoring these
hints.

We should support these route hints eventually, but it will involve some
reworking of the Path/BlindedTail structs.
2023-09-27 13:19:49 -04:00
Valentine Wallace
b16d6a1e11
Remove trailing whitespace in get_route
Because my text editor loves to do that.
2023-09-27 09:37:21 -04:00
Valentine Wallace
7632cfe517
Refuse to pathfind when provided our_node_id matches internal dummy pk
The fuzzer managed to hit this and it causes some invalid paths to be generated
internally.
2023-09-27 09:37:21 -04:00
Valentine Wallace
6cfb052d98
Pathfinding: log when we ignore one hop blinded route hints 2023-09-27 09:37:21 -04:00
Matt Corallo
0f87ee8883
Merge pull request #2601 from TheBlueMatt/2023-09-117-alpha2
Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2
2023-09-27 03:51:12 +00:00
Matt Corallo
c8e1916b77
Merge pull request #2603 from TheBlueMatt/2023-09-default-route-limit
Set a default max_total_routing_fee_msat of 1% + 50sats
2023-09-27 03:47:16 +00:00
Matt Corallo
7d5f137946
Merge pull request #2602 from TheBlueMatt/2023-09-descriptor-hash
Derive `Hash` for `SpendableOutputDescriptor`
2023-09-27 03:47:09 +00:00
Matt Corallo
bf9144039c
Merge pull request #2359 from domZippilli/2023-06-monitor-updating-persister
Monitor updating persister
2023-09-27 03:46:39 +00:00
Dom Zippilli
0430d3379a Add MonitorUpdatingPersister
MonitorUpdatingPersister is an implementation of Persister that stores
ChannelMonitorUpdates separately from ChannelMonitors. Its RFC is
in #2545, at https://github.com/orgs/lightningdevkit/discussions/2545.

Co-Authored-By: Elias Rohrer <dev@tnull.de>
2023-09-26 16:30:07 -07:00
Matt Corallo
3e1e393f61
Merge pull request #2486 from wvanlint/batch_channel_opens
Batch funding for v1 channel establishments
2023-09-26 22:54:12 +00:00
Matt Corallo
0c31c6f162 Set a default max_total_routing_fee_msat of 1% + 50sats
When using the normal default constructors, we should have some
fee maximum to ensure our default behavior is safe. Here we pick
1% + 50 sats to ensure we're always willing to pay
reasonabl(y high) fees, but not anything too wild.
2023-09-26 22:03:59 +00:00
Matt Corallo
793a1bf679 Derive Debug and Display for Route 2023-09-26 21:59:48 +00:00
Matt Corallo
8a42d55508 Derive Hash for SpendableOutputDescriptor
This allows for easy descriptor de-duplication before building a
claiming transaction.
2023-09-26 20:41:49 +00:00
Willem Van Lint
82341991cb Batch funding for v1 channel establishments 2023-09-26 13:37:14 -07:00
Willem Van Lint
c55a507709 Rename finish_force_close_channel to finish_close_channel 2023-09-26 13:37:14 -07:00
Willem Van Lint
cd4b38dfd3 Always call finish_force_close_channel on closure
This is a step towards more unified closing of channels, and provides a
place where the per_peer_state lock is not held.
2023-09-26 13:37:14 -07:00
Matt Corallo
94140b91d8 Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2 2023-09-26 20:21:08 +00:00
Matt Corallo
1ac53ed02b
Merge pull request #2417 from tnull/2023-07-max-total-fee
Add config option to set maximum total routing fee
2023-09-26 20:07:52 +00:00
Elias Rohrer
6765767cbc
Test max_total_routing_fee_msat handling when retrying overpaid paths
We setup an MPP scenario with two paths in which we need to overpay to
reach `htlc_minimum_msat`. We then fail the overpaid path and check that
on retry our `max_total_routing_fee_msat` only accounts for the path
fees, but not for the fees overpaid in the first attempt.
2023-09-26 20:12:31 +02:00
Elias Rohrer
7895943953
Check max_total_routing_fee is accounted for in test_threaded_payment_retries 2023-09-26 20:12:30 +02:00
Elias Rohrer
26b515c13c
Check max_total_routing_fee is reduced in mpp_retry test
We check that the `RouteParameters::max_total_routing_fee` field is reduced accordingly
to our previously used fees.
2023-09-26 20:12:30 +02:00
Elias Rohrer
649144d25f
Account for leftover fee budget when retrying via check_retry_payment 2023-09-26 20:12:30 +02:00
Matt Corallo
39094d4472 Correct comment in shutdown_on_unfunded_channel
which described the script type incorrectly.
2023-09-26 16:37:40 +00:00
Matt Corallo
974ba314a2 Refer to an "outage" over a "timeout", for when failure happens
Timeouts may be worth retrying, but an outage is a more general
term which obviously cannot be retried.
2023-09-26 16:37:19 +00:00
Matt Corallo
11b228b7b0 Correct ChannelUnavailable error docs on send_payment_with_route
Monitor update failure can no longer lead to a `ChannelUnavailable`
error, but more common cases such as the peer being disconnected
always could, so those should be documented clearer.
2023-09-26 16:37:19 +00:00
Matt Corallo
4abc939aa0 Correct test comments missed in f254c56585 2023-09-26 16:37:19 +00:00
Matt Corallo
827b17c7df
Merge pull request #2597 from TheBlueMatt/2023-09-finish-force-close-deadlocks
Fix potential peer_state deadlocks in `finish_force_close_channel`
2023-09-26 16:36:16 +00:00
Elias Rohrer
ac57163895
Account for leftover fee budget when retrying PartialFailures 2023-09-26 09:44:05 +02:00
Elias Rohrer
b1a878fe81
Test we adhere to max_total_routing_fee_msat 2023-09-26 09:44:05 +02:00