mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-23 19:35:28 +02:00
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:
@@ -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,
|
||||
|
Reference in New Issue
Block a user