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) 2022-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.6from test_framework.test_framework import BitcoinTestFramework7from test_framework.util import assert_equal10class WalletLocktimeTest(BitcoinTestFramework):11def set_test_params(self):12self.num_nodes = 114def skip_test_if_missing_module(self):15self.skip_if_no_wallet()17def run_test(self):18node = self.nodes[0]20mtp_tip = node.getblockheader(node.getbestblockhash())["mediantime"]22self.log.info("Get new address with label")23label = "timelock⌛🔓"24address = node.getnewaddress(label=label)26self.log.info("Send to new address with locktime")27node.send(28outputs={address: 5},29locktime=mtp_tip - 1,30)31self.generate(node, 1)33self.log.info("Check that clock cannot change finality of confirmed txs")34amount_before_ad = node.getreceivedbyaddress(address)35amount_before_lb = node.getreceivedbylabel(label)36list_before_ad = node.listreceivedbyaddress(address_filter=address)37list_before_lb = node.listreceivedbylabel(include_empty=False)38balance_before = node.getbalances()["mine"]["trusted"]39coin_before = node.listunspent(maxconf=1)40node.setmocktime(mtp_tip - 1)41assert_equal(node.getreceivedbyaddress(address), amount_before_ad)42assert_equal(node.getreceivedbylabel(label), amount_before_lb)43assert_equal(node.listreceivedbyaddress(address_filter=address), list_before_ad)44assert_equal(node.listreceivedbylabel(include_empty=False), list_before_lb)45assert_equal(node.getbalances()["mine"]["trusted"], balance_before)46assert_equal(node.listunspent(maxconf=1), coin_before)49if __name__ == "__main__":50WalletLocktimeTest(__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.