Commit graph

1141 commits

Author SHA1 Message Date
ziggie
a8500d3b1d
localchans: bugfix so that we always use the correct chanID 2025-02-04 09:49:49 +01:00
Oliver Gugger
f78cafca7e
multi: fix CI for minor release branch
This commit fixes a couple of issues that only occur on the branch we
use for minor releases. The branch doesn't contain all refactors and
cleanups so a couple of very minor things need to be fixed.
Because we don't have all new features of the master branch we also
can't apply the fuzz corpora for the master branch as that can lead to
false positives.
2025-01-30 17:25:08 +01:00
ziggie
a863534f41
multi: introduce new traffic shaper method.
We introduce a new specific fail resolution error when the
external HTLC interceptor denies the incoming HTLC. Moreover
we introduce a new traffic shaper method which moves the
implementation of asset HTLC to the external layers.
Moreover itests are adopted to reflect this new change.
2025-01-30 08:36:56 +01:00
Jesse de Wit
f49021240f
localchans: do error if an edge policy is missing 2025-01-28 18:18:17 +01:00
Jesse de Wit
b45deab379
localchans: add policy when missing 2025-01-28 18:18:16 +01:00
Jesse de Wit
454e94f556
localchans: add test for createEdge and manager 2025-01-28 18:18:16 +01:00
Jesse de Wit
8cc78b371d
localchans: recreate missing edge if not found
If a node contains a channel, but doesn't have a corresponding edge in
the graph database, updating the channel policy would fail. In this
commit the edge is recreated if the channel exists. This ensures a node
can recover from a missing edge in the graph database by calling
updatechanpolicy.
2025-01-28 18:18:11 +01:00
ziggie
4c61411802
routing: bugfix for mc reporting of blinded paths
When reporting an error  or a success case of a payment to a
blinded paths, the amounts to forward for intermediate hops
are set to 0 so we need to use the receiver amount instead.
2024-12-10 22:29:29 +01:00
ziggie
a1e5dfc266
routing: add pathfinding test
We add a test where we add duplicate hops in a route and verify
that the pathfinding engine can handle this edge case.
2024-12-10 20:27:25 +01:00
ziggie
c579a6bf2f
routing: improve lasthoppaylaod size calculation
Fixes a bug and makes the function more robust. Before
we would always return the encrypted data size of last hop
of the last path. Now we return the greatest last hop payload
not always the one of the last path.
2024-12-10 20:27:25 +01:00
ziggie
eb93eb7ee9
routing: Use NUMS point for blinded paths
To be able to do MPP payment to multiple blinded routes we need
to add a constant dummy hop as a final hop to every blined path.
This is used when sending or querying a blinded path, to let the
pathfinder be able to send MPP payments over different blinded
routes. For this dummy final hop we use a NUMS key so that we
are sure no other node can use this blinded pubkey either in a
normal or blinded route.
Moreover this helps us handling the mission control data for
blinded paths correctly because we always consider the blinded
pubkey pairs which are registered with mission control when
a payment to a blinded path fails.
2024-12-10 20:27:24 +01:00
Oliver Gugger
699e2b74f6
multi: move routing.TlvTrafficShaper => htlcswitch.AuxTrafficShaper
With this commit we move the traffic shaper definition from the routing
package to the HTLC switch package as a preparation for being able to
use it there as well.
At the same time we rename it to AuxTrafficShaper to be more in line
with the other auxiliary components.
2024-12-05 21:44:56 +01:00
George Tsagkarelis
9d50e273a3
routing: add htlcAmt to PaymentBandwidth method of TlvTrafficShaper
This commit was added to the 0-19-staging branch recently and therefore
didn't make it into a previous part yet. So it's unrelated to the
changes in this part but is required for the whole custom channel saga.
2024-10-11 14:22:09 +02:00
Elle Mouton
d2c745e610
multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if
it is a pointer.
2024-10-11 14:20:17 +02:00
George Tsagkarelis
444ef199a6
routing: use first hop records on path finding 2024-10-11 14:13:48 +02:00
Oliver Gugger
5489b06628
channeldb+routing: persist first hop custom data for route 2024-10-11 14:13:48 +02:00
Olaoluwa Osuntokun
ec2b2c6e1e
routing: skip amtInRange for custom HTLCs
We might be trying to send an invoice amount that's greater than the size of the channel, but once you factor in the custom channel logic, an actual HTLC can be sent over the channel to pay that larger payment.

