chanbackup: create new Single version for tweakless commitment chans

In this commit, we create a new Single version for channels that use the
tweakless commitment scheme. When recovering from an SCB into an open
channel shell, we'll now check this field and use it to determine the
proper channel type. Otherwise, we may attempt to sweep the on chain
funds using the commitment point, when it goes directly to our key, or
the other way around.
This commit is contained in:
Olaoluwa Osuntokun
2019-09-17 19:12:11 -07:00
parent 6d97bcbacd
commit c6ee42d3e2
3 changed files with 45 additions and 5 deletions

View File

@@ -83,9 +83,23 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) (
return nil, fmt.Errorf("unable to derive htlc key: %v", err)
}
var chanType channeldb.ChannelType
switch backup.Version {
case chanbackup.DefaultSingleVersion:
chanType = channeldb.SingleFunder
case chanbackup.TweaklessCommitVersion:
chanType = channeldb.SingleFunderTweakless
default:
return nil, fmt.Errorf("unknown Single version: %v", err)
}
chanShell := channeldb.ChannelShell{
NodeAddrs: backup.Addresses,
Chan: &channeldb.OpenChannel{
ChanType: chanType,
ChainHash: backup.ChainHash,
IsInitiator: backup.IsInitiator,
Capacity: backup.Capacity,