Commit Graph

16867 Commits

Author SHA1 Message Date
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
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
bitromortac
2edbe6b878
routing: extract getEdgeUnifiers
We split up the functionality in getRouteUnifiers into checking that all
edges exist via getEdgeUnifiers and then add a backward pass that will
be responsible for determining the sender amount.

We remove the node pub key from the error string, as in route building
this is duplicate info, which can be determined from the input keys,
further it's not available in the backward pass anymore.

We refactor the BuildRoute test to use the require library and add a
test case for a max HTLC violation on the last hop.
2024-07-30 15:49:50 +02:00
bitromortac
16f6284d97
routing: reorganize BuildRoute 2024-07-30 15:49:50 +02:00
Olaoluwa Osuntokun
9decf80a68
Merge pull request #8735 from ellemouton/rb-receives
[2/4] Route Blinding Receives: Receive and send to a single blinded path in an invoice.
2024-07-29 19:00:06 -07:00
Oliver Gugger
b7c59b36a7
Merge pull request #8896 from ziggie1984/batchopen-feerate-fix
Fix batchopen fee calculation
2024-07-26 05:52:48 -06:00
Elle Mouton
c490279002
blindedpath: smarter dummy hop policy selection
This commit introduces more sophisticated code for selecting dummy hop
policy values for dummy hops in blinded paths.

For the case where the path does contain real hops, the dummy hop policy
values are derived by taking the average of those hop polices. For the
case where there are no real hops (in other words, we are the
introduction node), we use the default policy values used for normal
ChannelUpdates but then for the MaxHTLC value, we take the average of
all our open channel capacities.
2024-07-26 13:03:07 +02:00
ziggie
eb7818a633
docs: add release-notes. 2024-07-26 10:48:00 +02:00
ziggie
bf38aed87f
lnd: unify the default setting behaviour.
Setting default values for the channel opening fee rate is already
done elsewhere therefore we remove on of those checks and return
an error if no fee rate is specified.
2024-07-26 10:48:00 +02:00
ziggie
d0a7765c68
rpcserver: include fee calc. for psbt flow.
Include the fee calculaltion for the psbt flow. Moreover include
fee rate testing in the itest environment.
2024-07-26 10:48:00 +02:00
Elle Mouton
60a856ab65
record/routing: set minimum padding size 2024-07-26 10:32:47 +02:00
Elle Mouton
398623bde5
blindedpath: move blinded path logic to own pkg 2024-07-26 09:54:59 +02:00
Elle Mouton
c62a9c235e
itest: test blinded paths over private channels 2024-07-26 09:54:38 +02:00
Elle Mouton
74e45ec4bf
docs: update release notes 2024-07-26 09:54:38 +02:00
Elle Mouton
66765de413
itest: add route blinding dummy hops test
Add an itest that tests the addition of dummy hops to a blinded path. By
testing that invoices containing such a path can be paid, it also tests
the peeling of dummy hops by the receiver.
2024-07-26 09:54:38 +02:00
Elle Mouton
f0558babf3
multi: send MPP payment to blinded path
Make various sender side adjustments so that a sender is able to send an
MP payment to a single blinded path without actually including an MPP
record in the payment.
2024-07-26 09:54:38 +02:00
Elle Mouton
64a99d4a8e
itest: end to end route blinding invoices test
Update one of the route blinding itests to do a full end-to-end test
where the recipient generates and invoice with a blinded path and the
sender just provides that invoice to SendPayment.

The tests also covers the edge case where the recipient is the
introduction node.
2024-07-26 09:54:38 +02:00
Elle Mouton
735d7d9738
multi: send to a blinded path in an invoice
Update the SendPayment flow so that it is able to send to an invoice
containing a blinded path.
2024-07-26 09:54:37 +02:00
Elle Mouton
34d8fff5f9
itest: update route blind tests
The route blinding itests are now updated so that recipient logic is
tested. The creation of a blinded route is also now done through the
AddInvoice API instead of manually.
2024-07-26 09:54:18 +02:00
Elle Mouton
65aef6a69c
htlcswitch: handle blinded path dummy hops
If a blinded path payload contains a signal that the following hop on
the path is a dummy hop, then we iteratively peel the dummy hops until
the final payload is reached.
2024-07-26 09:54:18 +02:00
Elle Mouton
b0d3e4dc0d
multi: extract path ID and total amt from received payment
We've covered all the logic for building a blinded path to ourselves and
putting that into an invoice - so now we start preparing to actually be
able to recognise the incoming payment as one from a blinded path we
created.

