mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 23:01:53 +02:00
multi: introduce and use new TapTweak and SignMethod fields
In this commit, we add a new field `TapTweak` to be used for key path spends. Before this commit, we'd overload the existing `WitnessScript` field to pass this information to the signing context. This was confusing as for tapscript spends, this was the leaf script, which mirrors the other script based spending types. With this new filed, users need to set this to the script root for keypath spends where the output key commits to a real merkle root, and nothing when bip 86 spending is being used. To make the signing even more explicit, we also add a new field called sign_method with an enum type that differentiates between the different segwit v0 and v1 signing methods. Fixes https://github.com/lightningnetwork/lnd/issues/6446.
This commit is contained in:
committed by
Oliver Gugger
parent
99cda74f6a
commit
630fc36dcf
@@ -372,21 +372,23 @@ func (b *BtcWallet) SignOutputRaw(tx *wire.MsgTx,
|
||||
// slightly different, so we need to account for that to get the
|
||||
// raw signature.
|
||||
var rawSig []byte
|
||||
if signDesc.TaprootKeySpend {
|
||||
switch signDesc.SignMethod {
|
||||
case input.TaprootKeySpendBIP0086SignMethod,
|
||||
input.TaprootKeySpendSignMethod:
|
||||
|
||||
// This function tweaks the private key using the tap
|
||||
// root key supplied as the tweak. So we pass in the
|
||||
// original private key to avoid it being double
|
||||
// tweaked!
|
||||
// root key supplied as the tweak.
|
||||
rawSig, err = txscript.RawTxInTaprootSignature(
|
||||
tx, sigHashes, signDesc.InputIndex,
|
||||
signDesc.Output.Value, signDesc.Output.PkScript,
|
||||
signDesc.WitnessScript, signDesc.HashType,
|
||||
signDesc.TapTweak, signDesc.HashType,
|
||||
privKey,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
|
||||
case input.TaprootScriptSpendSignMethod:
|
||||
leaf := txscript.TapLeaf{
|
||||
LeafVersion: txscript.BaseLeafVersion,
|
||||
Script: witnessScript,
|
||||
|
Reference in New Issue
Block a user