Commit graph

1732 commits

Author SHA1 Message Date
Oliver Gugger
b35dae72a5
channeldb: add NextHeight, fix formatting 2024-10-11 14:16:36 +02:00
Jonathan Harvey-Buschel
9c80088abd
lnwallet: sort sig jobs before submission
To make sure we attempt to read the results of the sig batches in the
same order they're processed, we sort them _before_ submitting them to
the batch processor.
Otherwise it might happen that we try to read on a result channel that
was never sent on because we aborted due to an error.
We also use slices.SortFunc now which doesn't use reflection and might
be slightly faster.
2024-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
69155bc60b
multi: 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-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
b83783cc3d
lnwallet: add WithAuxSigner option to channel 2024-10-11 14:16:35 +02:00
Oliver Gugger
6d3f8af007
lnwallet: clarify usage of cancel and response channels 2024-10-11 14:16:35 +02:00
Oliver Gugger
266aba8a6c
lnwallet: allow read-only access to HtlcView's HTLCs
Due to a recent refactor, the HTLCs are no longer an exported type.
Custom channels need access to those updates, so we provide them in a
read-only manner.
2024-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
6dda51d026
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-10-11 14:16:35 +02:00
Olaoluwa Osuntokun
1402f087ab
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-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
f2dff16c37
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-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
39b1080166
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-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
0a7139c9ca
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-10-11 14:16:34 +02:00
Olaoluwa Osuntokun
5f5bbf9ae2
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-10-11 14:16:33 +02:00
Olaoluwa Osuntokun
f73f5f5582
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-10-11 14:16:33 +02:00
Keagan McClelland
56866448dc
lnwallet: remove unnecessary chanID argument form unsignedLocalUpdates 2024-10-11 14:15:16 +02:00
Keagan McClelland
f8979c0614
htlcswitch+lnwallet: quarantine paymentDescriptor to lnwallet
The objective of this commit is to make paymentDescriptor a private
data structure so we can quarantine it to the lnwallet package.
To accomplish this we had to prevent it from leaking out via the
arguments or return values of the public functions in lnwallet.
This naturally had consequences for the htlcswitch package as we
choose other mechanisms for tracking the data that paymentDescriptor
was responsible for.

Astoundingly, this was highly successful and allowed us to remove
a ton of redundant code. The diff for this commit represents a
substantial reduction in total lines of code as well as extraneous
arguments and return values from key functions.

This also sets the stage for future commits where we actually will
be attempting to rid lnwallet of paymentDescriptor completely.
2024-10-11 14:15:14 +02:00
Keagan McClelland
7e5f6b5802
lnwallet: remove unused function PayDescsFromRemoteLogUpdates
This function is no longer used as of the last commit and it is the
last remaining leak of the PaymentDescriptor type through the public
API.
2024-10-11 14:14:41 +02:00
Keagan McClelland
870800b81a
htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns
This is part of a systematic removal of PaymentDescriptor from the public
API of the lnwallet package. This marks the last change needed before we
make the PaymentDescriptor structure private.
2024-10-11 14:14:41 +02:00
Keagan McClelland
d364b9b9f8
lnwallet: add function to convert paymentDescriptor to LogUpdate
Here we add a function that is capable of recovering LogUpdates from
paymentDescriptors and we refactor the lnwallet code to use this
rather than doing JIT inline construction of the LogUpdates.
2024-10-11 14:14:40 +02:00
Keagan McClelland
fb841b6436
htlcswitch+lnwallet: fix OnionBlob to 1366 bytes 2024-10-11 14:14:39 +02:00
Keagan McClelland
391370de20
lnwallet: track ChannelID on PaymentDescriptor
In this commit we track the ChannelID on the PaymentDescriptor.
This will be useful in upcoming commits that need to be able to
reconstruct lnwire.Message values from PaymentDescriptors as the
Messages that are exchanged to update channel state all include
the ChannelID.
2024-10-11 14:14:39 +02:00
Keagan McClelland
a40d363936
lnwallet: add ChannelID method to LightningChannel
In this commit we introduce a convenience method to LightningChannel
to allow us to quickly grab the channel id. This will be important
in upcoming commits where we need to remember the ChannelID to
reconstruct update messages.
2024-10-11 14:14:39 +02:00
George Tsagkarelis
c70832a823
lnwallet: expose commitment blob from channel 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
Oliver Gugger
b5efc0ef3e
lnwallet: extract diskCommit, remove unused error return value 2024-10-11 14:13:47 +02:00
Keagan McClelland
d4a4233e96
lnwallet+htlcswitch: define expanded NumPendingUpdates
This commit squashes the below operations for a net result where
we have an expanded capability of assessing pending updates. This
is made possible by packing the components into Duals in the prior
commits. We squash the operations to simplify review.

htlcswitch+lnwallet: rename PendingLocalUpdateCount

lnwallet: complete pending update queries API for LightningChannel

lnwallet+htlcswitch: consolidate NumPendingUpdates using ChannelParty

