Skip to content

Commit afc2dd5

Browse files
committed
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.
1 parent e352f5a commit afc2dd5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test/functional/rpc_psbt.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,15 @@ def run_test(self):
397397
self.nodes[0].decodepsbt(new_psbt)
398398

399399
# Make sure that a non-psbt with signatures cannot be converted
400-
# Error could be either "TX decode failed" (segwit inputs causes parsing to fail) or "Inputs must not have scriptSigs and scriptWitnesses"
401-
# We must set iswitness=True because the serialized transaction has inputs and is therefore a witness transaction
402400
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])
403-
assert_raises_rpc_error(-22, "", self.nodes[0].converttopsbt, hexstring=signedtx['hex'], iswitness=True)
404-
assert_raises_rpc_error(-22, "", self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False, iswitness=True)
401+
assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses",
402+
self.nodes[0].converttopsbt, hexstring=signedtx['hex']) # permitsigdata=False by default
403+
assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses",
404+
self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False)
405+
assert_raises_rpc_error(-22, "Inputs must not have scriptSigs and scriptWitnesses",
406+
self.nodes[0].converttopsbt, hexstring=signedtx['hex'], permitsigdata=False, iswitness=True)
405407
# Unless we allow it to convert and strip signatures
406-
self.nodes[0].converttopsbt(signedtx['hex'], True)
407-
408-
# Explicitly allow converting non-empty txs
409-
new_psbt = self.nodes[0].converttopsbt(rawtx['hex'])
410-
self.nodes[0].decodepsbt(new_psbt)
408+
self.nodes[0].converttopsbt(hexstring=signedtx['hex'], permitsigdata=True)
411409

412410
# Create outputs to nodes 1 and 2
413411
node1_addr = self.nodes[1].getnewaddress()

0 commit comments

Comments
 (0)