The incoming update_add_htlc will have an `encrypted_recipient_data`
blob for us that we would have put in the original invoice. From this we
extract the PathID which we wrote. We consider this the payment address
and we use this to derive the associated invoice location.

Blinded path payments will not include MPP records, so the payment
address and total payment amount must be gleaned from the pathID and new
totalAmtMsat onion field respectively.

This commit only covers the final hop payload of a hop in a blinded
path. Dummy hops will be handled in the following commit.
2024-07-26 09:54:18 +02:00
Elle Mouton
3d9c77d1fc
htlcswitch+refactor: add rHash and sphinx.Router to sphinxHopIterator
This will be required to construct a new hop iterator for when peeling
of dummy hops is done for route blinding.
2024-07-26 09:54:18 +02:00
Elle Mouton
c1c2e1c6ce
htlcswitch+refactor: continue modularising extractTLVPayload
We further break up the extracTLVPayload into more modular pieces. The
pieces are structured in such a way as to prepare for extracTLVPayload
being called in a recursive manner from within
`deriveBlindedRouteForwardingInfo` when we add the logic for handling
dummy hops in a later commit. With this refactor, we completey remove
the BlindingKit's DecryptAndValidateFwdInfo method.
2024-07-26 09:54:18 +02:00
Elle Mouton
55c25f427f
htlcswitch+refactor: continue modularising extractTLVPayload
In this refactor commit, we extract all the steps from extractTLVPayload
that have to do with parsing the payload from the sender and verifying
the presence of various fields from the sender.
2024-07-26 09:54:18 +02:00
Elle Mouton
a15e4bb55f
refactor+htlcswitch: method for TLV payload parsing logic
In preparation for calling the TLV payload parsing logic recursively for
when we need to peel dummy hops from an onion, this commit creates a new
extractTLVPayload function. This is a pure refactor.
2024-07-26 09:54:18 +02:00
Elle Mouton
18cb7f0b87
lncli: add --blind option to addinvoice
In this commit, we expose the option to create an invoice containing
blinded paths to lncli.
2024-07-26 09:54:18 +02:00
Elle Mouton
de975334cd
multi: add blinded paths to invoices
Expose the ability to add blinded paths to an invoice. Also expose
various configuration values.

We also let the lncfg.Invoices struct satisfy the Validator interface so
that we can verify all its config values in one place.
2024-07-26 09:54:17 +02:00
Elle Mouton
e12a226272
routing: use mission control to select blinded paths
Add a `FindBlindedPaths` method to the `ChannelRouter` which will use
the new `findBlindedPaths` function to get a set of candidate blinded
path routes. It then uses mission control to select the best of these
paths.

Note that as of this commit, the MC data we get from these queries won't
mean much since we wont have data about a channel in the direction
towards us. But we do this now in preparation for a future PR which will
start writing mission control success pairs for successful receives from
blinded route paths.
2024-07-26 09:54:17 +02:00
Elle Mouton
1039aedd0c
routing: find blinded paths to a destination node
This commit adds a new function, `findBlindedPaths`, that does a depth
first search from the target node to find a set of blinded paths to the
target node given the set of restrictions. This function will select and
return any candidate path. A candidate path is a path to the target node
with a size determined by the given hop number constraints where all the
nodes on the path signal the route blinding feature _and_ the
introduction node for the path has more than one public channel. Any
filtering of paths based on payment value or success probabilities is
left to the caller.
2024-07-26 09:54:17 +02:00
Elle Mouton
9787ae9c89
lnrpc/invoicesrpc: prep AddInvoice for blinded routes
Here we add a new `Blind` option to the `AddInvoiceData` which will
signal that the new invoice should encode a blinded route.

Certain other changes are also made in the case that this invoice
contains a blinded route:
1) the payment address/secret no longer needs to be in the invoice
   itself since it will be put in the `PathID` recored of the encrypted
   recipient record for our hop.
2) When we sign the invoice, we now use an ephemeral key since we dont
   want the sender to be able to derive our real node pub key from the
   invoice signature.
