Commit graph

16578 commits

Author SHA1 Message Date
ffranr
197b291aae
multi: pass UpdateAddHtlc message custom records to invoice modifier 2024-05-28 08:07:47 +02:00
ffranr
c0d2b53816
itest: add basic invoice HTLC modifier integration test
This commit introduces a basic integration test for the invoice
HTLC modifier. The test covers scenarios where an invoice is settled with a
payment that is less than the invoice amount, facilitated by the invoice
HTLC modifier.
2024-05-27 20:33:52 +02:00
ffranr
08429c63fc
lntest: add HtlcModifier support to node RPC harness
This commit enhances the itest LND node harness to include support for
the new `HtlcModifier` RPC endpoint.
At the same time we move another method to the correct file.
2024-05-27 20:33:52 +02:00
ffranr
2580661acb
invoicesrpc: add HtlcModifier RPC endpoint and modifier RPC server
This commit introduces a singleton invoice HTLC modifier RPC server and
an endpoint to activate it. The server interfaces with the internal
invoice HTLC modifier interpreter, handling the marshalling between RPC
types and internal formats.
2024-05-27 20:33:52 +02:00
ffranr
73f52c8b11
invoicesrpc: add HTLC modifier to invoices RPC server
This commit integrates the HTLC modifier service into the
invoices RPC server.
2024-05-27 20:23:02 +02:00
ffranr
7e8a3b0df7
lnd: initialize invoice settlement interceptor at server startup
This commit initiates the invoice settlement interceptor during the
main server startup, assigning it a handle within the server.
2024-05-27 20:23:02 +02:00
ffranr
12ad0cbf5a
invoices: integrate settlement interceptor with invoice registry
This commit updates the invoice registry to utilize the settlement
interceptor during the invoice settlement routine. It allows the
interceptor to capture the invoice, providing interception clients an
opportunity to determine the settlement outcome.
2024-05-27 20:23:01 +02:00
ffranr
72abc94fe8
invoices: add invoice htlc interceptor service
This commit introduces a new invoice htlc interceptor service
that intercepts invoice HTLCs during their settlement phase. It forwards
HTLCs to a subscribed client to determine their settlement outcomes.