As a result, we'll skip over this check if a have a custom HTLC.
2024-10-11 14:13:48 +02:00
George Tsagkarelis
f927563049
routing: add TlvTrafficShaper to bandwidth hints 2024-10-11 14:13:48 +02:00
Oliver Gugger
ff1a45549e
channeldb+routing: persist first hop custom records
With this commit we make sure the first hop custom records aren't lost
on restart/resume of a payment, so we persist it as part of the
PaymentCreationInfo struct.
2024-10-11 14:13:47 +02:00
George Tsagkarelis
857a16d838
lnrpc: add wire records fields to payment+interceptor RPCs 2024-10-11 14:13:47 +02:00
George Tsagkarelis
ef2c9801fb
multi: use wire records on payment and intercept flows 2024-10-11 14:13:47 +02:00
ziggie
59355b17a5 blindedpath: minHTLC for blinded path change.
We will not add a buffer to the chan policy for blinded paths in case
the sender amount violates the minHTLC restriction in the first place.

Moreover we disgard a route fast if the payment amount is smaller than
the minHTLC along the route.
2024-08-26 20:19:31 -05:00
ziggie
89ef3737b1 blindedpath: fix log output. 2024-08-26 20:19:31 -05:00
ziggie
38c81516ec blindedpath: remove blockexpiry check.
Removes a check where we would NOT allow to create a blinded invoice
with an expiry (invoice expiry in seconds considered as block time)
lower than the min_final_ctlv_delta.
2024-08-26 20:19:31 -05:00
Elle Mouton
ab28cde240
routing: correct initial finalPaddedSize
This purely affects logging. This makes sure that the `padStat`
finalPaddedSize field is initilised correctly with the given minSize.
2024-08-08 16:46:04 +02:00
Olaoluwa Osuntokun
459ee9b245
Merge pull request #8976 from ellemouton/rb-follow-ups
route blinding: follow ups
2024-08-07 17:54:31 -07:00
Elle Mouton
697f514d09
blindedpath: log chosen blinded paths
In this commit, we log selected blinded paths.
2024-08-07 17:03:12 +02:00
Elle Mouton
e4619afc08
multi: add node omission list for blinded paths 2024-08-07 17:03:11 +02:00
Elle Mouton
b490deefdf
routing/blindedpath: dont error out unless all paths fail
In this commit, we adjust BuildBlindedPaymentPaths to only error out
completely if none of the paths it received from FindRoutes resulted in
a usable blinded path.
2024-08-07 17:02:56 +02:00
Elle Mouton
e47160d257
routing: fix MC probability order for blinded paths
Fix the blinded path probability sorting function.
Also fix the test assertion function.
2024-08-07 17:01:21 +02:00
yyforyongyu
bc31a8b36f
routing: fix doc string 2024-08-07 22:19:23 +08:00
yyforyongyu
188aa9a4d4
routing+lnd: prepare closed channel SCIDs in server
The method `FetchClosedChannels` sometimes prematurely mark a pending
force closing channel as finalized, therefore we need to furthur check
`FetchPendingChannels` to make sure the channel is indeed finalized.
2024-08-07 22:19:23 +08:00
yyforyongyu
c2f7e6a66f
routing: fail stale HTLC attempts during startup
This commit adds a check during router's startup and fails the inflight
HTLCs if they are routing using channels unknown to us. The channels are
unknown because they are already closed, usually long time ago.
2024-08-07 22:19:21 +08:00
yyforyongyu
b998ce11f1
routing+htlcswitch: add new interface method HasAttemptResult 2024-08-07 22:18:51 +08:00
yyforyongyu
bbf58ab444
routing: add new method resumePayments to handle payments during
startup
2024-08-07 22:18:49 +08:00
yyforyongyu
0928ba0149
routing: fix and enhance logging 2024-08-07 22:17:58 +08:00
Oliver Gugger
b63e5decad
Merge pull request #8886 from bitromortac/buildroute-inbound-fees
routing: inbound fees support for BuildRoute
2024-08-07 08:11:17 -06:00
bitromortac
452db01ad7
lnrpc+routing: convert amt pointer to fn.Option 2024-08-07 14:24:56 +02:00
bitromortac
8b32e3e785
routing: add inbound fee support for BuildRoute 2024-08-07 14:23:54 +02:00
bitromortac
36cd03669b
routing: add outgoingFromIncoming amount calc
Adds a utility function to be able to compute the outgoing routing
amount from the incoming amount by taking inbound and outbound fees into
account. The discussion was contributed by user feelancer21, see
f6f05fa930.
2024-08-07 12:40:42 +02:00
bitromortac
2c79bf9635
routing: refactor backward and forward pass 2024-08-07 12:40:42 +02:00
Elle Mouton
6ab34665fb
routing: fix race in TestNewRouteRequest
The `err` variable was being shared by the parallel threads.
2024-08-05 16:07:03 +02:00
Oliver Gugger
11c7e20d0a
Merge pull request #8953 from ProofOfKeags/refactor/lnwallet-channel-channel-constraints-partition
[MICRO]: multi: break ChannelConstraints into two sub-structures
2024-08-05 02:08:52 -06:00
Keagan McClelland
e3a9d0acbe
multi: break ChannelConstraints into two sub-structures
This commit breaks the ChannelConstraints structure into two
sub-structures that reflect the fundamental differences in how
these parameters are used. On its face it may not seem necessary,
however the distinction introduced here is relevant for how we
will be implementing the Dynamic Commitments proposal.
2024-08-01 12:00:32 -07:00
bitromortac
c18694ff5e
routing: backward pass determines unified edges
We shift the duty of determining the policies to the backward pass as
the forward pass will only be responsible for finding the corrected
receiver amount.

