Commit graph

1758 commits

Author SHA1 Message Date
ziggie
79d0655a96
multi: introduce an option for resolutions
We don't always need the resolutions in the local force close
summary so we make it an option.
2024-11-20 10:42:54 +01:00
Olaoluwa Osuntokun
6db7d42654
lnwallet: add whoseCommit to FetchLeavesFromCommit
This is useful for additional context to know which commit the
AuxLeafStore is fetching the leaves for.
2024-11-15 13:09:10 +01:00
Olaoluwa Osuntokun
e3eef0adff
lnwallet: populate resolution blob for incoming+outgoing HTLC resolutions
In this commit, we populate the resolution blobs for the incoming and
outgoing HTLCs. We take care to populate the AuxSigDesc with the correct
information, as we need to pass along the second-level aux signature and
also sign desc along with it.
2024-11-15 13:09:09 +01:00
Olaoluwa Osuntokun
84aacc6c39
channel: add ResolutionBlob to Incoming+Outgoing HtlcResolution
Similar to the other blobs we have for the commitment output force close
resolution, these blobs will be used to ensure that we have everything
needed to sweep aux HTLCs.
2024-11-15 13:09:08 +01:00
Olaoluwa Osuntokun
57617dc4f7
channel: always specify ChanType in ResolutionReq 2024-11-15 13:09:08 +01:00
Olaoluwa Osuntokun
a5beb340e4
lnwallet: expand attributes in ResolutionReq
In this commit, we add some additional attributes to the ResolutionReq
struct. These will be used to make sure that we can properly handle all
the HTLC variants, on chain.

The `AuxSigDesc` will be used to communicate if an HTLC needs to go to
the second level or not. It contains the second-level sig information
needed to finalize a broadcast to the second level.
2024-11-15 13:09:07 +01:00
Boris Nagaev
552d182594
lnwallet: fix closechannel for P2TR external addr
If the delivery address is P2TR, function InternalKeyForAddr checks its
existance in the wallet to return internal key for it in case it is a custom
taproot channel. It used to return the error returned by wallet.AddressInfo.
The error is now ignored if it is ErrAddressNotFound error. This fixes
"lncli closechannel --delivery_addr <external p2tr address" case.
2024-10-30 14:16:36 +01:00
Jonathan Harvey-Buschel
455cdffede
lnwallet: test link quit signal handling 2024-10-22 09:06:17 +02:00
Jonathan Harvey-Buschel
8703153c44
multi: link quit can interrupt commitment signing
In this commit, we make sig job handling when singing a next commitment
non-blocking by allowing the shutdown of a channel link to prevent
further waiting on sig jobs by the channel state machine. This addresses
possible cases where the aux signer may be shut down via a separate quit
signal, so the state machine could block indefinitely on receiving an
update on a sig job.
2024-10-22 09:06:17 +02:00
Jonathan Harvey-Buschel
afb7532f17
lnwallet: sort sig jobs before submission 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
ed5d748a9f
lnwallet: test aux signer shutdown handling 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
b6363a8da4
lnwallet: refactor test code for HTLC add and recv 2024-10-22 09:05:42 +02:00
Jonathan Harvey-Buschel
afdd53194b
multi: allow mock aux signer to customize sig jobs 2024-10-22 09:05:41 +02:00
Oliver Gugger
57e7b41510
lnwallet: turn off RBF detection in test 2024-10-16 15:58:00 +02:00
Oliver Gugger
89c84f1da6
lnwallet: fix import issue 2024-10-11 14:46:09 +02:00
Olaoluwa Osuntokun
4efa39ddb1
lnwallet: add awareness of taproot overlay chan type to reservations 2024-10-11 14:22:12 +02:00
Olaoluwa Osuntokun
23e99ddd4d
sweep: add new AuxSweeper interface
In this commit, we add a new AuxSweeper interface. This'll take a set of
inputs, and a change addr for the sweep transaction, then optionally
return a new sweep output to be added to the sweep transaction.

We also add a new NotifyBroadcast method.  This'll be used to notify
that we're _about_ to broadcast a sweeping transaction. The set of
inputs is passed in, which allows the caller to prepare for the ultimate
broadcast of the sweeping transaction.

We also add ExtraTxOut to BumpRequest pass fees to NotifyBroadcast. This
allows the callee to know the total fee of the sweeping transaction.
2024-10-11 14:22:11 +02:00
Olaoluwa Osuntokun
07ee114116
lnwallet+peer: move internalKeyForAddr to lnwallet package
This way we can re-use it. We also make it slightly more generalized.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
f4710ca639
lnwallet: add new aux resolver interface
This will be used by external callers to modify the way we resolve
contracts on chain. For a given contract, we'll store an extra "blob",
that will later be presented during the sweeping phase.
2024-10-11 14:22:10 +02:00
Olaoluwa Osuntokun
39e4e8d8a4
peer: decorate delivery addr w/ internal key
In this commit, we move to add the internal key to the delivery addr. This way, we give the aux chan closer the extra information it may need to properly augment the normal co-op close process.
2024-10-11 14:17:28 +02:00
Olaoluwa Osuntokun
8b97d4f833
lnwallet: modify CoopCloseBalance to not depend on chan commit 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
e536cfad0f
lnwallet/chancloser: add aux chan closer, use in coop flow 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
e2dae56698
lnwallet/chancloser: add new AuxChanCloser interface 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
2d8c4fda2f
lnwallet: add ability to do custom sort for coop close txn 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
0cb211e14c
lnwallet: add ability to add extra co-op close outputs 2024-10-11 14:17:27 +02:00
Olaoluwa Osuntokun
7e4f6f5b4a
lnwallet: add FundingBlob method to LightningChannel 2024-10-11 14:17:27 +02:00
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