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.
This commit is contained in:
1 parent
142b408be7
commit
c8b7987a39
2 files changed
+13
-3
No files matched your search
@@ -415,6 +415,10 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||||||
chanType |= channeldb.ScidAliasFeatureBit
|
chanType |= channeldb.ScidAliasFeatureBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.TapscriptRoot.IsSome() {
|
||||||
|
chanType |= channeldb.TapscriptRootBit
|
||||||
|
}
|
||||||
|
|
||||||
return &ChannelReservation{
|
return &ChannelReservation{
|
||||||
ourContribution: &ChannelContribution{
|
ourContribution: &ChannelContribution{
|
||||||
FundingAmount: ourBalance.ToSatoshis(),
|
FundingAmount: ourBalance.ToSatoshis(),
|
||||||
@@ -448,6 +452,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||||||
InitialLocalBalance: ourBalance,
|
InitialLocalBalance: ourBalance,
|
||||||
InitialRemoteBalance: theirBalance,
|
InitialRemoteBalance: theirBalance,
|
||||||
Memo: req.Memo,
|
Memo: req.Memo,
|
||||||
|
TapscriptRoot: req.TapscriptRoot,
|
||||||
},
|
},
|
||||||
pushMSat: req.PushMSat,
|
pushMSat: req.PushMSat,
|
||||||
pendingChanID: req.PendingChanID,
|
pendingChanID: req.PendingChanID,
|
||||||
|
|||||||
+8
-3
@@ -211,6 +211,11 @@ type InitFundingReserveMsg struct {
|
|||||||
// channel that will be useful to our future selves.
|
// channel that will be useful to our future selves.
|
||||||
Memo []byte
|
Memo []byte
|
||||||
|
|
||||||
|
// TapscriptRoot is the root of the tapscript tree that will be used to
|
||||||
|
// create the funding output. This is an optional field that should
|
||||||
|
// only be set for taproot channels.
|
||||||
|
TapscriptRoot fn.Option[chainhash.Hash]
|
||||||
|
|
||||||
// err is a channel in which all errors will be sent across. Will be
|
// err is a channel in which all errors will be sent across. Will be
|
||||||
// nil if this initial set is successful.
|
// nil if this initial set is successful.
|
||||||
//
|
//
|
||||||
@@ -2103,7 +2108,7 @@ func (l *LightningWallet) verifyCommitSig(res *ChannelReservation,
|
|||||||
if res.musigSessions == nil {
|
if res.musigSessions == nil {
|
||||||
_, fundingOutput, err := input.GenTaprootFundingScript(
|
_, fundingOutput, err := input.GenTaprootFundingScript(
|
||||||
localKey, remoteKey, channelValue,
|
localKey, remoteKey, channelValue,
|
||||||
fn.None[chainhash.Hash](),
|
res.partialState.TapscriptRoot,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -2346,7 +2351,7 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
|||||||
//nolint:lll
|
//nolint:lll
|
||||||
fundingWitnessScript, fundingTxOut, err = input.GenTaprootFundingScript(
|
fundingWitnessScript, fundingTxOut, err = input.GenTaprootFundingScript(
|
||||||
ourKey.PubKey, theirKey.PubKey, channelValue,
|
ourKey.PubKey, theirKey.PubKey, channelValue,
|
||||||
fn.None[chainhash.Hash](),
|
pendingReservation.partialState.TapscriptRoot,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
@@ -2487,7 +2492,7 @@ func (l *LightningWallet) ValidateChannel(channelState *channeldb.OpenChannel,
|
|||||||
if channelState.ChanType.IsTaproot() {
|
if channelState.ChanType.IsTaproot() {
|
||||||
fundingScript, _, err = input.GenTaprootFundingScript(
|
fundingScript, _, err = input.GenTaprootFundingScript(
|
||||||
localKey, remoteKey, int64(channel.Capacity),
|
localKey, remoteKey, int64(channel.Capacity),
|
||||||
fn.None[chainhash.Hash](),
|
channelState.TapscriptRoot,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user