Commit Graph

15271 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
5f1e0bf772
multi: add new SCB version for the taproot chan type 2023-08-22 16:34:34 -07:00
Olaoluwa Osuntokun
94f45b2b82
itest: use explicit chan type negotiation for taproot chan cases
The prior commit removed implicit negotiation, so we'll need to make
sure to use the explicit chan type feature vector when we go to
negotiate.
2023-08-22 16:34:31 -07:00
Olaoluwa Osuntokun
384b1b1c12
feature: use +100 staging bit for taproot channels
In this commit, we carry out a new notion introduced during a recent
spec meeting to use a feature bit plus 100 before the feature has been
finalized in the spec.

We split into the Final and Staging bits.
2023-08-22 16:34:28 -07:00
Olaoluwa Osuntokun
fcbf6f2483
lnwallet: add taproot case to TestForceClose
This adds some extra assertions to ensure things like the taproot
commitment weight estimation is correct.
2023-08-22 16:34:25 -07:00
Olaoluwa Osuntokun
ff055ce0a4
lnwallet: uniformly use sighash default everywhere for taproot chans
We use a helper function to ensure that anytime we're about to make a
normal sighash, we consult the channel type to check if we should use
the default value or sighash all explicitly.
2023-08-22 16:34:23 -07:00
Olaoluwa Osuntokun
dd05dd55d4
funding: add explicit chan type support for zeroconf+scid+taproot
We also remove the old implicit negotiation as well, as we'll be
updating tests to use explciit when required.
2023-08-22 16:34:20 -07:00
Olaoluwa Osuntokun
4b65c71213
lnwallet: for musig2 coop close fee estimation
Co-op close for musig2 chans needs to use the proper witness size.
2023-08-22 16:34:17 -07:00
Olaoluwa Osuntokun
a2b277cf1d
multi: fix linter errors 2023-08-22 16:34:15 -07:00
Olaoluwa Osuntokun
d3e4bca772
itest: add taproot support to revocation itests 2023-08-22 16:34:12 -07:00
Olaoluwa Osuntokun
7c5be4d056
itest: add taproot support for all variants of runMultiHopHtlcClaimTest 2023-08-22 16:34:06 -07:00
Olaoluwa Osuntokun
5739061f13
lnwallet: add first+second level taptweaks to htlc retribution
The first and second level taptweaks need to be stored in order to
ensure the breach arb can play revocations at both the first and second
level.
2023-08-22 16:34:04 -07:00
Olaoluwa Osuntokun
28c086f1fc
htlcswitch: remove call to InitRemoteMusigNonces
In this commit, we remove the internal call to `InitRemoteMusigNonces`.
We don't need this since when we go to process the remote party's chan
reest message, we'll already call this method. Otherwise, we'll get an
error here since the pending verification nonce has been wiped out after
each call.
2023-08-22 16:34:02 -07:00
Olaoluwa Osuntokun
5379823346
itest: add taproot chans to testChannelForceClosure 2023-08-22 16:34:00 -07:00
Olaoluwa Osuntokun
82a5addd3d
lnwallet: add error logging to getSignedCommitTx 2023-08-22 16:33:58 -07:00
Olaoluwa Osuntokun
da3ab2728b
itest: add taproot chan support to basic channel funding
We keep in line with the existing test that uses implicit negotiation.
In the future, we should modify to also have explicit negotiation as
well.
2023-08-22 16:33:56 -07:00
Olaoluwa Osuntokun
2b952af629
feature+lncfg: restore simple- prefix for taproot chans arg 2023-08-22 16:33:54 -07:00
Olaoluwa Osuntokun
d98136e850
funding: add support for implicit negotiation for taproot chans
Otherwise, in the itests (which are mainly based on implicit
negotiation), we won't try to open taproot chans when we actually need
to.

