From 7d66e6647b5b5ab8b82cbe56c7c566ac0e703619 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 12 Nov 2018 19:09:23 +0100 Subject: [PATCH] Merge #14356: fix converttopsbt permitsigdata arg, add basic test 88a79cb436b30b39d37d139da723f5a31e9d161b fix converttopsbt permitsigdata arg, add basic test (Gregory Sanders) Pull request description: The final check for extraneous sigdata has a flipped boolean, resulting in incorrect behavior. Resolves https://github.com/bitcoin/bitcoin/issues/14355 Tree-SHA512: 5157a74b8ddebd7d836fba96765c4d7ed15a73d4289817353d3566a0f6803bd4bbc3f936735c517c7a83a6cbdb4052b9c61d23f6cc4ad00a6077278cd51adbd4 --- src/rpc/rawtransaction.cpp | 2 +- test/functional/rpc_psbt.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 8acd1f4c3e..6bc11bd105 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1701,7 +1701,7 @@ UniValue converttopsbt(const JSONRPCRequest& request) // 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"); } input.scriptSig.clear(); diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 374823b14f..6045b65fb2 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -85,6 +85,9 @@ class PSBTTest(BitcoinTestFramework): # 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']) + assert_raises_rpc_error(-22, "Inputs must not have scriptSigs", self.nodes[0].converttopsbt, signedtx['hex'], False) + # 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'])