Note that this is not a pure refactor as demonstrated in the test, as
the forward pass doesn't select new policies anymore, which is less
flexible and doesn't lead to the highest possible receiver amount. This
is however neccessary as we otherwise won't be able to compute
forwarding amounts involving inbound fees and this edge case is unlikely
to occur, because we search for a min amount for a route that was most
likely constructed for a larger amount.
2024-08-01 11:16:18 +02:00
bitromortac
e4c7c10618
routing: handle both amounts equally
We duplicate the function calls to handle the min amount and known
amount cases in a similar manner, to make the next diff easier to
parse.
2024-08-01 11:16:15 +02:00
Slyghtning
2e3c96f986
routing: new failure reason for cancelled payments 2024-08-01 10:24:08 +02:00
Elle Mouton
b271922501
routing: dont use InPolicy for blinded paths
We only need the ChannelID, so no need to use the InPolicy which might
be nil.
2024-07-31 09:36:06 +02:00
Elle Mouton
e87110317b
routing: final changes to BlindedPaymentPathSet
Continue adding some complexity behind the BlindedPaymentPathSet. What
we do here is add a new IntroNodeOnlyPath method. The assumption we
make here is: If multiple blinded paths are provided to us in an invoice
but one of those paths only includes an intro node, then there is no
point in looking at any other path since we know that the intro node is
the destination node. So in such a case, we would have discarded any
other path in the `NewBlindedPaymentPathSet` constructor. So then we
would only have a single blinded path made up of an introduction node
only. In this specific case, in the `newRoute` function, no edge passed
to the function would have a blindedPayment associated with it (since
there are no blinded hops in this case). So we will have a case where
`blindedPathSet` passed to `newRoute` is not nil but `blindedPayment` is
nil since nonce was extacted from any edge. If this happens then we can
assume that this is the Intro-Node-Only situation described above. And
so we grabe the associated payment from the path set.
2024-07-31 09:15:43 +02:00
Elle Mouton
daaa24b69c
routing: let BlindedPaymentPathSet handle FinalCLTV logic
Instead of needing to remember how to handle the FinalCLTV value of a
blinded payment path at various points in the code base, we hide the
logic behind a unified FinalCLTVDelta method on the blinded path.
2024-07-31 09:15:24 +02:00