We may want to revisit this however, since it may lock in parties trying
to use the defaults that aren't currently setting the explicit commit
type during funding.
2023-08-22 16:33:52 -07:00
Olaoluwa Osuntokun
bed9455d60
lnwallet: fix taproot co-op close nonce bug
The local nonce needs to be the one that's finalized to simulate us
receiving the remote nonce, then generating the local nonce in a JIT
style.
2023-08-22 16:33:50 -07:00
Olaoluwa Osuntokun
93e8428b6b
lnwallet: for taproot channels allow the co-op close tx to be RBF'd
This is a preparatory change for the upcoming "simple channel close"
feature which'll utilize RBF to allow either side to resign the co-op
close transaction for broadcast at any point.
2023-08-22 16:33:48 -07:00
Olaoluwa Osuntokun
4b0139c9ba
lnwallet: update channel state machine to use new ScriptDescriptor interface
In this commit, we update the channel state machine to use the new
ScriptDescriptor interface. This fixes some subtle issues with the
existing commits, as for p2wsh we always sign the same witness script,
but for p2tr, the witness script differs depending on which branch is
taken.

With the new abstractions, we can treat p2wsh and p2tr as the same
mostly, right up until we need to obtain a control block or a tap tweak.

All tests have been updated accordingly.
2023-08-22 16:33:46 -07:00
Olaoluwa Osuntokun
a244a30f32
input: create new ScriptDesciptor interface
In this commit, we add a new interface, the `ScriptDesciptor` to
abstract over details of a given output script. The purpose of this
interface, and the taproot superset, is to be able to paper over the
differences of a p2wsh vs a p2tr output. With this new interface, we can
treat them as the same, but then use a type assertion to get at any
control block related methods if needed.
2023-08-22 16:33:44 -07:00
Olaoluwa Osuntokun
7e2d04a310
contractcourt: update UTXO nursery to support taproot chans 2023-08-22 16:33:42 -07:00
Olaoluwa Osuntokun
cdcde6e0a5
contractcourt: update breach arbiter to support taproot chans
In this commit, we update the breach arb to support taproot channels. We
utilize the new taproot briefcase space to store both control blocks,
and also the first+second level scripts for the set of HTLCs.
2023-08-22 16:33:40 -07:00
Olaoluwa Osuntokun
df2a2d83ea
contractcourt: update htlcSuccessResolver for taproot chans 2023-08-22 16:33:38 -07:00
Olaoluwa Osuntokun
23f7ee39c7
contractcourt: update htlcTimeoutResolver for taproot chans 2023-08-22 16:33:36 -07:00
Olaoluwa Osuntokun
47f70dae3a
contractcourt: update commitSweepResolver for taproot chans 2023-08-22 16:33:34 -07:00
Olaoluwa Osuntokun
2010239b63
contractcourt: update the anchor resolver for taproot chans 2023-08-22 16:33:32 -07:00
Olaoluwa Osuntokun
47d4eb341d
contractcourt: store new taproot resolution info in new key
We pull the information from the sign descriptors and store them in the
resolutions. However, the resolvers created end up duplicating the
resolution data, so we update the sign descs as needed during start up.
2023-08-22 16:33:30 -07:00
Olaoluwa Osuntokun
a1788fe4a2
contractcourt: add new taproot briefcase to store ctrl block and tap tweaks
In this commit, we add a new taproot specific briefcase to store the
control block and tap tweaks for all taproot outputs. We chose this
route as many of the existing fields are serialized in line, so we
aren't able to serialize this new taproot specific information in the
existing briefcase.
2023-08-22 16:33:27 -07:00
Olaoluwa Osuntokun
fa07a2d248
input: HtlcSucceedInput to support sweeping for taproot chans 2023-08-22 16:33:25 -07:00
Olaoluwa Osuntokun
b00cf25590
input: add new HtlcSecondLevelAnchorInput types for taproot chans 2023-08-22 16:33:22 -07:00
Olaoluwa Osuntokun
2b92c15ca9
input: update the mock signer for the musig2 API changes 2023-08-22 16:33:19 -07:00
Olaoluwa Osuntokun
b39f5884ad
input: update IsHtlcSpendRevoke for taproot chans
For taproot channels, the revocation witness is a single sig as the
keyspend path is used.
2023-08-22 16:33:17 -07:00
Olaoluwa Osuntokun
995e6cd66b
lnwallet: update NewBreachRetribution to handle taproot chans
For our local output, we need a valid control block. To sweep the remote
output, we use the taptweak so we can spend the keyspend path.
2023-08-22 16:33:14 -07:00
Olaoluwa Osuntokun
1f887a1b14
lnwallet: add support for taproot chans to createHtlcRetribution
As these are revoked HTLCs, we need to set the taptweak since the
revocation case is just a keyspend.
2023-08-22 16:33:12 -07:00
Olaoluwa Osuntokun
52b122a8bb
lnwallet: NewUnilateralCloseSummary for local taproot output sweep 2023-08-22 16:33:09 -07:00
Olaoluwa Osuntokun
b72f368673
lnwallet: update NewLocalForceCloseSummary for local taproot output sweep 2023-08-22 16:33:07 -07:00
Olaoluwa Osuntokun
ad5305b99c
lnwallet: update newIncomingHtlcResolution for taproot chans
Similar to the outgoing resolutions, the main change here is ensuring
the sign method and control block are properly set for the various spend
types.
2023-08-22 16:33:04 -07:00
Olaoluwa Osuntokun
a0a3c7aa89
lnwallet: update newOutgoingHtlcResolution for taproot chans
For taproot channels, we need to thread through the control block in the
sign descriptor. We also ensure that the proper sign method is set. We
leverage the new input.Signature generalization be able to support
handling both schnorr and ECDSA signatures for the second level output.
2023-08-22 16:33:01 -07:00
Olaoluwa Osuntokun
ee59e3f181
lnwallet: update NewAnchorResolution to support taproot anchors 2023-08-22 16:32:59 -07:00
Olaoluwa Osuntokun
a128b74dc1
lnwallet: add tapscript tree to ScriptInfo
In this commit, we add the tapscript tree to the ScriptInfo struct, as
in many cases the caller needs the tree in order to generate the control
block or obtain the taptweak which is needed to spend revoked outputs.
2023-08-22 16:32:56 -07:00
Olaoluwa Osuntokun
a74c30fbdd
lnwallet: update HtlcSuccessFee + HtlcTimeoutFee for taproot chans
There's no fee, as taproot channels are always zero fee HTLC.
2023-08-22 16:32:54 -07:00
Olaoluwa Osuntokun
ebc61818a3
lnwallet: update CommitWeight to return taproot commit weight 2023-08-22 16:32:51 -07:00
Olaoluwa Osuntokun
8d0435397d
input: add new SecondLevelScriptTree to support second level HTLC spends 2023-08-22 16:32:48 -07:00
Olaoluwa Osuntokun
4c7da7df49
input: update all taproot script spends to optionally make the ctrl block
In this commit, we update all the taproot scripts spends to optionally
make the control block. This is useful in cases where we've already
created the control block, or may not have the items needed to construct
it in the first place.

We also add the control block to the sign descriptor itself.
2023-08-22 16:32:46 -07:00
Olaoluwa Osuntokun
405a435a84
input: add weight estimation + tests for all taproot witness gen types 2023-08-22 16:32:44 -07:00
Olaoluwa Osuntokun
d3c7c51f7e
input: add new witness gen types for all taproot spends 2023-08-22 16:32:42 -07:00
Olaoluwa Osuntokun
0d3bed66c0
lnwallet: properly set witness script in CommitScriptToSelf 2023-08-22 16:32:40 -07:00
Olaoluwa Osuntokun
a5f67b451e
input: add new ParseSignature helper func 2023-08-22 16:32:37 -07:00
Olaoluwa Osuntokun
7323e9373b
feature+lncfg: add new CLI flag to opt into taproot chans 2023-08-22 16:32:35 -07:00