lnwallet: nil single tweak when creating keyring

To make the channel state machine less concerned about the type of
commitment, we nil the local tweak when creating the keyring, depending
on the commitment type.
This commit is contained in:
Johan T. Halseth 2020-01-06 11:42:04 +01:00
parent 5e3718a1b5
commit f92c7a3af0
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 7 additions and 14 deletions

View File

@ -1929,13 +1929,6 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
},
HashType: txscript.SigHashAll,
}
// If this is a tweakless commitment, then we can safely blank
// out the SingleTweak value as it isn't needed.
tweaklessCommit := chanState.ChanType.IsTweakless()
if tweaklessCommit {
localSignDesc.SingleTweak = nil
}
}
// Similarly, if the remote balance exceeds the remote party's dust
@ -4807,13 +4800,6 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer input.Si
},
MaturityDelay: 0,
}
// If this is a tweakless commitment, then we can safely blank
// out the SingleTweak value as it isn't needed.
tweaklessCommit := chanState.ChanType.IsTweakless()
if tweaklessCommit {
commitResolution.SelfOutputSignDesc.SingleTweak = nil
}
}
closeSummary := channeldb.ChannelCloseSummary{

View File

@ -146,6 +146,13 @@ func DeriveCommitmentKeys(commitPoint *btcec.PublicKey,
// we'll use that directly, and ignore the commitPoint tweak.
if tweaklessCommit {
keyRing.ToRemoteKey = toRemoteBasePoint
// If this is not our commitment, the above ToRemoteKey will be
// ours, and we blank out the local commitment tweak to
// indicate that the key should not be tweaked when signing.
if !isOurCommit {
keyRing.LocalCommitKeyTweak = nil
}
} else {
keyRing.ToRemoteKey = input.TweakPubKey(
toRemoteBasePoint, commitPoint,