diff --git a/chanbackup/single.go b/chanbackup/single.go index dd63bf1f6..47a4b5054 100644 --- a/chanbackup/single.go +++ b/chanbackup/single.go @@ -52,6 +52,10 @@ const ( // SimpleTaprootVersion is a version that denotes this channel is using // the musig2 based taproot commitment format. SimpleTaprootVersion = 5 + + // TapscriptRootVersion is a version that denotes this is a MuSig2 + // channel with a top level tapscript commitment. + TapscriptRootVersion = 6 ) // Single is a static description of an existing channel that can be used for @@ -218,7 +222,11 @@ func NewSingle(channel *channeldb.OpenChannel, switch { case channel.ChanType.IsTaproot(): - single.Version = SimpleTaprootVersion + if channel.ChanType.HasTapscriptRoot() { + single.Version = TapscriptRootVersion + } else { + single.Version = SimpleTaprootVersion + } case channel.ChanType.HasLeaseExpiration(): single.Version = ScriptEnforcedLeaseVersion @@ -252,6 +260,7 @@ func (s *Single) Serialize(w io.Writer) error { case AnchorsZeroFeeHtlcTxCommitVersion: case ScriptEnforcedLeaseVersion: case SimpleTaprootVersion: + case TapscriptRootVersion: default: return fmt.Errorf("unable to serialize w/ unknown "+ "version: %v", s.Version) @@ -429,6 +438,7 @@ func (s *Single) Deserialize(r io.Reader) error { case AnchorsZeroFeeHtlcTxCommitVersion: case ScriptEnforcedLeaseVersion: case SimpleTaprootVersion: + case TapscriptRootVersion: default: return fmt.Errorf("unable to de-serialize w/ unknown "+ "version: %v", s.Version) diff --git a/chanbackup/single_test.go b/chanbackup/single_test.go index a2d44027b..68ce35c56 100644 --- a/chanbackup/single_test.go +++ b/chanbackup/single_test.go @@ -250,13 +250,20 @@ func TestSinglePackUnpack(t *testing.T) { valid: true, }, - // The new taproot channel lease version should + // The new taproot channel version should // pack/unpack with no problem. { version: SimpleTaprootVersion, valid: true, }, + // The new tapscript root channel version should pack/unpack + // with no problem. + { + version: TapscriptRootVersion, + valid: true, + }, + // A non-default version, atm this should result in a failure. { version: 99, diff --git a/chanrestore.go b/chanrestore.go index 27f6d6d9e..5b221c105 100644 --- a/chanrestore.go +++ b/chanrestore.go @@ -162,6 +162,13 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) ( chanType |= channeldb.SingleFunderTweaklessBit chanType |= channeldb.SimpleTaprootFeatureBit + case chanbackup.TapscriptRootVersion: + chanType = channeldb.ZeroHtlcTxFeeBit + chanType |= channeldb.AnchorOutputsBit + chanType |= channeldb.SingleFunderTweaklessBit + chanType |= channeldb.SimpleTaprootFeatureBit + chanType |= channeldb.TapscriptRootBit + default: return nil, fmt.Errorf("unknown Single version: %w", err) }