From c8525c93870c7510f04a8df9f765c5d083089b5c Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 2 May 2019 16:52:22 +0100 Subject: [PATCH 1/2] Fix bug in converttopsbt --- src/rpc/rawtransaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index a69db61faa..3b2cbb9a7e 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1765,13 +1765,13 @@ UniValue converttopsbt(const JSONRPCRequest& request) // Remove all scriptSigs and scriptWitnesses 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"); } input.scriptSig.clear(); } for (CTxInWitness& witness: tx.witness.vtxinwit) { - if ((!witness.scriptWitness.IsNull()) && (request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool()))) { + if (!witness.scriptWitness.IsNull() && !permitsigdata) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptWitnesses"); } } From 794c305cdda1fe1d2ae0454e6809170eb63386ea Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 3 May 2019 14:42:53 +0100 Subject: [PATCH 2/2] Test that default `permitsigdata` is false --- test/functional/rpc_psbt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index ec52bfdcc0..9bdaa5311d 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -106,6 +106,7 @@ def run_test(self): # 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 scriptWitnesses", self.nodes[0].converttopsbt, signedtx['hex'], False) assert_raises_rpc_error(-22, "Inputs must not have scriptWitnesses", self.nodes[0].converttopsbt, signedtx['hex']) # Explicitly allow converting non-empty txs