test: add rescan_utxos in MiniWallet's initialization

this simplifies usage when MiniWallet is used with a pre-mined chain.
This commit is contained in:
kouloumos
2023-01-13 11:28:39 +02:00
parent 599e941c19
commit 0377d6bb42
25 changed files with 7 additions and 29 deletions

View File

@@ -101,6 +101,13 @@ class MiniWallet:
self._address, self._internal_key = create_deterministic_address_bcrt1_p2tr_op_true()
self._scriptPubKey = bytes.fromhex(self._test_node.validateaddress(self._address)['scriptPubKey'])
# When the pre-mined test framework chain is used, it contains coinbase
# outputs to the MiniWallet's default address in blocks 76-100
# (see method BitcoinTestFramework._initialize_chain())
# The MiniWallet needs to rescan_utxos() in order to account
# for those mature UTXOs, so that all txs spend confirmed coins
self.rescan_utxos()
def _create_utxo(self, *, txid, vout, value, height, coinbase, confirmations):
return {"txid": txid, "vout": vout, "value": value, "height": height, "coinbase": coinbase, "confirmations": confirmations}