When a pre-mined blockchain is used (default behavior), it contains coinbase outputs in blocks 76-10 to the MiniWallet's default address. That's why we always* rescan_utxos() after initializing the MiniWallet, in order for the MiniWallet to account for those mature UTXOs.
The tests following this usage pattern can be seen with:
git grep -n "MiniWallet(" $(git grep -le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))
This PR adds rescan_utxos() inside MiniWallet's initialization to simplify usage when the MiniWallet is used with a pre-mined chain.
secondary changes
*There are a few tests that use the pre-mined blockchain but do not
rescan_utxos(), they instead generate new blocks to create mature UTXOs.Those were written before the
rescan_utxos()method was introduced with #22955 (fac66d0a39cb0b4bc565b57087ba84dd932e9b6d) and can be seen with:git grep -n "MiniWallet(" $(git grep -Le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))After including
rescan_utxos()inside MiniWallets initilization, this blocks generation logic is not needed as the MiniWallet already accounts for enough mature UTXOs to perform the tests. Therefore the now redundant blocks generation logic is removed from those tests with the second commit.The rest of the MiniWallet tests use a clean chain (
self.setup_clean_chain = True) and can be seen withgit grep -n "MiniWallet(" $(git grep -le "self.setup_clean_chain = True")From those, there are a few that start from a clean chain and then create enough mature UTXOs for the MiniWallet with this kind of logic: https://github.com/bitcoin/bitcoin/blob/07c54de550035c3441f34ef6c34209666267eb38/test/functional/mempool_expiry.py#L36-L40
Those tests are simplified in the third commit to instead utilize the mature UTXOs of the pre-mined chain.