This commit also introduces an interface to facilitate integrating the
interceptor with other packages.
2024-05-27 20:23:01 +02:00
Oliver Gugger
b628483120
routing: update TLV traffic shaper interface 2024-05-27 20:23:01 +02:00
Oliver Gugger
1404468299
routing: remove unused struct member 2024-05-27 20:23:01 +02:00
Oliver Gugger
8865484fb7
routing+lnrpc: fix log statements 2024-05-27 20:23:01 +02:00
Oliver Gugger
a3cdae0f7a
htlcswitch: override amount check on custom records 2024-05-27 20:23:00 +02:00
Oliver Gugger
be752ac2d3
Merge pull request #8641 from lightningnetwork/custom-channels-integration
[5/5]: lnwallet: extensions to aux leaf store to integrate custom channels
2024-05-27 20:22:02 +02:00
Oliver Gugger
d2d50649ce
lnwallet: add HTLC index to commitment sorting function
To avoid sorting issues with identical HTLCs (equal size, equal payment
hash, equal CLTV), we need to also use the HTLC index to be able to
distinguish between them.
2024-05-27 18:19:47 +02:00
Oliver Gugger
a62600799e
htlcswitch+channeldb+lnwallet: fix CustomRecord decoding
It doesn't make sense to do multiple encode/decode round trips on the
custom data of an HTLC. So we just use the same custom record type
everywhere, which also simplifies some of the code again.
2024-05-27 18:19:47 +02:00
Oliver Gugger
f59c0c12cf
channeldb: add NextHeight, fix formatting 2024-05-27 18:19:45 +02:00
Oliver Gugger
b2d41ee4aa
server: fix logging of pubkey 2024-05-27 18:19:41 +02:00
Oliver Gugger
2ef42c6c51
lntest: fix comments 2024-05-27 15:53:11 +02:00
Oliver Gugger
a780c81340
lnd: add aux data parser
This commit adds an optional data parser that can inspect and in-place
format custom data of certain RPC messages.
We don't add an implementation of the interface itself, as that will be
provided by external components when packaging up lnd as a bundle with
other software.
2024-05-27 15:53:11 +02:00
Oliver Gugger
1b3f386979
lnrpc+rpcserver: add and populate custom channel data 2024-05-27 15:53:11 +02:00
Oliver Gugger
8a0222c347
cmd/commands: export StripPrefix 2024-05-27 15:53:11 +02:00
Oliver Gugger
c25b04fbea
lnwallet: add Tree() method, fix formatting 2024-05-27 15:53:10 +02:00
Oliver Gugger
1552a67f3f
lnwallet: export GenTaprootHtlcScript 2024-05-27 15:53:10 +02:00
Oliver Gugger
74ba9e9e4d
lnwallet: export AnchorSize 2024-05-27 15:53:10 +02:00
Oliver Gugger
1f3f954a02
lnwallet: add AddHeight and RemoveHeight funcs 2024-05-27 15:53:10 +02:00
Oliver Gugger
26e759423b
cmd/lncli: move commands and export
We want to export some of our CLI code to re-use in other projects. But
in Golang you cannot import code from a `main` package.
So we need to move the actual code into its own package and only have
the `func main()` in the `main` package.
2024-05-27 15:53:10 +02:00
Oliver Gugger
626a1b87fa
Merge pull request #8632 from lightningnetwork/aux-leaf-signing
[4/5]: lnwallet: add new AuxSigner interface to mirror SigPool
2024-05-27 15:46:24 +02:00
Oliver Gugger
652ff81461
Merge pull request #8622 from lightningnetwork/aux-funding
[3/5]: multi: add new AuxFundingController for custom external funding flows
2024-05-27 15:26:13 +02:00
Olaoluwa Osuntokun
ebf9856fac
lnwallet: obtain+verify aux sigs for all second level HTLCs
In this commit, we start to use the new AuxSigner to obtain+verify aux sigs for all second level HTLCs. This is similar to the existing SigPool, but we'll only attempt to do this if the AuxSigner is present (won't be for most channels).
2024-05-27 13:02:16 +02:00
Olaoluwa Osuntokun
9b869f95bf
lnwallet: add WithAuxSigner option to channel 2024-05-27 13:02:16 +02:00
Olaoluwa Osuntokun
d908e8c2f7
lnwallet: add new AuxSigner interface to mirror SigPool
In this commit, we add a new aux signer interface that's meant to mirror the SigPool. If present, this'll be used to (maybe) obtain signatures for second level HTLCs for certain classes of custom channels.
2024-05-27 13:02:16 +02:00
Oliver Gugger
a350ccd791
funding: inform aux controller about channel ready/finalize 2024-05-27 12:58:29 +02:00
Oliver Gugger
6b7849950a
multi: add tapscript root to gossip message 2024-05-27 12:58:29 +02:00
Olaoluwa Osuntokun
bf307d30d1
funding+lnwallet: finish hook up new aux funding flow
For the initiator, once we get the signal that the PSBT has been
finalized, we'll call into the aux funder to get the funding desc. For
the responder, once we receive the funding_created message, we'll do the
same.

We now also have local+remote aux leaves for the commitment transaction.

Some old TODO comments that in retrospect aren't required anymore are
removed as well.
2024-05-27 12:58:29 +02:00
Olaoluwa Osuntokun
26ab75852b
funding+lnwallet: only blind tapscript root early in funding flow
In this commit, we modify the aux funding work flow slightly. We won't
be able to generate the full AuxFundingDesc until both sides has
sent+received funding params. So we'll now only attempt to bind the
tapscript root as soon as we send+recv the open_channel message.

