Skip to content

Commit fa1bedb

Browse files
author
MarcoFalke
committed
test: Add MiniWallet.sendrawtransaction
Can be reviewed with --ignore-all-space --color-moved=dimmed-zebra
1 parent 4b5659c commit fa1bedb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/functional/test_framework/wallet.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ def scan_blocks(self, *, start=1, num):
3737
for i in range(start, start + num):
3838
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
3939
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']})
4347

4448
def generate(self, num_blocks):
4549
"""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
8488
tx_hex = tx.serialize().hex()
8589

8690
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)
8992
assert_equal(tx_info['vsize'], vsize)
9093
assert_equal(tx_info['fees']['base'], fee)
9194
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

Comments
 (0)