This commit makes the observation that we can cleanly define the
NumPendingUpdates function using a single expression by taking
advantage of the relevant fields being properly packed into Duals.
2024-10-11 14:12:54 +02:00
Keagan McClelland
b337213fb2
lnwallet: pack commitment message indices into Dual
This is yet another commit that packs a symmetric structure into
a Dual. This is the last one needed for the time being to consolidate
Num{X}UpdatesPendingOn{Y} functions into a single one.
2024-10-11 14:12:53 +02:00
Keagan McClelland
214dac0c45
lnwallet: pack update logs into Dual
This commit, like the last one packs the update logs into a symmetric
Dual structure. This will allow us to index into them more concisely
in higher order logic.
2024-10-11 14:12:52 +02:00
Keagan McClelland
61383f1014
lnwallet: pack commit chains into Dual
This commit packs the LightningChannel's localCommitmentChain and
remoteCommitmentChain into a Dual structure for better symmetric
access. This will be leveraged by an upcoming commit where we want
to more concisely express how we compute the number of pending
updates.
2024-10-11 14:12:28 +02:00
Oliver Gugger
b0728647c9
lnwallet: thread thru input.AuxTapleaf to all relevant areas
In this commit, we start to thread thru the new aux tap leaf structures to all relevant areas. This includes: commitment outputs, resolution creation, breach handling, and also HTLC scripts.
2024-10-11 14:11:58 +02:00
Oliver Gugger
860cacb70a
lnwallet: refactor commit keys to use lntypes.Dual 2024-10-11 14:11:58 +02:00
Oliver Gugger
b1c8a836e3
multi: thread thru the AuxLeafStore everywhere 2024-10-11 14:11:58 +02:00
Olaoluwa Osuntokun
eb600a9447
channeldb: add custom blobs to RevocationLog+HTLCEntry
This'll be useful for custom channel types that want to store extra information that'll be useful to help handle channel revocation cases.
2024-10-11 14:11:58 +02:00
Olaoluwa Osuntokun
1f785e897e
channeldb: convert RevocationLog to use RecordT 2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
314a24689c
channeldb: convert HTLCEntry to use tlv.RecordT 2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
12ab2c3b51
lnwallet: add TLV blob to PaymentDescriptor + htlc add
In this commit, we add a TLV blob to the PaymentDescriptor struct. We also now thread through this value from the UpdateAddHTLC message to the PaymentDescriptor mapping, and the other way around.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
ef56d8654e
lnwallet+channeldb: add new AuxLeafStore for dynamic aux leaves
In this commit, we add a new AuxLeafStore which can be used to dynamically fetch the latest aux leaves for a given state. This is useful for custom channel types that will store some extra information in the form of a custom blob, then will use that information to derive the new leaf tapscript leaves that may be attached to reach state.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
ae1b121cdd
lnwallet: add custom tlv blob to internal commitment struct
In this commit, we also add the custom TLV blob to the internal commitment struct that we use within the in-memory commitment linked list.

This'll be useful to ensure that we're tracking the current blob for our in memory commitment for when we need to write it to disk.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
da9ceb131b
lnwallet: export the HtlcView struct
We'll need this later on to ensure we can always interact with the new aux blobs at all stages of commitment transaction construction.
2024-10-11 14:11:57 +02:00
Olaoluwa Osuntokun
41bd293f33
input+lnwallet: update taproot scripts to accept optional aux leaf
In this commit, we update all the taproot scripts to also accept an
optional aux leaf. This aux leaf can be used to add more redemption
paths for advanced channels, or just as an extra commitment space.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
ca5dcbbf5c
lnwallet: add initial unit tests for musig2+tapscript root chans 2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
cae4f21897
lnwallet+peer: add tapscript root awareness to musig2 sessions
With this commit, the channel is now aware of if it's a musig2 channel, that also has a tapscript root. We'll need to always pass in the tapscript root each time we: make the funding output, sign a new state, and also verify a new state.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
62713c1270
lnwallet: update internal funding flow w/ tapscript root
This isn't hooked up yet to the funding manager, but with this commit, we can now start to write internal unit tests that handle musig2 channels with a tapscript root.
2024-10-11 14:11:56 +02:00
Olaoluwa Osuntokun
9fd8287c7b
lnwallet/chanfunding: add optional tapscript root 2024-10-11 14:11:55 +02:00
Olaoluwa Osuntokun
1e71b1e544
multi: add new tapscript root option to GenTaprootFundingScript
This'll allow us to create a funding output that uses musig2, but uses a tapscript tweak rather than a normal BIP 86 tweak.
2024-10-11 14:11:55 +02:00
Oliver Gugger
4fd1abfe52
lnwallet: add Tree() method, fix formatting 2024-10-11 14:04:00 +02:00
Oliver Gugger
89f75e7d1b
lnwallet: export GenTaprootHtlcScript 2024-10-11 14:04:00 +02:00
Oliver Gugger
29f139225b
lnwallet: export AnchorSize 2024-10-11 14:04:00 +02:00
Olaoluwa Osuntokun
213618adcc
lnwallet/chanfunding: rename assembler.go to interface.go
In this commit, we rename the files as assembler.go houses the primary
interfaces/abstractions of the package. In the rest of the codebase,
this file is near uniformly called interface.go, so we rename the file
to make the repo more digestible at a scan.
2024-10-11 14:03:59 +02:00
Oliver Gugger
03493d491b
multi: update linter, fix new issues 2024-10-11 14:02:30 +02:00
Olaoluwa Osuntokun
2341019016 lnwallet: expand chan sync tests to cover taproot channels
In this commit, we expand some of the existing chan sync tests to cover
taproot channels (the others already did). Along the way, we always
assert that the `PartialSig` is populated on retransmission. In
addition, we now send the new commit sig rather than the existing
in-memory one to test the new logic that re-signs the commitment.
2024-09-06 12:59:32 -07:00