@@ -37,9 +37,13 @@ def scan_blocks(self, *, start=1, num):
37
37
for i in range (start , start + num ):
38
38
block = self ._test_node .getblock (blockhash = self ._test_node .getblockhash (i ), verbosity = 2 )
39
39
for tx in block ['tx' ]:
40
- for out in tx ['vout' ]:
41
- if out ['scriptPubKey' ]['hex' ] == self ._scriptPubKey .hex ():
42
- self ._utxos .append ({'txid' : tx ['txid' ], 'vout' : out ['n' ], 'value' : out ['value' ]})
40
+ self .scan_tx (tx )
41
+
42
+ def scan_tx (self , tx ):
43
+ """Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
44
+ for out in tx ['vout' ]:
45
+ if out ['scriptPubKey' ]['hex' ] == self ._scriptPubKey .hex ():
46
+ self ._utxos .append ({'txid' : tx ['txid' ], 'vout' : out ['n' ], 'value' : out ['value' ]})
43
47
44
48
def generate (self , num_blocks ):
45
49
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
@@ -84,8 +88,11 @@ def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_sp
84
88
tx_hex = tx .serialize ().hex ()
85
89
86
90
tx_info = from_node .testmempoolaccept ([tx_hex ])[0 ]
87
- self ._utxos .append ({'txid' : tx_info ['txid' ], 'vout' : 0 , 'value' : send_value })
88
- from_node .sendrawtransaction (tx_hex )
91
+ self .sendrawtransaction (from_node = from_node , tx_hex = tx_hex )
89
92
assert_equal (tx_info ['vsize' ], vsize )
90
93
assert_equal (tx_info ['fees' ]['base' ], fee )
91
94
return {'txid' : tx_info ['txid' ], 'wtxid' : tx_info ['wtxid' ], 'hex' : tx_hex }
95
+
96
+ def sendrawtransaction (self , * , from_node , tx_hex ):
97
+ from_node .sendrawtransaction (tx_hex )
98
+ self .scan_tx (from_node .decoderawtransaction (tx_hex ))
0 commit comments