rpcwallet: disallow empty UTXO pk script [skip ci]

If we're signing for an UTXO that isn't known to the wallet, then the
UTXO's pk script _must_ be set in the sign descriptor. Otherwise we run
into a generic PSBT serialization error when running in a remote signing
setup.
This commit is contained in:
Oliver Gugger 2022-02-03 17:34:14 +01:00
parent 04bbbea9a7
commit 75016a176c
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -618,6 +618,16 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
PubKey: signDesc.KeyDesc.PubKey.SerializeCompressed(),
}}
// We need to specify a pk script in the witness UTXO, otherwise
// the field becomes invalid when serialized as a PSBT. To avoid
// running into a generic "Invalid PSBT serialization format"
// error later, we return a more descriptive error now.
if len(in.WitnessUtxo.PkScript) == 0 {
return nil, fmt.Errorf("error assembling UTXO " +
"information, output not known to wallet and " +
"no UTXO pk script provided in sign descriptor")
}
default:
return nil, fmt.Errorf("error assembling UTXO information, "+
"wallet returned err='%v' and sign descriptor is "+