fix converttopsbt permitsigdata arg, add basic test
Github-Pull: #14356
Rebased-From: 88a79cb436
This commit is contained in:
parent
5d12143c73
commit
7a590d8390
2 changed files with 4 additions and 1 deletions
|
@ -1778,7 +1778,7 @@ UniValue converttopsbt(const JSONRPCRequest& request)
|
||||||
|
|
||||||
// Remove all scriptSigs and scriptWitnesses from inputs
|
// Remove all scriptSigs and scriptWitnesses from inputs
|
||||||
for (CTxIn& input : tx.vin) {
|
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");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptSigs and scriptWitnesses");
|
||||||
}
|
}
|
||||||
input.scriptSig.clear();
|
input.scriptSig.clear();
|
||||||
|
|
|
@ -146,6 +146,9 @@ class PSBTTest(BitcoinTestFramework):
|
||||||
# Make sure that a psbt with signatures cannot be converted
|
# Make sure that a psbt with signatures cannot be converted
|
||||||
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])
|
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'])
|
||||||
|
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
|
# Explicilty allow converting non-empty txs
|
||||||
new_psbt = self.nodes[0].converttopsbt(rawtx['hex'])
|
new_psbt = self.nodes[0].converttopsbt(rawtx['hex'])
|
||||||
|
|
Loading…
Reference in a new issue