We'll now also make sure that we pass the tapscript root all the way
down into the musig2 session creation.
2024-05-27 12:58:29 +02:00
Olaoluwa Osuntokun
28cb4884ca
lnwallet: for PsbtIntent return the internal key in the POutput
We also add a new assertion to the itests to ensure the field is being properly set.
2024-05-27 12:58:28 +02:00
Olaoluwa Osuntokun
a841a9be30
lnwallet: add TaprootInternalKey method to ShimIntent
If this is a taproot channel, then we'll return the internal key which'll be useful to callers.
2024-05-27 12:58:28 +02:00
Olaoluwa Osuntokun
bb71c496f4
config+serer: add AuxFundingController as top level cfg option 2024-05-27 12:58:28 +02:00
Olaoluwa Osuntokun
2f6e7ef191
funding: create new AuxFundingController interface
In this commit, we make a new `AuxFundingController` interface capable of processing messages off the wire. In addition, we can use it to abstract away details w.r.t how we obtain a `AuxFundingDesc` for a given channel.

We'll now use this whenever we get a channel funding request, to make sure we pass along the custom state that a channel may require.
2024-05-27 12:58:28 +02:00
Olaoluwa Osuntokun
54bbc25d9a
lnwallet: use AuxFundingDesc to populate all custom chan info
With this commit, we'll now populate all the custom channel information within the OpenChannel and ChannelCommitment structs.
2024-05-22 18:24:52 +02:00
Olaoluwa Osuntokun
f2c2a82744
lnwallet: add new AuxFundingDesc struct
This struct will house all the information we'll need to do a class of custom channels that relies primarily on adding additional items to the tapscript root of the HTLC/commitment/funding outputs.
2024-05-22 18:24:52 +02:00
Olaoluwa Osuntokun
dd357fb847
funding: use atomic.Uint64 for chanIDNonce
This lets us get rid of the mutex usage there. We also shift the algo slightly to increment by 1, then use that as the next value, which plays nicer with the atomics.
2024-05-22 18:24:52 +02:00
Olaoluwa Osuntokun
8ba3f3a317
funding: add new type alias for PendingChanID = [32]byte
This'll be useful for new interface definitions that use the contents of the package.
2024-05-22 18:24:51 +02:00
Olaoluwa Osuntokun
5866287aae
multi: make MsgRouter available in the ImplementationCfg
With this commit, we allow the `MsgRouter` to be available in the `ImplementationCfg`. With this, programs outside of lnd itself are able to now hook into the message processing flow to direct handle custom messages, and even normal wire messages.
2024-05-22 18:24:51 +02:00
Olaoluwa Osuntokun
371e0148dc
peer: update readHandler to dispatch to msgRouter if set
Over time with this, we should be able to significantly reduce the size
of the peer.Brontide struct as we only need all those deps as the peer
needs to recognize and handle each incoming wire message itself.
2024-05-22 18:24:51 +02:00
Olaoluwa Osuntokun
e5e5da381d
log+protofsm: add new abstract message router
In this commit, we add a new abstract message router. Over time, the
goal is that this message router replaces the logic we currently have in
the readHandler (the giant switch for each message).

With this new abstraction, can reduce the responsibilities of the
readHandler to *just* reading messages off the wire and handing them off
to the msg router. The readHandler no longer needs to know *where* the
messages should go, or how they should be dispatched.

This will be used in tandem with the new `protofsm` module in an
upcoming PR implementing the new rbf-coop close.
2024-05-22 18:24:51 +02:00
Oliver Gugger
5d53431f59
Merge pull request #8665 from GeorgeTsagk/custom-sender-bandwidth-hint
routing: add TlvTrafficShaper to bandwidth hints
2024-05-22 18:24:08 +02:00
George Tsagkarelis
53e9f288ed
routing: use first hop records on path finding 2024-05-22 17:28:22 +02:00
George Tsagkarelis
a584b7585d
lnd: use impl cfg TlvTrafficShaper 2024-05-22 17:28:22 +02:00
George Tsagkarelis
37cbfea912
routing: add TlvTrafficShaper to bandwidth hints 2024-05-22 17:28:22 +02:00