mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 06:47:44 +01:00
lnwallet: add awareness of taproot overlay chan type to reservations
This commit is contained in:
parent
745f3a6181
commit
4efa39ddb1
2 changed files with 29 additions and 6 deletions
|
@ -2,6 +2,7 @@ package lnwallet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -50,6 +51,11 @@ const (
|
||||||
// channels that use a musig2 funding output and the tapscript tree
|
// channels that use a musig2 funding output and the tapscript tree
|
||||||
// where relevant for the commitment transaction pk scripts.
|
// where relevant for the commitment transaction pk scripts.
|
||||||
CommitmentTypeSimpleTaproot
|
CommitmentTypeSimpleTaproot
|
||||||
|
|
||||||
|
// CommitmentTypeSimpleTaprootOverlay builds on the existing
|
||||||
|
// CommitmentTypeSimpleTaproot type but layers on a special overlay
|
||||||
|
// protocol.
|
||||||
|
CommitmentTypeSimpleTaprootOverlay
|
||||||
)
|
)
|
||||||
|
|
||||||
// HasStaticRemoteKey returns whether the commitment type supports remote
|
// HasStaticRemoteKey returns whether the commitment type supports remote
|
||||||
|
@ -59,8 +65,11 @@ func (c CommitmentType) HasStaticRemoteKey() bool {
|
||||||
case CommitmentTypeTweakless,
|
case CommitmentTypeTweakless,
|
||||||
CommitmentTypeAnchorsZeroFeeHtlcTx,
|
CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
CommitmentTypeScriptEnforcedLease,
|
CommitmentTypeScriptEnforcedLease,
|
||||||
CommitmentTypeSimpleTaproot:
|
CommitmentTypeSimpleTaproot,
|
||||||
|
CommitmentTypeSimpleTaprootOverlay:
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -71,8 +80,11 @@ func (c CommitmentType) HasAnchors() bool {
|
||||||
switch c {
|
switch c {
|
||||||
case CommitmentTypeAnchorsZeroFeeHtlcTx,
|
case CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
CommitmentTypeScriptEnforcedLease,
|
CommitmentTypeScriptEnforcedLease,
|
||||||
CommitmentTypeSimpleTaproot:
|
CommitmentTypeSimpleTaproot,
|
||||||
|
CommitmentTypeSimpleTaprootOverlay:
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -80,7 +92,8 @@ func (c CommitmentType) HasAnchors() bool {
|
||||||
|
|
||||||
// IsTaproot returns true if the channel type is a taproot channel.
|
// IsTaproot returns true if the channel type is a taproot channel.
|
||||||
func (c CommitmentType) IsTaproot() bool {
|
func (c CommitmentType) IsTaproot() bool {
|
||||||
return c == CommitmentTypeSimpleTaproot
|
return c == CommitmentTypeSimpleTaproot ||
|
||||||
|
c == CommitmentTypeSimpleTaprootOverlay
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the name of the CommitmentType.
|
// String returns the name of the CommitmentType.
|
||||||
|
@ -96,6 +109,8 @@ func (c CommitmentType) String() string {
|
||||||
return "script-enforced-lease"
|
return "script-enforced-lease"
|
||||||
case CommitmentTypeSimpleTaproot:
|
case CommitmentTypeSimpleTaproot:
|
||||||
return "simple-taproot"
|
return "simple-taproot"
|
||||||
|
case CommitmentTypeSimpleTaprootOverlay:
|
||||||
|
return "simple-taproot-overlay"
|
||||||
default:
|
default:
|
||||||
return "invalid"
|
return "invalid"
|
||||||
}
|
}
|
||||||
|
@ -424,7 +439,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
||||||
chanType |= channeldb.FrozenBit
|
chanType |= channeldb.FrozenBit
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.CommitType == CommitmentTypeSimpleTaproot {
|
if req.CommitType.IsTaproot() {
|
||||||
chanType |= channeldb.SimpleTaprootFeatureBit
|
chanType |= channeldb.SimpleTaprootFeatureBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +455,15 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
||||||
chanType |= channeldb.ScidAliasFeatureBit
|
chanType |= channeldb.ScidAliasFeatureBit
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.TapscriptRoot.IsSome() {
|
taprootOverlay := req.CommitType == CommitmentTypeSimpleTaprootOverlay
|
||||||
|
switch {
|
||||||
|
case taprootOverlay && req.TapscriptRoot.IsNone():
|
||||||
|
fallthrough
|
||||||
|
case !taprootOverlay && req.TapscriptRoot.IsSome():
|
||||||
|
return nil, fmt.Errorf("taproot overlay chans must be set " +
|
||||||
|
"with tapscript root")
|
||||||
|
|
||||||
|
case taprootOverlay && req.TapscriptRoot.IsSome():
|
||||||
chanType |= channeldb.TapscriptRootBit
|
chanType |= channeldb.TapscriptRootBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -983,7 +983,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *InitFundingReserveMsg
|
||||||
TaprootPubkey, true, DefaultAccountName,
|
TaprootPubkey, true, DefaultAccountName,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
Musig2: req.CommitType == CommitmentTypeSimpleTaproot,
|
Musig2: req.CommitType.IsTaproot(),
|
||||||
}
|
}
|
||||||
fundingIntent, err = req.ChanFunder.ProvisionChannel(
|
fundingIntent, err = req.ChanFunder.ProvisionChannel(
|
||||||
fundingReq,
|
fundingReq,
|
||||||
|
|
Loading…
Add table
Reference in a new issue