Commit graph

8865 commits

Author SHA1 Message Date
Matt Corallo
a6b8a220be
Merge pull request #3599 from tnull/2025-02-track-amount-in-payment-sent
Track `amount_msat` field in `Event::PaymentSent`
2025-02-14 17:56:06 +00:00
Elias Rohrer
e5d46c5e71
Track amount_msat field in Event::PaymentSent
Previously, we would only track the fees paid, but not the actual amount
that was sent.
2025-02-14 16:05:18 +01:00
Arik Sosman
d3981e11a4
Create structs for InboundOnionPayload variants
In an upcoming commit, we will eliminate various invalid state
combinations between `Hop` and `InboundOnionPayload` enums. To do so,
rather than nesting one within the other, we will instead have them
both referring to the same structs, with variant-dependent supplemental
data. This requires pulling each variant's data into its own type.
2025-02-13 23:36:32 -08:00
Matt Corallo
b05402ae78
Merge pull request #3595 from arik-so/arik/trampoline/inbound-prefactors
Prefactor for inbound Trampoline parsing/decryption
2025-02-13 22:53:34 +00:00
Wilmer Paulino
7cf95e17ff
Merge pull request #3558 from optout21/funding-fee-estimation
Include base input fee in fee, in calculate_our_funding_satoshis()
2025-02-13 11:25:29 -08:00
Jeffrey Czyz
e93aa019ef
Fix debug panic in full_stack fuzz test
d4bd56fc41 changed the logic for calling
unset_funding_info such that it may be called on a channel that was
already in ChannelPhase::Funded when handling funding_signed. This
caused a debug panic in the full_stack fuzz test when calling
FundedChannel::unset_funding_info. Fix this by only calling
unset_funding_info on watch_channel error, as was previously the case.

This also reverts moving the channel back into
ChannelPhase::UnfundedOutboundV1, which should be fine since the channel
is about to be removed.
2025-02-13 11:10:40 -06:00
Arik Sosman
2c685d26e6
Test trampoline-cfg in CI 2025-02-13 08:53:27 -08:00
valentinewallace
11d12d1c8e
Merge pull request #3586 from TheBlueMatt/2025-02-router-fixes
Fix router-backtrack cases in last-hop hints
2025-02-13 07:02:35 -08:00
Arik Sosman
b616559aae
Add TrampolineForward variant to PendingHTLCRouting
Forwarding Trampoline packets requires storing their shared secrets on
top of the outer onion's shared secrets, as well as referencing the
next hop by its node ID as opposed to by an SCID. We modify
PendingHTLCRouting to adequately represent this information.
2025-02-12 17:57:03 -08:00
Matt Corallo
0f3c4d26df Stop wrapping router errors in LightningError
`LightningError` is an error type for returning errors back to the
`PeerHandler` when handling P2P messages. However, it used to be
more broadly used, in a way that never made any sense.

Here we remove on vestige of this, using a `&'static str` for
router errors rather than `LightningError` with a constant
`action`.
2025-02-13 01:48:41 +00:00
Matt Corallo
b3c1b6cda4 More completely ignore route hints which are for our own channels
When we see a channel come into the router as a route-hint, but its
for a direct channel of ours, we'd like to ignore the route-hint as
we have more information in the first-hop channel info. We do this
by matching SCIDs, but only considered outbound SCID aliases.

Here we change to consider both outbound SCID aliases and the full
channel SCID, which some nodes may use in their invoices.
2025-02-13 01:48:41 +00:00
Matt Corallo
83ce6c463d Replace a few router expects with debug_assert + Err-returns
The router is a somewhat complicated beast, and though the last few
commits removed some code from it, a complicated beast it remains.
Thus, having `expect`s in it is somewhat risky, so we take this
opportunity to replace some of them with `debug_assert!(false)`s
and an `Err`-return.
2025-02-13 01:48:41 +00:00
Matt Corallo
303143a957 Add PathBuildingHop::best_path_from_hop_selected
When we process a path backwards from a node during pathfinding, we
implicitly commit to the path up to that node. Any changes to the
preferred path up to that node will make the newly processed path's
state invalid.

In the previous few commits we fixed cases for this in last-hop
paths (both blinded and unblinded).

