mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-09 20:33:45 +01: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:
@@ -124,8 +124,14 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
|
||||
isInitiator = true
|
||||
}
|
||||
|
||||
chanType := channeldb.SingleFunder
|
||||
if rand.Int63()%2 == 0 {
|
||||
chanType = channeldb.SingleFunderTweakless
|
||||
}
|
||||
|
||||
return &channeldb.OpenChannel{
|
||||
ChainHash: chainHash,
|
||||
ChanType: chanType,
|
||||
IsInitiator: isInitiator,
|
||||
FundingOutpoint: chanPoint,
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(
|
||||
@@ -223,6 +229,12 @@ func TestSinglePackUnpack(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
|
||||
// The new tweakless version, should pack/unpack with no problem.
|
||||
{
|
||||
version: TweaklessCommitVersion,
|
||||
valid: true,
|
||||
},
|
||||
|
||||
// A non-default version, atm this should result in a failure.
|
||||
{
|
||||
version: 99,
|
||||
@@ -274,7 +286,7 @@ func TestSinglePackUnpack(t *testing.T) {
|
||||
}
|
||||
|
||||
rawBytes := rawSingle.Bytes()
|
||||
rawBytes[0] ^= 1
|
||||
rawBytes[0] ^= 5
|
||||
|
||||
newReader := bytes.NewReader(rawBytes)
|
||||
err = unpackedSingle.Deserialize(newReader)
|
||||
|
||||
Reference in New Issue
Block a user