aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/wallet.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-04-22 13:34:26 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-04-22 20:02:31 +0200
commitfa1bedb4944b513a3c9184ad549f58bfbe69e20e (patch)
tree78fa7e9288a3b7da2d026c34c3d991552e62c512 /test/functional/test_framework/wallet.py
parent4b5659c6b115315c9fd2902b4edd4b960a5e066e (diff)
downloadbitcoin-fa1bedb4944b513a3c9184ad549f58bfbe69e20e.tar.xz
test: Add MiniWallet.sendrawtransaction
Can be reviewed with --ignore-all-space --color-moved=dimmed-zebra
Diffstat (limited to 'test/functional/test_framework/wallet.py')
-rw-r--r--test/functional/test_framework/wallet.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index a906a21dd0..26294d6a9d 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -37,9 +37,13 @@ class MiniWallet:
for i in range(start, start + num):
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
for tx in block['tx']:
- for out in tx['vout']:
- if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
- self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value']})
+ self.scan_tx(tx)
+
+ def scan_tx(self, tx):
+ """Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
+ for out in tx['vout']:
+ if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
+ self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value']})
def generate(self, num_blocks):
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
@@ -84,8 +88,11 @@ class MiniWallet:
tx_hex = tx.serialize().hex()
tx_info = from_node.testmempoolaccept([tx_hex])[0]
- self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value})
- from_node.sendrawtransaction(tx_hex)
+ self.sendrawtransaction(from_node=from_node, tx_hex=tx_hex)
assert_equal(tx_info['vsize'], vsize)
assert_equal(tx_info['fees']['base'], fee)
return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex}
+
+ def sendrawtransaction(self, *, from_node, tx_hex):
+ from_node.sendrawtransaction(tx_hex)
+ self.scan_tx(from_node.decoderawtransaction(tx_hex))