From df1ea46d9e4cf11426f61d2e99c9f6bd856bfc28 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 7 Feb 2023 22:15:13 +0100 Subject: [PATCH] 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. --- lnwallet/rpcwallet/rpcwallet.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index d5ab4e254..38f345c14 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -159,6 +159,10 @@ func (r *RPCKeyRing) SendOutputs(outputs []*wire.TxOut, 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 // signDesc with the per input unique information. signDesc.Output = &wire.TxOut{ @@ -593,7 +597,7 @@ func (r *RPCKeyRing) ComputeInputScript(tx *wire.MsgTx, signDesc.SignMethod = input.TaprootKeySpendBIP0086SignMethod signDesc.WitnessScript = nil - sig, err := r.remoteSign(tx, signDesc, sigScript) + sig, err := r.remoteSign(tx, signDesc, nil) if err != nil { return nil, fmt.Errorf("error signing with remote"+ "instance: %v", err)