Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) 2024-present The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test MiniWallet."""6import random7import string9from test_framework.blocktools import COINBASE_MATURITY10from test_framework.test_framework import BitcoinTestFramework11from test_framework.util import (12assert_equal,13)14from test_framework.wallet import (15MiniWallet,16MiniWalletMode,17)20class FeatureFrameworkMiniWalletTest(BitcoinTestFramework):21def set_test_params(self):22self.num_nodes = 124def test_tx_padding(self):25"""Verify that MiniWallet's transaction padding (`target_vsize` parameter)26works accurately with all modes."""27for mode_name, wallet in self.wallets:28self.log.info(f"Test tx padding with MiniWallet mode {mode_name}...")29utxo = wallet.get_utxo(mark_as_spent=False)30for target_vsize in [250, 500, 1250, 2500, 5000, 12500, 25000, 50000, 1000000,31248, 501, 1085, 3343, 5805, 12289, 25509, 55855, 999998]:32tx = wallet.create_self_transfer(utxo_to_spend=utxo, target_vsize=target_vsize)33assert_equal(tx['tx'].get_vsize(), target_vsize)34child_tx = wallet.create_self_transfer_multi(utxos_to_spend=[tx["new_utxo"]], target_vsize=target_vsize)35assert_equal(child_tx['tx'].get_vsize(), target_vsize)38def test_wallet_tagging(self):39"""Verify that tagged wallet instances are able to send funds."""40self.log.info("Test tagged wallet instances...")41node = self.nodes[0]42untagged_wallet = self.wallets[0][1]43for i in range(10):44tag = ''.join(random.choice(string.ascii_letters) for _ in range(20))45self.log.debug(f"-> ({i}) tag name: {tag}")46tagged_wallet = MiniWallet(node, tag_name=tag)47untagged_wallet.send_to(from_node=node, scriptPubKey=tagged_wallet.get_output_script(), amount=100000)48tagged_wallet.rescan_utxos()49tagged_wallet.send_self_transfer(from_node=node)50self.generate(node, 1) # clear mempool52def run_test(self):53node = self.nodes[0]54self.wallets = [55("ADDRESS_OP_TRUE", MiniWallet(node, mode=MiniWalletMode.ADDRESS_OP_TRUE)),56("RAW_OP_TRUE", MiniWallet(node, mode=MiniWalletMode.RAW_OP_TRUE)),57("RAW_P2PK", MiniWallet(node, mode=MiniWalletMode.RAW_P2PK)),58]59for _, wallet in self.wallets:60self.generate(wallet, 10)61self.generate(wallet, COINBASE_MATURITY)63self.test_tx_padding()64self.test_wallet_tagging()67if __name__ == '__main__':68FeatureFrameworkMiniWalletTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.