rpcwallet: fix p2tr inputs in remote signing

The SendOutputs method isn't used very often in our code so the missing
Taproot sighash type wasn't detected before.
Also, a P2TR input will never have a sigScript, so we can explicitly set
that parameter to nil instead of relying on it being nil anyway.
This commit is contained in:
Oliver Gugger committed 2023-02-07 22:15:13 +01:00
1 parent 8bc16b4fb2
commit df1ea46d9e
1 file changed
+5 -1
+5 -1
View File
@@ -159,6 +159,10 @@ func (r *RPCKeyRing) SendOutputs(outputs []*wire.TxOut,
return nil, fmt.Errorf("error looking up utxo: %v", err) return nil, fmt.Errorf("error looking up utxo: %v", err)
} }
if txscript.IsPayToTaproot(info.PkScript) {
signDesc.HashType = txscript.SigHashDefault
}
// Now that we know the input is ours, we'll populate the // Now that we know the input is ours, we'll populate the
// signDesc with the per input unique information. // signDesc with the per input unique information.
signDesc.Output = &wire.TxOut{ signDesc.Output = &wire.TxOut{
@@ -593,7 +597,7 @@ func (r *RPCKeyRing) ComputeInputScript(tx *wire.MsgTx,
signDesc.SignMethod = input.TaprootKeySpendBIP0086SignMethod signDesc.SignMethod = input.TaprootKeySpendBIP0086SignMethod
signDesc.WitnessScript = nil signDesc.WitnessScript = nil
sig, err := r.remoteSign(tx, signDesc, sigScript) sig, err := r.remoteSign(tx, signDesc, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("error signing with remote"+ return nil, fmt.Errorf("error signing with remote"+
"instance: %v", err) "instance: %v", err)