mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-17 20:32:33 +02:00
test: Sync MiniWallet utxo state after each generate call
This commit is contained in:
parent
dddd7c4d39
commit
fa13375aa3
@ -147,12 +147,16 @@ class MiniWallet:
|
|||||||
tx.rehash()
|
tx.rehash()
|
||||||
|
|
||||||
def generate(self, num_blocks, **kwargs):
|
def generate(self, num_blocks, **kwargs):
|
||||||
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
|
"""Generate blocks with coinbase outputs to the internal address, and call rescan_utxos"""
|
||||||
blocks = self._test_node.generatetodescriptor(num_blocks, self.get_descriptor(), **kwargs)
|
blocks = self._test_node.generatetodescriptor(num_blocks, self.get_descriptor(), **kwargs)
|
||||||
for b in blocks:
|
# Calling rescan_utxos here makes sure that after a generate the utxo
|
||||||
block_info = self._test_node.getblock(blockhash=b, verbosity=2)
|
# set is in a clean state. For example, the wallet will update
|
||||||
cb_tx = block_info['tx'][0]
|
# - if the caller consumed utxos, but never used them
|
||||||
self._utxos.append(self._create_utxo(txid=cb_tx["txid"], vout=0, value=cb_tx["vout"][0]["value"], height=block_info["height"]))
|
# - if the caller sent a transaction that is not mined or got rbf'd
|
||||||
|
# - after block re-orgs
|
||||||
|
# - the utxo height for mined mempool txs
|
||||||
|
# - However, the wallet will not consider remaining mempool txs
|
||||||
|
self.rescan_utxos()
|
||||||
return blocks
|
return blocks
|
||||||
|
|
||||||
def get_scriptPubKey(self):
|
def get_scriptPubKey(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user