From 0b9bec78048bcc4ce7e49fce9d1a038a5aa32c35 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 7 Dec 2020 14:21:29 +0100 Subject: [PATCH] chanrestore: define ZeroHtlcTxFeeCommitVersion --- chanbackup/single.go | 9 +++++++++ chanrestore.go | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/chanbackup/single.go b/chanbackup/single.go index 490657b9..ab8bdcdc 100644 --- a/chanbackup/single.go +++ b/chanbackup/single.go @@ -36,6 +36,10 @@ const ( // implicitly denotes that this channel uses the new anchor commitment // format. 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 @@ -163,6 +167,9 @@ func NewSingle(channel *channeldb.OpenChannel, } switch { + case channel.ChanType.ZeroHtlcTxFee(): + single.Version = AnchorsZeroFeeHtlcTxCommitVersion + case channel.ChanType.HasAnchors(): single.Version = AnchorsCommitVersion @@ -185,6 +192,7 @@ func (s *Single) Serialize(w io.Writer) error { case DefaultSingleVersion: case TweaklessCommitVersion: case AnchorsCommitVersion: + case AnchorsZeroFeeHtlcTxCommitVersion: default: return fmt.Errorf("unable to serialize w/ unknown "+ "version: %v", s.Version) @@ -344,6 +352,7 @@ func (s *Single) Deserialize(r io.Reader) error { case DefaultSingleVersion: case TweaklessCommitVersion: case AnchorsCommitVersion: + case AnchorsZeroFeeHtlcTxCommitVersion: default: return fmt.Errorf("unable to de-serialize w/ unknown "+ "version: %v", s.Version) diff --git a/chanrestore.go b/chanrestore.go index 60071ae3..a309866c 100644 --- a/chanrestore.go +++ b/chanrestore.go @@ -110,6 +110,11 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) ( chanType = channeldb.AnchorOutputsBit chanType |= channeldb.SingleFunderTweaklessBit + case chanbackup.AnchorsZeroFeeHtlcTxCommitVersion: + chanType = channeldb.ZeroHtlcTxFeeBit + chanType |= channeldb.AnchorOutputsBit + chanType |= channeldb.SingleFunderTweaklessBit + default: return nil, fmt.Errorf("unknown Single version: %v", err) }