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.
251self.add_utxos([19, 2])253assert_raises_rpc_error(254-8,255"Must provide at least one address without a specified amount" ,256self.wallet.sendall,257[]258)260@cleanup261def sendall_fails_on_specific_inputs_with_send_max(self):262self.log.info("Test sendall fails because send_max is used while specific inputs are provided")263self.add_utxos([15, 6])264utxo = self.wallet.listunspent()[0]266assert_raises_rpc_error(-8,267"Cannot combine send_max with specific inputs.",268self.wallet.sendall,269recipients=[self.remainder_target],270inputs=[utxo], send_max=True)272@cleanup273def sendall_fails_on_high_fee(self):274self.log.info("Test sendall fails if the transaction fee exceeds the maxtxfee")275self.add_utxos([21])277assert_raises_rpc_error(278-4,279"Fee exceeds maximum configured by user",280self.wallet.sendall,281recipients=[self.remainder_target],282fee_rate=100000)284@cleanup285def sendall_fails_on_low_fee(self):286self.log.info("Test sendall fails if the transaction fee is lower than the minimum fee rate setting")287assert_raises_rpc_error(-8, "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)",288self.wallet.sendall, recipients=[self.recipient], fee_rate=0.999)290@cleanup291def sendall_watchonly_specific_inputs(self):292self.log.info("Test sendall with a subset of UTXO pool in a watchonly wallet")293self.add_utxos([17, 4])294utxo = self.wallet.listunspent()[0]296self.nodes[0].createwallet(wallet_name="watching", disable_private_keys=True)297watchonly = self.nodes[0].get_wallet_rpc("watching")299import_req = [{300"desc": utxo["desc"],301"timestamp": 0,302}]303watchonly.importdescriptors(import_req)305sendall_tx_receipt = watchonly.sendall(recipients=[self.remainder_target], inputs=[utxo])306psbt = sendall_tx_receipt["psbt"]307decoded = self.nodes[0].decodepsbt(psbt)308assert_equal(len(decoded["inputs"]), 1)309assert_equal(len(decoded["outputs"]), 1)310assert_equal(decoded["inputs"][0]["previous_txid"], utxo["txid"])311assert_equal(decoded["inputs"][0]["previous_vout"], utxo["vout"])312assert_equal(decoded["outputs"][0]["script"]["address"], self.remainder_target)314@cleanup315def sendall_with_minconf(self):316# utxo of 17 bicoin has 6 confirmations, utxo of 4 has 3317self.add_utxos([17])318self.generate(self.nodes[0], 2)319self.add_utxos([4])320self.generate(self.nodes[0], 2)322self.log.info("Test sendall fails because minconf is negative")324assert_raises_rpc_error(-8,325"Invalid minconf (minconf cannot be negative): -2",326self.wallet.sendall,327recipients=[self.remainder_target],328options={"minconf": -2})329self.log.info("Test sendall fails because minconf is used while specific inputs are provided")331utxo = self.wallet.listunspent()[0]332assert_raises_rpc_error(-8,333"Cannot combine minconf or maxconf with specific inputs.",334self.wallet.sendall,335recipients=[self.remainder_target],336options={"inputs": [utxo], "minconf": 2})338self.log.info("Test sendall fails because there are no utxos with enough confirmations specified by minconf")340assert_raises_rpc_error(-6,341"Total value of UTXO pool too low to pay for transaction. Try using lower feerate or excluding uneconomic UTXOs with 'send_max' option.",342self.wallet.sendall,343recipients=[self.remainder_target],344options={"minconf": 7})346self.log.info("Test sendall only spends utxos with a specified number of confirmations when minconf is used")347self.wallet.sendall(recipients=[self.remainder_target], fee_rate=300, options={"minconf": 6})349assert_equal(len(self.wallet.listunspent()), 1)350assert_equal(self.wallet.listunspent()[0]['confirmations'], 3)352# decrease minconf and show the remaining utxo is picked up353self.wallet.sendall(recipients=[self.remainder_target], fee_rate=300, options={"minconf": 3})354assert_equal(self.wallet.getbalance(), 0)356@cleanup357def sendall_with_maxconf(self):358# utxo of 17 bicoin has 6 confirmations, utxo of 4 has 3359self.add_utxos([17])360self.generate(self.nodes[0], 2)361self.add_utxos([4])362self.generate(self.nodes[0], 2)364self.log.info("Test sendall fails because there are no utxos with enough confirmations specified by maxconf")365assert_raises_rpc_error(-6,366"Total value of UTXO pool too low to pay for transaction. Try using lower feerate or excluding uneconomic UTXOs with 'send_max' option.",367self.wallet.sendall,368recipients=[self.remainder_target],369options={"maxconf": 1})371self.log.info("Test sendall only spends utxos with a specified number of confirmations when maxconf is used")372self.wallet.sendall(recipients=[self.remainder_target], fee_rate=300, options={"maxconf":4})373assert_equal(len(self.wallet.listunspent()), 1)374assert_equal(self.wallet.listunspent()[0]['confirmations'], 6)376@cleanup377def sendall_spends_unconfirmed_change(self):378self.log.info("Test that sendall spends unconfirmed change")379self.add_utxos([17])380self.wallet.sendtoaddress(self.remainder_target, 10)381assert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 6)382self.test_sendall_success(sendall_args = [self.remainder_target])384assert_equal(self.wallet.getbalance(), 0)386@cleanup387def sendall_spends_unconfirmed_inputs_if_specified(self):388self.log.info("Test that sendall spends specified unconfirmed inputs")389self.def_wallet.sendtoaddress(self.wallet.getnewaddress(), 17)390self.wallet.syncwithvalidationinterfacequeue()391assert_equal(self.wallet.getbalances()["mine"]["untrusted_pending"], 17)392unspent = self.wallet.listunspent(minconf=0)[0]394self.wallet.sendall(recipients=[self.remainder_target], inputs=[unspent])395assert_equal(self.wallet.getbalance(), 0)397@cleanup398def sendall_does_ancestor_aware_funding(self):399self.log.info("Test that sendall does ancestor aware funding for unconfirmed inputs")401# higher parent feerate402self.def_wallet.sendtoaddress(address=self.wallet.getnewaddress(), amount=17, fee_rate=20)403self.wallet.syncwithvalidationinterfacequeue()405assert_equal(self.wallet.getbalances()["mine"]["untrusted_pending"], 17)406unspent = self.wallet.listunspent(minconf=0)[0]408parent_txid = unspent["txid"]409assert_equal(self.wallet.gettransaction(parent_txid)["confirmations"], 0)411res_1 = self.wallet.sendall(recipients=[self.def_wallet.getnewaddress()], inputs=[unspent], fee_rate=20, add_to_wallet=False, lock_unspents=True)412child_hex = res_1["hex"]414child_tx = self.wallet.decoderawtransaction(child_hex)415higher_parent_feerate_amount = child_tx["vout"][0]["value"]417# lower parent feerate418self.def_wallet.sendtoaddress(address=self.wallet.getnewaddress(), amount=17, fee_rate=10)419self.wallet.syncwithvalidationinterfacequeue()420assert_equal(self.wallet.getbalances()["mine"]["untrusted_pending"], 34)421unspent = self.wallet.listunspent(minconf=0)[0]423parent_txid = unspent["txid"]424assert_equal(self.wallet.gettransaction(parent_txid)["confirmations"], 0)426res_2 = self.wallet.sendall(recipients=[self.def_wallet.getnewaddress()], inputs=[unspent], fee_rate=20, add_to_wallet=False, lock_unspents=True)427child_hex = res_2["hex"]429child_tx = self.wallet.decoderawtransaction(child_hex)430lower_parent_feerate_amount = child_tx["vout"][0]["value"]432assert_greater_than(higher_parent_feerate_amount, lower_parent_feerate_amount)434@cleanup435def sendall_anti_fee_sniping(self):436self.log.info("Testing sendall does anti-fee-sniping when locktime is not specified")437self.add_utxos([10,11])438tx_from_wallet = self.test_sendall_success(sendall_args = [self.remainder_target], options={"replaceable":False})440# the locktime should be within 100 blocks of the441# block height442assert_greater_than_or_equal(tx_from_wallet["decoded"]["locktime"], tx_from_wallet["blockheight"] - 100)444self.log.info("Testing sendall does not do anti-fee-sniping when locktime is specified")445self.add_utxos([10,11])446txid = self.wallet.sendall(recipients=[self.remainder_target], options={"locktime":0})["txid"]447assert_equal(self.wallet.gettransaction(txid=txid, verbose=True)["decoded"]["locktime"], 0)449self.log.info("Testing sendall does not do anti-fee-sniping when even one of the sequences is final")450self.add_utxos([10, 11])451utxos = self.wallet.listunspent()452utxos[0]["sequence"] = SEQUENCE_FINAL453txid = self.wallet.sendall(recipients=[self.remainder_target], inputs=utxos)["txid"]454assert_equal(self.wallet.gettransaction(txid=txid, verbose=True)["decoded"]["locktime"], 0)456# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error457def sendall_fails_with_transaction_too_large(self):458self.log.info("Test that sendall fails if resulting transaction is too large")460# Force the wallet to bulk-generate the addresses we'll need461self.wallet.keypoolrefill(1600)463# create many inputs464outputs = {self.wallet.getnewaddress(): 0.000025 for _ in range(1600)}465self.def_wallet.sendmany(amounts=outputs)466self.generate(self.nodes[0], 1)468assert_raises_rpc_error(469-4,470"Transaction too large.",471self.wallet.sendall,472recipients=[self.remainder_target])474def run_test(self):475self.nodes[0].createwallet("activewallet")476self.wallet = self.nodes[0].get_wallet_rpc("activewallet")477self.def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)478self.generate(self.nodes[0], 101)479self.recipient = self.def_wallet.getnewaddress() # payee for a specific amount480self.remainder_target = self.def_wallet.getnewaddress() # address that receives everything left after payments and fees481self.split_target = self.def_wallet.getnewaddress() # 2nd target when splitting rest483# Test cleanup484self.test_cleanup()486# Basic sweep: everything to one address487self.sendall_two_utxos()489# Split remainder to two addresses with equal amounts490self.sendall_split()492# Pay recipient and sweep remainder493self.sendall_and_spend()495# sendall fails if no recipient has unspecified amount496self.sendall_invalid_recipient_addresses()498# Sendall fails if same destination is provided twice499self.sendall_duplicate_recipient()
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.