diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-03-24 17:46:15 +0100 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-03-24 17:54:09 +0100 |
commit | afc2dd54848fa70ed408ae259420ff8648f21efc (patch) | |
tree | 94f710b6f86c5f2039470e0b72abe83b7b2b7f07 | |
parent | e352f5ab6b60ec1cc549997275e945238508cdee (diff) |
test: various `converttopsbt` check cleanups in rpc_psbt.py
In the functional test rpc_psbt.py, some comments around the
`converttopsbt` RPC checks are wrong or outdated and can be
removed:
> Error could be either "TX decode failed" (segwit inputs causes
> parsing to fail) or "Inputs must not have scriptSigs and
> scriptWitnesses"
Decoding a valid TX with at least one input always succeeds with the
heuristic, i.e. this comment is not right and we can assert for the
error string "Inputs must not have scriptSigs and scriptWitnesses"
on the calls below.
> We must set iswitness=True because the serialized transaction has
> inputs and is therefore a witness transaction
This is also unneeded (and confusing, w.r.t. "is therefore a witness
transaction"?), for a TX with one input there is no need to set the
`iswitness` parameter. For sake of completeness, we still keep one
variant where iswitness is explicitly set to true.
Lastly, there is a superflous `converttopsbt` call on the raw tx which
is the same as just about ~10 lines above, so it can be removed.
-rwxr-xr-x | test/functional/rpc_psbt.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 0fc0c0df8b..bf7ff6baa0 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -397,17 +397,15 @@ class PSBTTest(BitcoinTestFramework): self.nodes[0].decodepsbt(new_psbt) # Make sure that a non-psbt with signatures cannot be converted - # Error could be either "TX decode failed" (segwit inputs causes parsing to fail) or "Inputs must not have scriptSigs and scriptWitnesses" - # We must set iswitness=True because the serialized transaction has inputs and is therefore a witness transaction signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex']) - assert_raises_rpc_error(-22, "", self.nodes[0].converttopsbt, hexstring=signedtx['hex'], iswitness=True) - assert_raises_rpc_error(-22, "", self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False, iswitness=True) + assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses", + self.nodes[0].converttopsbt, hexstring=signedtx['hex']) # permitsigdata=False by default + assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses", + self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False) + assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses", + self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False, iswitness=True) # Unless we allow it to convert and strip signatures - self.nodes[0].converttopsbt(signedtx['hex'], True) - - # Explicitly allow converting non-empty txs - new_psbt = self.nodes[0].converttopsbt(rawtx['hex']) - self.nodes[0].decodepsbt(new_psbt) + self.nodes[0].converttopsbt(hexstring=signedtx['hex'], permitsigdata=True) # Create outputs to nodes 1 and 2 node1_addr = self.nodes[1].getnewaddress() |