Inside Bitcoin
Opening the selected file…
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.
251{ "send", 0, "outputs" },252{ "send", 1, "conf_target" },253{ "send", 3, "fee_rate"},254{ "send", 4, "options" },255{ "send", 4, "add_inputs"},256{ "send", 4, "include_unsafe"},257{ "send", 4, "minconf"},258{ "send", 4, "maxconf"},259{ "send", 4, "add_to_wallet"},260{ "send", 4, "change_position"},261{ "send", 4, "fee_rate"},262{ "send", 4, "include_watching"},263{ "send", 4, "inputs"},264{ "send", 4, "locktime"},265{ "send", 4, "lock_unspents"},266{ "send", 4, "psbt"},267{ "send", 4, "subtract_fee_from_outputs"},268{ "send", 4, "conf_target"},269{ "send", 4, "replaceable"},270{ "send", 4, "solving_data"},271{ "send", 4, "max_tx_weight"},272{ "send", 5, "version"},273{ "sendall", 0, "recipients" },274{ "sendall", 1, "conf_target" },275{ "sendall", 3, "fee_rate"},276{ "sendall", 4, "options" },277{ "sendall", 4, "add_to_wallet"},278{ "sendall", 4, "fee_rate"},279{ "sendall", 4, "include_watching"},280{ "sendall", 4, "inputs"},281{ "sendall", 4, "locktime"},282{ "sendall", 4, "lock_unspents"},283{ "sendall", 4, "psbt"},284{ "sendall", 4, "send_max"},285{ "sendall", 4, "minconf"},286{ "sendall", 4, "maxconf"},287{ "sendall", 4, "conf_target"},288{ "sendall", 4, "replaceable"},289{ "sendall", 4, "solving_data"},290{ "sendall", 4, "version"},291{ "simulaterawtransaction", 0, "rawtxs" },292{ "simulaterawtransaction", 1, "options" },293{ "simulaterawtransaction", 1, "include_watchonly"},294{ "importmempool", 0, "filepath", ParamFormat::STRING },295{ "importmempool", 1, "options" },296{ "importmempool", 1, "apply_fee_delta_priority" },297{ "importmempool", 1, "use_current_time" },298{ "importmempool", 1, "apply_unbroadcast_set" },299{ "importdescriptors", 0, "requests" },300{ "listdescriptors", 0, "private" },301{ "verifychain", 0, "checklevel" },302{ "verifychain", 1, "nblocks" },303{ "getblockstats", 0, "hash_or_height", ParamFormat::JSON_OR_STRING },304{ "getblockstats", 1, "stats" },305{ "pruneblockchain", 0, "height" },306{ "keypoolrefill", 0, "newsize" },307{ "getrawmempool", 0, "verbose" },308{ "getrawmempool", 1, "mempool_sequence" },309{ "getorphantxs", 0, "verbosity" },310{ "estimatesmartfee", 0, "conf_target" },311{ "estimatesmartfee", 2, "options" },312{ "estimaterawfee", 0, "conf_target" },313{ "estimaterawfee", 1, "threshold" },314{ "prioritisetransaction", 1, "dummy" },315{ "prioritisetransaction", 2, "fee_delta" },316{ "setban", 2, "bantime" },317{ "setban", 3, "absolute" },318{ "setnetworkactive", 0, "state" },319{ "setwalletflag", 1, "value" },320{ "getmempoolancestors", 1, "verbose" },321{ "getmempooldescendants", 1, "verbose" },322{ "gettxspendingprevout", 0, "outputs" },323{ "gettxspendingprevout", 1, "options" },324{ "gettxspendingprevout", 1, "mempool_only" },325{ "gettxspendingprevout", 1, "return_spending_tx" },326{ "bumpfee", 1, "options" },327{ "bumpfee", 1, "conf_target"},328{ "bumpfee", 1, "fee_rate"},329{ "bumpfee", 1, "replaceable"},330{ "bumpfee", 1, "outputs"},331{ "bumpfee", 1, "original_change_index"},332{ "psbtbumpfee", 1, "options" },333{ "psbtbumpfee", 1, "conf_target"},334{ "psbtbumpfee", 1, "fee_rate"},335{ "psbtbumpfee", 1, "replaceable"},336{ "psbtbumpfee", 1, "outputs"},337{ "psbtbumpfee", 1, "original_change_index"},338{ "psbtbumpfee", 1, "psbt_version"},339{ "logging", 0, "include" },340{ "logging", 1, "exclude" },341{ "disconnectnode", 1, "nodeid" },342{ "getopenrpcinfo", 0, "show_hidden" },343{ "gethdkeys", 0, "active_only" },344{ "gethdkeys", 0, "options" },345{ "gethdkeys", 0, "private" },346{ "derivehdkey", 1, "options" },347{ "derivehdkey", 1, "private" },348{ "createwalletdescriptor", 1, "options" },349{ "createwalletdescriptor", 1, "internal" },350// Echo with conversion (For testing only)351{ "echojson", 0, "arg0" },352{ "echojson", 1, "arg1" },353{ "echojson", 2, "arg2" },354{ "echojson", 3, "arg3" },355{ "echojson", 4, "arg4" },356{ "echojson", 5, "arg5" },357{ "echojson", 6, "arg6" },358{ "echojson", 7, "arg7" },359{ "echojson", 8, "arg8" },360{ "echojson", 9, "arg9" },361{ "rescanblockchain", 0, "start_height"},362{ "rescanblockchain", 1, "stop_height"},363{ "createwallet", 0, "wallet_name", ParamFormat::STRING },364{ "createwallet", 1, "disable_private_keys"},365{ "createwallet", 2, "blank"},366{ "createwallet", 3, "passphrase", ParamFormat::STRING },367{ "createwallet", 4, "avoid_reuse"},368{ "createwallet", 5, "descriptors"},369{ "createwallet", 6, "load_on_startup"},370{ "createwallet", 7, "external_signer"},371{ "restorewallet", 0, "wallet_name", ParamFormat::STRING },372{ "restorewallet", 1, "backup_file", ParamFormat::STRING },373{ "restorewallet", 2, "load_on_startup"},374{ "loadwallet", 0, "filename", ParamFormat::STRING },375{ "loadwallet", 1, "load_on_startup"},376{ "unloadwallet", 0, "wallet_name", ParamFormat::STRING },377{ "unloadwallet", 1, "load_on_startup"},378{ "getnodeaddresses", 0, "count"},379{ "addpeeraddress", 1, "port"},380{ "addpeeraddress", 2, "tried"},381{ "sendmsgtopeer", 0, "peer_id" },382{ "stop", 0, "wait" },383{ "addnode", 2, "v2transport" },384{ "addconnection", 2, "v2transport" },385{ "decodepsbt", 0, "psbt", ParamFormat::STRING },386{ "analyzepsbt", 0, "psbt", ParamFormat::STRING},387{ "verifymessage", 1, "signature", ParamFormat::STRING },388{ "verifymessage", 2, "message", ParamFormat::STRING },389{ "getnewaddress", 0, "label", ParamFormat::STRING },390{ "getnewaddress", 1, "address_type", ParamFormat::STRING },391{ "backupwallet", 0, "destination", ParamFormat::STRING },392{ "echoipc", 0, "arg", ParamFormat::STRING },393{ "encryptwallet", 0, "passphrase", ParamFormat::STRING },394{ "getaddressesbylabel", 0, "label", ParamFormat::STRING },395{ "loadtxoutset", 0, "path", ParamFormat::STRING },396{ "migratewallet", 0, "wallet_name", ParamFormat::STRING },397{ "migratewallet", 1, "passphrase", ParamFormat::STRING },398{ "migratewallet", 2, "load_wallet"},399{ "setlabel", 1, "label", ParamFormat::STRING },400{ "signmessage", 1, "message", ParamFormat::STRING },401{ "signmessagewithprivkey", 1, "message", ParamFormat::STRING },402{ "walletpassphrasechange", 0, "oldpassphrase", ParamFormat::STRING },403{ "walletpassphrasechange", 1, "newpassphrase", ParamFormat::STRING },404};405// clang-format on407/** Parse string to UniValue or throw runtime_error if string contains invalid JSON */408static UniValue Parse(std::string_view raw, ParamFormat format = ParamFormat::JSON)409{410UniValue parsed;411if (!parsed.read(raw)) {412if (format != ParamFormat::JSON_OR_STRING) throw std::runtime_error(tfm::format("Error parsing JSON: %s", raw));413return UniValue(std::string(raw));414}415return parsed;416}418namespace rpc_convert419{420const CRPCConvertParam* FromPosition(std::string_view method, size_t pos)421{422auto it = std::ranges::find_if(vRPCConvertParams, [&](const auto& p) {423return p.methodName == method && p.paramIdx == static_cast<int>(pos);424});426return it == std::end(vRPCConvertParams) ? nullptr : &*it;427}429const CRPCConvertParam* FromName(std::string_view method, std::string_view name)430{431auto it = std::ranges::find_if(vRPCConvertParams, [&](const auto& p) {432return p.methodName == method && p.paramName == name;433});435return it == std::end(vRPCConvertParams) ? nullptr : &*it;436}437} // namespace rpc_convert439static UniValue ParseParam(const CRPCConvertParam* param, std::string_view raw)440{441// Only parse parameters which have the JSON or JSON_OR_STRING format; otherwise, treat them as strings.442return (param && (param->format == ParamFormat::JSON || param->format == ParamFormat::JSON_OR_STRING)) ? Parse(raw, param->format) : UniValue(std::string(raw));443}445/**446* Convert command lines arguments to params object when -named is disabled.447*/448UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)449{450UniValue params(UniValue::VARR);452for (std::string_view s : strParams) {453params.push_back(ParseParam(rpc_convert::FromPosition(strMethod, params.size()), s));454}456return params;457}459/**460* Convert command line arguments to params object when -named is enabled.461*462* The -named syntax accepts named arguments in NAME=VALUE format, as well as463* positional arguments without names. The syntax is inherently ambiguous if464* names are omitted and values contain '=', so a heuristic is used to465* disambiguate:466*467* - Arguments that do not contain '=' are treated as positional parameters.468*469* - Arguments that do contain '=' are assumed to be named parameters in470* NAME=VALUE format except for two special cases:471*472* 1. The case where NAME is not a known parameter name, and the next473* positional parameter requires a JSON value, and the argument parses as474* JSON. E.g. ["list", "with", "="].475*476* 2. The case where NAME is not a known parameter name and the next477* positional parameter requires a string value. E.g. "my=wallet".478*479* For example, the command `bitcoin-cli -named createwallet "my=wallet"`,480* the parser initially sees "my=wallet" and attempts to process it as a481* parameter named "my". When it finds that "my" is not a valid named parameter482* parameter for this method, it falls back to checking the rule for the483* next available positional parameter (index 0). Because it finds the rule484* that this parameter is a ParamFormat::STRING, it correctly treats the entire485* "my=wallet" as a single positional string, successfully creating a486* wallet with that literal name.487*/488UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<std::string> &strParams)489{490UniValue params(UniValue::VOBJ);491UniValue positional_args{UniValue::VARR};493for (std::string_view s: strParams) {494size_t pos = s.find('=');495if (pos == std::string_view::npos) {496positional_args.push_back(ParseParam(rpc_convert::FromPosition(strMethod, positional_args.size()), s));497continue;498}500std::string name{s.substr(0, pos)};