1716 Commits

Author SHA1 Message Date
Jonathan Harvey-Buschel
a680224c02
lnwallet: test link quit signal handling 2024-10-15 17:05:45 -04:00
Jonathan Harvey-Buschel
62ffe6ca56
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-15 17:04:40 -04:00
Oliver Gugger
fe46353392
lnwallet: clarify usage of cancel and response channels 2024-09-30 15:40:33 -04:00
Jonathan Harvey-Buschel
36faab3553
lnwallet: sort sig jobs before submission 2024-09-30 15:40:33 -04:00
Jonathan Harvey-Buschel
aa435034bf
lnwallet: test aux signer shutdown handling 2024-09-30 15:40:32 -04:00
Jonathan Harvey-Buschel
43ab85b874
lnwallet: refactor test code for HTLC add and recv 2024-09-30 15:28:39 -04:00
Jonathan Harvey-Buschel
1cd4fdc859
lnwallet: allow mock aux signer to fail sig jobs 2024-09-30 13:09:46 -04:00
George Tsagkarelis
70338e3cf3
lnwallet: fix panic on aux sig handling 2024-09-19 11:12:29 +02:00
Olaoluwa Osuntokun
505843213a
lnwallet: add new TestChanSyncOweCommitmentAuxSigner test
This test ensures that when we go to retransmit a signature, we also include the set of CustomRecords.
2024-09-12 17:54:39 -07:00
Olaoluwa Osuntokun
f41dd862d0
htlcswitch+lnwallet: use CustomRecords for aux sig blobs
In this commit, we start to use the set of CustomRecords instead of ExtraData for the aux sig blobs.
2024-09-12 17:54:37 -07:00
Olaoluwa Osuntokun
819de82262
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-12 17:54:32 -07:00
Olaoluwa Osuntokun
f5b57e8d08
lnwallet: extract initMusigNonce from initRevocationWindows
This'll be useful later to make some enhancements to the existing unit tests.
2024-09-12 17:54:32 -07:00
Olaoluwa Osuntokun
f03a6d5a0b
lnwallet: ensure we re-sign retransmitted commits for taproot channels
In this commit, we fix an existing bug with the taproot channel type that can cause force closes if a peer disconnects while attempting to send the commitment signature.

Before this commit, since the `PartialSig` we send is never committed to disk, the version read wouldn't contain the musig2 partial sig. We never write these signatures to disk, as each time we make a new session, we need to generate fresh nonces to avoid nonce-reuse.

Due to the above interaction, if we went to re-send a signature after a disconnection, the `CommitSig` message we sent wouldn't actualy contain a `PartialSigWithNonce`, causing a protocol error.
2024-09-12 17:54:31 -07:00
Olaoluwa Osuntokun
aed568b6ed
lnwallet: properly set aux HTLC blob on retransmission
Before this commit, we weren't properly setting the aux HTLC blob when
we went to retransmit a signature. We fix this by setting the
`ExtraData` field as expected in the `CommitSig` message.
2024-09-12 17:54:30 -07:00
Olaoluwa Osuntokun
6a8da1cd80
lnwallet: store aux sig in custom data within the HTLC
We can use this space as we'll properly encode the blinded paths data
along with our custom fields before we go to write the HTLCs to the
wire.
2024-07-22 19:41:01 -07:00
Olaoluwa Osuntokun
c7011a6a5c
lnwallet: add short chan ID to AuxShutdownReq
This allows implementations to obtain information related where the
funding transaction confirmed in the mainchain.
2024-07-02 11:30:19 -07:00
Olaoluwa Osuntokun
a222878a0d
lnwallet: add awareness of taproot overlay chan type to reservations 2024-06-26 18:12:58 -07:00
Olaoluwa Osuntokun
64cf872846
lnwallet: fix bugs in ResolutionReq for breach handling
In this commit, we fix three existing bugs in the way we make
`ResolutionReq` for breach handling:

  1. We were passing in the commit blob of the *current* channel state,
     instead of the one stored in the revocation log for this breached
     state.

  2. We were using theirDelay for CsvDelay, when we want ourDelay, which
     in this case will be 1 CSV, as this is a non delayed output.

  3. We also need to pass in the delay for the remote party's to_local
     delayed output.
2024-06-25 10:53:23 +02:00
Oliver Gugger
09af0cc64c
lnwallet: fix local/remote aux leaf, add local resolution blob 2024-06-25 10:52:29 +02:00
Olaoluwa Osuntokun
c2927d8212
lnwallet: split ResolutionBlob into local vs remote for breach
When we're handling a breach, we'll be sweeping from both the local and
remote outputs, so we'll carve out two blob areas for that.
2024-06-25 10:46:38 +02:00
Olaoluwa Osuntokun
739f82e43a lnwallet: pass tap leaf through in NewLocalForceCloseSummary
Before this commit, the leaf wasn't yet passed in on force close. This
is needed to detect the force close outputs properly.
2024-06-21 15:20:00 -07:00
Olaoluwa Osuntokun
bf9dab6242 multi: hook up new aux interfaces 2024-06-21 15:20:00 -07:00
Olaoluwa Osuntokun
1c92c79f15 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-06-21 15:20:00 -07:00
Olaoluwa Osuntokun
70d53a83c0 lnwallet+peer: move internalKeyForAddr to lnwallet package
This way we can re-use it. We also make it slightly more generalized.
2024-06-21 13:18:16 -07:00
Olaoluwa Osuntokun
5a5669d63a 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-06-21 13:18:16 -07:00
Oliver Gugger
d6e1d19fa1
chancloser: always set close output
We always need to set the close output in order for us to be able
to calculate the closing keys. Especially if there is only a dust
balance in BTC terms but perhaps a valuable amount in custom channel
funds.
2024-06-07 16:07:55 +02:00
Olaoluwa Osuntokun
daa9226dae
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-06-04 16:06:04 +02:00
Olaoluwa Osuntokun
e7747442d3
lnwallet: modify CoopCloseBalance to not depend on chan commit 2024-06-03 11:33:36 +02:00
Olaoluwa Osuntokun
c76376594b
lnwallet/chancloser: add aux chan closer, use in coop flow 2024-06-03 11:33:36 +02:00
Olaoluwa Osuntokun
db373c5da9
lnwallet/chancloser: add new AuxChanCloser interface 2024-06-03 11:33:35 +02:00
Olaoluwa Osuntokun
a7c8595d2b
lnwallet: add ability to do custom sort for coop close txn 2024-06-03 11:33:35 +02:00
Olaoluwa Osuntokun
7ee24fcb13
lnwallet: add ability to add extra co-op close outputs 2024-06-03 11:33:35 +02:00
Olaoluwa Osuntokun
73407be75d
lnwallet: add FundingBlob method to LightningChannel 2024-06-03 11:33:35 +02:00
Oliver Gugger
1f86f38f36
Merge remote-tracking branch 'origin/master' into 0-19-staging 2024-05-28 13:55:23 +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
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
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
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
yyforyongyu
17a089c899
input+lnwallet: apply the new type lntypes.VByte 2024-05-25 13:37:16 +08:00
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00