@@ -56,6 +56,11 @@ def send_to_address(self, addr, amount):
56
56
txid = self .nodes [0 ].sendrawtransaction (self .nodes [0 ].signrawtransactionwithkey (rawtx , [self .nodes [0 ].get_deterministic_priv_key ().key ])["hex" ], 0 )
57
57
return txid
58
58
59
+ def assert_signing_completed_successfully (self , signed_tx ):
60
+ assert 'errors' not in signed_tx
61
+ assert 'complete' in signed_tx
62
+ assert_equal (signed_tx ['complete' ], True )
63
+
59
64
def successful_signing_test (self ):
60
65
"""Create and sign a valid raw transaction with one input.
61
66
@@ -68,11 +73,7 @@ def successful_signing_test(self):
68
73
rawTx = self .nodes [0 ].createrawtransaction (INPUTS , OUTPUTS )
69
74
rawTxSigned = self .nodes [0 ].signrawtransactionwithkey (rawTx , privKeys , INPUTS )
70
75
71
- # 1) The transaction has a complete set of signatures
72
- assert rawTxSigned ['complete' ]
73
-
74
- # 2) No script verification error occurred
75
- assert 'errors' not in rawTxSigned
76
+ self .assert_signing_completed_successfully (rawTxSigned )
76
77
77
78
def witness_script_test (self ):
78
79
self .log .info ("Test signing transaction to P2SH-P2WSH addresses without wallet" )
@@ -93,9 +94,7 @@ def witness_script_test(self):
93
94
# Now create and sign a transaction spending that output on node[0], which doesn't know the scripts or keys
94
95
spending_tx = self .nodes [0 ].createrawtransaction ([unspent_output ], {getnewdestination ()[2 ]: Decimal ("49.998" )})
95
96
spending_tx_signed = self .nodes [0 ].signrawtransactionwithkey (spending_tx , [embedded_privkey ], [unspent_output ])
96
- # Check the signing completed successfully
97
- assert 'complete' in spending_tx_signed
98
- assert_equal (spending_tx_signed ['complete' ], True )
97
+ self .assert_signing_completed_successfully (spending_tx_signed )
99
98
100
99
# Now test with P2PKH and P2PK scripts as the witnessScript
101
100
for tx_type in ['P2PKH' , 'P2PK' ]: # these tests are order-independent
@@ -118,9 +117,7 @@ def verify_txn_with_witness_script(self, tx_type):
118
117
# Now create and sign a transaction spending that output on node[0], which doesn't know the scripts or keys
119
118
spending_tx = self .nodes [0 ].createrawtransaction ([{'txid' : txid , 'vout' : vout }], {getnewdestination ()[2 ]: Decimal ("9.999" )})
120
119
spending_tx_signed = self .nodes [0 ].signrawtransactionwithkey (spending_tx , [embedded_privkey ], [{'txid' : txid , 'vout' : vout , 'scriptPubKey' : script_pub_key , 'redeemScript' : redeem_script , 'witnessScript' : witness_script , 'amount' : 10 }])
121
- # Check the signing completed successfully
122
- assert 'complete' in spending_tx_signed
123
- assert_equal (spending_tx_signed ['complete' ], True )
120
+ self .assert_signing_completed_successfully (spending_tx_signed )
124
121
self .nodes [0 ].sendrawtransaction (spending_tx_signed ['hex' ])
125
122
126
123
def invalid_sighashtype_test (self ):
0 commit comments