Merge #14878: 0.17: Further backports

7a590d8390 fix converttopsbt permitsigdata arg, add basic test (Gregory Sanders)

Pull request description:

  Ooff, we missed some backports that were tagged.

  Checked:

  * In 7a590d8 (clean cherry-pick): The test changes fail without the code changes

Tree-SHA512: 9996886113dfcd8efa91f5436bc0f3507c81579861543611367bc3403868019fb1e45832c3f994f12278edb1c0c850e21f2f88e46a6981f45a11c4d61dcedaf9
This commit is contained in:
Wladimir J. van der Laan 2018-12-06 15:18:16 +01:00
commit 8b8b3a9a5f
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D
2 changed files with 4 additions and 1 deletions

View file

@ -1778,7 +1778,7 @@ UniValue converttopsbt(const JSONRPCRequest& request)
// Remove all scriptSigs and scriptWitnesses from inputs
for (CTxIn& input : tx.vin) {
if ((!input.scriptSig.empty() || !input.scriptWitness.IsNull()) && (request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool()))) {
if ((!input.scriptSig.empty() || !input.scriptWitness.IsNull()) && !permitsigdata) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptSigs and scriptWitnesses");
}
input.scriptSig.clear();

View file

@ -146,6 +146,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, "TX decode failed", self.nodes[0].converttopsbt, signedtx['hex'])
assert_raises_rpc_error(-22, "TX decode failed", 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'])