chanrestore: define ZeroHtlcTxFeeCommitVersion

This commit is contained in:
Johan T. Halseth 2020-12-07 14:21:29 +01:00
parent d5cd9861d2
commit 0b9bec7804
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 14 additions and 0 deletions

@ -36,6 +36,10 @@ const (
// implicitly denotes that this channel uses the new anchor commitment // implicitly denotes that this channel uses the new anchor commitment
// format. // format.
AnchorsCommitVersion = 2 AnchorsCommitVersion = 2
// AnchorsZeroFeeHtlcTxCommitVersion is a version that denotes this
// channel is using the zero-fee second-level anchor commitment format.
AnchorsZeroFeeHtlcTxCommitVersion = 3
) )
// Single is a static description of an existing channel that can be used for // Single is a static description of an existing channel that can be used for
@ -163,6 +167,9 @@ func NewSingle(channel *channeldb.OpenChannel,
} }
switch { switch {
case channel.ChanType.ZeroHtlcTxFee():
single.Version = AnchorsZeroFeeHtlcTxCommitVersion
case channel.ChanType.HasAnchors(): case channel.ChanType.HasAnchors():
single.Version = AnchorsCommitVersion single.Version = AnchorsCommitVersion
@ -185,6 +192,7 @@ func (s *Single) Serialize(w io.Writer) error {
case DefaultSingleVersion: case DefaultSingleVersion:
case TweaklessCommitVersion: case TweaklessCommitVersion:
case AnchorsCommitVersion: case AnchorsCommitVersion:
case AnchorsZeroFeeHtlcTxCommitVersion:
default: default:
return fmt.Errorf("unable to serialize w/ unknown "+ return fmt.Errorf("unable to serialize w/ unknown "+
"version: %v", s.Version) "version: %v", s.Version)
@ -344,6 +352,7 @@ func (s *Single) Deserialize(r io.Reader) error {
case DefaultSingleVersion: case DefaultSingleVersion:
case TweaklessCommitVersion: case TweaklessCommitVersion:
case AnchorsCommitVersion: case AnchorsCommitVersion:
case AnchorsZeroFeeHtlcTxCommitVersion:
default: default:
return fmt.Errorf("unable to de-serialize w/ unknown "+ return fmt.Errorf("unable to de-serialize w/ unknown "+
"version: %v", s.Version) "version: %v", s.Version)

@ -110,6 +110,11 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) (
chanType = channeldb.AnchorOutputsBit chanType = channeldb.AnchorOutputsBit
chanType |= channeldb.SingleFunderTweaklessBit chanType |= channeldb.SingleFunderTweaklessBit
case chanbackup.AnchorsZeroFeeHtlcTxCommitVersion:
chanType = channeldb.ZeroHtlcTxFeeBit
chanType |= channeldb.AnchorOutputsBit
chanType |= channeldb.SingleFunderTweaklessBit
default: default:
return nil, fmt.Errorf("unknown Single version: %v", err) return nil, fmt.Errorf("unknown Single version: %v", err)
} }