diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1675,15 +1675,15 @@ // parse hex string from parameter CMutableTransaction tx; + bool permitsigdata = + request.params[1].isNull() ? false : request.params[1].get_bool(); if (!DecodeHexTx(tx, request.params[0].get_str())) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); } // Remove all scriptSigs from inputs for (CTxIn &input : tx.vin) { - if (!input.scriptSig.empty() && - (request.params[1].isNull() || - (!request.params[1].isNull() && request.params[1].get_bool()))) { + if (!input.scriptSig.empty() && !permitsigdata) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptSigs"); } diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -106,6 +106,13 @@ new_psbt = self.nodes[0].converttopsbt(rawtx['hex']) self.nodes[0].decodepsbt(new_psbt) + # Make sure that a psbt with signatures cannot be converted + signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex']) + assert_raises_rpc_error(-22, "Inputs must not have scriptSigs", + self.nodes[0].converttopsbt, signedtx['hex']) + # Unless we allow it to convert and strip signatures + self.nodes[0].converttopsbt(signedtx['hex'], True) + # Explicilty allow converting non-empty txs new_psbt = self.nodes[0].converttopsbt(rawtx['hex']) self.nodes[0].decodepsbt(new_psbt)