Here we add assertions to enforce this, tracked in a new bool in
`PathBuildingHop`.
2025-02-13 01:48:41 +00:00
Matt Corallo
b2c635b8e0 Add direct hops to intros after all blinded paths in pathfinding
When we do pathfinding with blinded paths, we start each
pathfinding iteration by inserting all the blinded paths into our
nodes map as last-hops to the destination. As we do that, we check
if any of the introduction points happen to be nodes we have direct
chanels with, as we want to use the local info for such channels
and support finding a path even if that channel is not publicly
announced.

However, as we iterate the blinded paths, we may find a second
blinded path from the same introduction point which we prefer over
the first. If this happens, we would already have added info from
us over the local channel to that intro point and end up with
calculations for the first hop to a blinded path that we no longer
prefer.

This is ultimately fixed here in two ways:
(a) we process the first-hop channels to blinded path introduction
    points in a separate loop after we've processed all blinded
    paths, ensuring we only ever consider a channel to the blinded
    path we will ultimately prefer.
(b) In the next commit, we add we add a new tracking bool in
    `PathBuildingHop` called `best_path_from_hop_selected` which we
    set when we process a channel backwards from a node, indicating
    that we've committed to the best path to the node and check when
    we add a new path to a node. This would have resulted in a much
    earlier debug-assertion in fuzzing or several tests.
2025-02-13 01:48:41 +00:00
Matt Corallo
0351a24722 Move last-hop route handling to the common "normal" hop codepath
When we handle the unblinded last-hop route hints from an invoice,
we had a good bit of code dedicated to handling fee propagation
through the (potentially) multiple last-hops and connecting them to
potentially directly-connected first-hops.

This was a good bit of code that was almost never used, and it
turns out was also buggy - we could process a route hint with
multiple hops, committing to one path through nodes A, B, to C,
then process another route hint (or public channel) which changes
our best path from B to C, making the A entry invalid.

Here we remove the whole maze, utilizing the normal hop-processing
logic in `add_entries_to_cheapest_to_target_node` for last-hops as
well. It requires tracking which nodes connect to last-hop hints
similar to the way we do with `is_first_hop_target` in
`PathBuildingHop`, storing the `CandidateRouteHop`s in a new map,
and always calling `add_entries_to_cheapest_to_target_node` on the
payee node, whether its public or not.
2025-02-13 01:48:41 +00:00
Matt Corallo
ff09619a22 Prefer higher-value, shorter equal-cost paths when routing
This likely only impacts very rare edge cases, but if we have two
equal-cost paths, we should likely prefer ones which contribute
more value (avoiding cases where we use paths which are
amount-limited but equal fee to higher-amount paths) and then paths
with fewer hops (which may complete faster).

