Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lnwallet/btcwallet/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,32 @@ func (b *BtcWallet) fetchPrivKey(

// maybeTweakPrivKey examines the single and double tweak parameters on the
// passed sign descriptor and may perform a mapping on the passed private key
// in order to utilize the tweaks, if populated.
// in order to utilize the tweaks, if populated. If both tweak parameters are
// set, then both are applied in the following order:
//
// a) double tweak
// b) single tweak
func maybeTweakPrivKey(signDesc *input.SignDescriptor,
privKey *btcec.PrivateKey) (*btcec.PrivateKey, error) {

var retPriv *btcec.PrivateKey
switch {

// If both tweak parameters are set, then apply both.
if signDesc.DoubleTweak != nil && signDesc.SingleTweak != nil {
// First apply the double tweak.
retPriv = input.DeriveRevocationPrivKey(privKey,
signDesc.DoubleTweak)

// Then apply the single tweak.
retPriv = input.TweakPrivKey(retPriv,
signDesc.SingleTweak)

return retPriv, nil
}

// If only one tweak parameter is set, apply it respectively over the
// provided private key.
switch {
case signDesc.SingleTweak != nil:
retPriv = input.TweakPrivKey(privKey,
signDesc.SingleTweak)
Expand Down
Loading