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.5"""Test the sendmany RPC command."""7from test_framework.test_framework import BitcoinTestFramework8from test_framework.util import assert_raises_rpc_error11class SendmanyTest(BitcoinTestFramework):12def skip_test_if_missing_module(self):13self.skip_if_no_wallet()15def set_test_params(self):16self.num_nodes = 117self.setup_clean_chain = True19def test_sffo_repeated_address(self):20addr_1 = self.wallet.getnewaddress()21addr_2 = self.wallet.getnewaddress()22addr_3 = self.wallet.getnewaddress()24self.log.info("Test using duplicate address in SFFO argument")25assert_raises_rpc_error(-8, "Invalid parameter 'subtract fee from output', duplicated position: 0", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[addr_1, addr_1, addr_1])26self.log.info("Test using address not present in tx.vout in SFFO argument")27assert_raises_rpc_error(-8, f"Invalid parameter 'subtract fee from output', destination {addr_3} not found in tx outputs", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[addr_3])28self.log.info("Test using negative index in SFFO argument")29assert_raises_rpc_error(-8, "Invalid parameter 'subtract fee from output', negative position: -5", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[-5])30self.log.info("Test using an out of bounds index in SFFO argument")31assert_raises_rpc_error(-8, "Invalid parameter 'subtract fee from output', position too large: 5", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[5])32self.log.info("Test using an unexpected type in SFFO argument")33assert_raises_rpc_error(-8, "Invalid parameter 'subtract fee from output', invalid value type: bool", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[False])34self.log.info("Test duplicates in SFFO argument, mix string destinations with numeric indexes")35assert_raises_rpc_error(-8, "Invalid parameter 'subtract fee from output', duplicated position: 0", self.def_wallet.sendmany, dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[0, addr_1])36self.log.info("Test valid mixing of string destinations with numeric indexes in SFFO argument")37self.def_wallet.sendmany(dummy='', amounts={addr_1: 1, addr_2: 1}, subtractfeefrom=[0, addr_2])39def run_test(self):40self.nodes[0].createwallet("activewallet")41self.wallet = self.nodes[0].get_wallet_rpc("activewallet")42self.def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)43self.generate(self.nodes[0], 101)45self.test_sffo_repeated_address()48if __name__ == '__main__':49SendmanyTest(__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.