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) 2018-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 estimatefee RPCs.7Test the following RPCs:8- estimatesmartfee9- estimaterawfee10"""12from test_framework.test_framework import BitcoinTestFramework13from test_framework.util import assert_raises_rpc_error15class EstimateFeeTest(BitcoinTestFramework):16def set_test_params(self):17self.num_nodes = 119def run_test(self):20# missing required params21assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee)22assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee)24# cli handles wrong types differently25if not self.options.usecli:26# wrong type for conf_target27assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimatesmartfee, 'foo')28assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 'foo')29# wrong type for estimatesmartfee(estimate_mode)30assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", self.nodes[0].estimatesmartfee, 1, 1)31# wrong type for estimatesmartfee(options.fee_rate_estimator)32assert_raises_rpc_error(-3, "JSON value of type number for field fee_rate_estimator is not of expected type string", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {'fee_rate_estimator': 1})33# wrong type for estimatesmartfee(options.verbosity)34assert_raises_rpc_error(-3, "JSON value of type string for field verbosity is not of expected type number", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {'verbosity': 'foo'})35# wrong type for estimaterawfee(threshold)36assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 1, 'foo')38assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"', self.nodes[0].estimatesmartfee, 1, 'foo')39for fee_rate_estimator in ["foo", "none", ""]:40assert_raises_rpc_error(-8, 'Invalid fee_rate_estimator parameter, must be one of: "auto", "block_policy", "mempool_policy"',41self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {'fee_rate_estimator': fee_rate_estimator})42assert_raises_rpc_error(-8, "Unknown named parameter fee_rate_estimator", self.nodes[0].estimatesmartfee, 1, fee_rate_estimator=True)43assert_raises_rpc_error(-3, "Unexpected key block_policy_only", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {'block_policy_only': True})44# extra params45assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {}, 1)46assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', {'verbosity': 1}, 1)47assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee, 1, 1, 1)49# max value of 1008 per src/policy/fees/block_policy_estimator.h50assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008", self.nodes[0].estimaterawfee, 1009)52# valid calls53self.nodes[0].estimatesmartfee(1)54# self.nodes[0].estimatesmartfee(1, None)55self.nodes[0].estimatesmartfee(1, 'ECONOMICAL')56self.nodes[0].estimatesmartfee(1, 'unset')57self.nodes[0].estimatesmartfee(1, 'conservative')58self.nodes[0].estimatesmartfee(1, 'ECONOMICAL', {"fee_rate_estimator": "block_policy"})59self.nodes[0].estimatesmartfee(1, 'ECONOMICAL', {"fee_rate_estimator": "mempool_policy"})60self.nodes[0].estimatesmartfee(1, 'ECONOMICAL', {'verbosity': 1, 'fee_rate_estimator': "auto"})62self.nodes[0].estimaterawfee(1)63self.nodes[0].estimaterawfee(1, None)64self.nodes[0].estimaterawfee(1, 1)67if __name__ == '__main__':68EstimateFeeTest(__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.