3) The invoice's FinalCLTV field should be zero for blinded invoices
   since the CLTV delta info will be communicated in the accumulated
   route policy values.
2024-07-26 09:54:17 +02:00
Elle Mouton
4b5327f057
lnrpc/invoicesrpc: build blinded path
This commit adds all the logic for building a blinded path (from a given
route) and packaging it up in a zpay32.BlindedPaymentPath struct so that
it is ready for adding to an invoice. It also includes logic for padding
a path with dummy hops.

Note that in this commit, the logic for choosing an actual path to us
that can then be used in a blinded path is abstracted away. This logic
will be fleshed out in a future commit.
2024-07-26 09:54:17 +02:00
Elle Mouton
0855e3e71a
lnrpc/invoicesrpc: add blinded path policy buffer
This commit adds a helper function that will be used to adjust a hops
policy values by certain given increase and decrease multipliers. This
will be used in blinded paths to give policy values some buffer to avoid
easy probing of blinded paths.
2024-07-26 09:54:17 +02:00
Elle Mouton
3b2a6042ff
lnrpc/invoicesrpc: blinded path total path policy calc
This commit adds a function that can be used to compute the accumulated
path policy for a blinded path as defined in the spec:

db278ab9b2/04-onion-routing.md (L255)
2024-07-26 09:54:17 +02:00
Elle Mouton
f87cc6274f
lnrpc/invoicesrpc: add function for padding encrypted data
This commit adds a helper function called `padHopInfo` along with a test
for it. This function will be used later on when building a blinded
path. It is used to ensure that all encrypted blobs of a blinded path
that we construct are padded to the same size.
2024-07-26 09:54:16 +02:00
Elle Mouton
4457ca2e66
record: stricter type for PaymentRelayInfo.BaseFee
In this commit, we update the PaymentRelayInfo struct's BaseFee member
to use a stricter type (lnwire.MilliSatoshi) instead of an ambigious
uint32.
2024-07-26 09:53:49 +02:00
Elle Mouton
62a97f86dd
record: add NextNodeID type to BlindedRouteData
Add the NextNodeID TLV (tlv type 4) to the BlindedRouteData TLV stream.
This will be used during the dummy hop payload construction.
2024-07-26 09:53:49 +02:00
Elle Mouton
9192c165ff
feature: define new feature bit for bolt11 blinded paths
We need a new feature bit for BOLT11 invoices in order to indicate that
they contain the new blinded path tagged field. Tagged fields pre-date
TLV and so nodes who dont understand them will simply skip them.
Therefore the feature bit helps them to fail fast.
2024-07-26 09:53:49 +02:00
Elle Mouton
188dd44b42
zpay32: improve readability of blinded path encoding 2024-07-26 09:53:49 +02:00
Elle Mouton
4f5dd20f7e
go.mod: update lightning-onion dep 2024-07-26 09:53:48 +02:00
Olaoluwa Osuntokun
8c0d7862c2
Merge pull request #8937 from Roasbeef/go-1-22-5
build: update to Go 1.22.5
2024-07-25 13:14:57 -07:00
Olaoluwa Osuntokun
bc2922232c
build: remove old Travis references
We no longer use Travis.
2024-07-25 13:14:26 -07:00
Oliver Gugger
b40f165310
Merge pull request #8891 from yyforyongyu/fix-fee-estimator
chainfee: allow specifying min relay feerate from the API source
2024-07-25 11:40:18 -06:00
yyforyongyu
d992cf94d6
multi: add SpewLogClosure to avoid code repetition 2024-07-25 22:18:49 +08:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
Olaoluwa Osuntokun
9e2b308f93
build: update to Go 1.22.5 2024-07-24 14:21:13 -07:00
yyforyongyu
7e60d41898
chainfee: make sure web API has been started before estimating
Previously we may get a floor feerate when calling `EstimateFeePerKW`
due to the fee estimator not finishing its startup process, which gives
us an empty fee map.

This is now fixed to return an error if the estimator is not started.
2024-07-24 20:05:00 +08:00
yyforyongyu
0a0d51ce22
docs: update release notes 2024-07-24 20:05:00 +08:00
yyforyongyu
a1d71afde8
lntest: allow specifying min relay feerate in itest 2024-07-24 20:05:00 +08:00