It does make test behavior more robust against router changes,
which comes in handy over the coming commits.
2025-02-13 01:48:14 +00:00
optout
c29ec0f926
Drop calculate_our_funding_satoshis(), keep only fee estimation
This method does not take into the intended funding amount, and it's
not currently used, therefore it's removed now. Its fee estimation
part is kept (estimate_v2_funding_transaction_fee).
2025-02-12 07:36:11 +01:00
optout
e1888c5a23 Include base input fee in fee calculation
The base input fee was missing in calculate_our_funding_satoshis(),
it is added now; also add unit test.
2025-02-11 09:22:03 +01:00
Matt Corallo
1b281f15cc
Merge pull request #3577 from tnull/2025-01-rustfmt-offers
`rustfmt`: Run on `offers`
2025-02-10 23:46:31 +00:00
Matt Corallo
f866e2c040
Merge pull request #3562 from joostjager/merge-scores 2025-02-10 17:55:13 +00:00
Joost Jager
e9921ddb01 add scores getter on ProbabilisticScorer
Allows access to the scorer state. An example use case is an LSP
exposing the global network view in its scorer over http to light
clients.
2025-02-10 16:29:23 +01:00
Joost Jager
630246b13f add set_scores method on CombinedScorer to overwrite local data
This commit expands on the previously introduced merge method by
offering a way to simply replace the local scores by the liquidity
information that is obtained from an external source.
2025-02-10 14:47:44 +01:00
Elias Rohrer
f38c88f191
rustfmt: Drop lightning/src/offers/mod.rs from exclusion list 2025-02-10 11:27:34 +01:00
Elias Rohrer
9e72bd3b73
rustfmt: Drop lightning/src/offers/test_utils.rs from exclusion list 2025-02-10 11:27:34 +01:00
Elias Rohrer
ea1dd92b24
rustfmt: Run on lightning/src/offers/test_utils.rs 2025-02-10 11:27:33 +01:00
Elias Rohrer
d96c4f7b66
rustfmt: Drop lightning/src/offers/signer.rs from exclusion list 2025-02-10 11:27:33 +01:00
Elias Rohrer
a129e0ba63
rustfmt: Run on lightning/src/offers/signer.rs 2025-02-10 11:27:29 +01:00
Elias Rohrer
25ef4aa99c
rustfmt: Drop lightning/src/offers/refund.rs from exclusion list 2025-02-10 11:25:19 +01:00
Elias Rohrer
6d9b826b6e
rustfmt: Run on lightning/src/offers/refund.rs 2025-02-10 11:25:19 +01:00
Elias Rohrer
209bf6f91d
rustfmt: Drop lightning/src/offers/payer.rs from exclusion list 2025-02-10 11:25:19 +01:00
Elias Rohrer
705c15d9fc
rustfmt: Drop lightning/src/offers/parse.rs from exclusion list 2025-02-10 11:25:19 +01:00
Elias Rohrer
22b95db7db
rustfmt: Run on lightning/src/offers/parse.rs 2025-02-10 11:25:19 +01:00
Elias Rohrer
8244046908
rustfmt: Drop lightning/src/offers/offer.rs from exclusion list 2025-02-10 11:25:18 +01:00
Elias Rohrer
a439e00eaf
rustfmt: Run on lightning/src/offers/offer.rs 2025-02-10 11:25:18 +01:00
Elias Rohrer
747dc4d9f2
rustfmt: Drop lightning/src/offers/merkle.rs from exclusion list 2025-02-10 11:25:18 +01:00
Elias Rohrer
01702f5790
rustfmt: Run on lightning/src/offers/merkle.rs 2025-02-10 11:25:17 +01:00
Elias Rohrer
f87eeb9303
rustfmt: Prepare lightning/src/offers/merkle.rs 2025-02-10 11:24:43 +01:00
Elias Rohrer
ac632eb502
rustfmt: Drop lightning/src/offers/invoice_request.rs from exclusion list 2025-02-10 11:01:27 +01:00
Elias Rohrer
20cb35fdee
rustfmt: Run on lightning/src/offers/invoice_request.rs 2025-02-10 11:01:26 +01:00
Elias Rohrer
9fc9b88c7f
rustfmt: Prepare lightning/src/offers/invoice_request.rs 2025-02-10 11:01:09 +01:00
Elias Rohrer
63eda06864
rustfmt: Drop lightning/src/offers/invoice_error.rs from exclusion list 2025-02-10 10:54:36 +01:00
Elias Rohrer
e1cab931c3
rustfmt: Run on lightning/src/offers/invoice_error.rs 2025-02-10 10:54:36 +01:00
Elias Rohrer
d6f6024ce2
rustfmt: Drop lightning/src/offers/invoice.rs from exclusion list 2025-02-10 10:54:36 +01:00
Elias Rohrer
6aa85bd7fb
rustfmt: Run on lightning/src/offers/invoice.rs 2025-02-10 10:54:33 +01:00
Arik Sosman
4d9deff091
Switch RequiredWrapper to LengthReadable
In a subsequent commit, we will be storing `TrampolineOnionPacket`s
within `PendingHTLCRouting`, requiring that they be serialized for
storage. To do so, `RequiredWrapper`'s requirements must be loosened to
only require `LengthReadable` instead of `Readable`.
2025-02-10 00:44:08 -08:00
Matt Corallo
ca40276c9f
Merge pull request #3580 from TheBlueMatt/2025-01-peer-connected-consistency
Ensure `peer_disconnected` is called after a handler refuses a connection
2025-02-09 20:38:33 +00:00
Matt Corallo
f5c0433704
Merge pull request #3440 from valentinewallace/2024-12-async-payment-receive
Support receiving async payments
2025-02-08 21:42:34 +00:00
Valentine Wallace
1f53a311e2
Test async receive
In the previous commit we completed support for async receive from an
always-online sender to an often-offline receiver, minus support for acting as
the async receiver's always-online channel counterparty.
2025-02-07 15:37:44 -08:00
Matt Corallo
7869953ab0
Merge pull request #3386 from arik-so/arik/trampoline/payload-construction
Trampoline Payload Construction Method
2025-02-07 23:26:37 +00:00
Valentine Wallace
8d1d136be6
Test utils: fix config overrides for private channels
Previously, this test util did not account for config overrides supplied at
node creation time. Uncovered because it caused test nodes to be unable to
forward over private channels created with this util because that is not the
default.
2025-02-07 12:38:40 -08:00