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.
1// Copyright (c) 2018-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <bitcoin-build-config.h> // IWYU pragma: keep7#include <external_signer.h>8#include <rpc/register.h> // IWYU pragma: associated10#include <common/args.h>11#include <rpc/protocol.h>12#include <rpc/request.h>13#include <rpc/server.h>14#include <rpc/util.h>15#include <univalue.h>17#include <exception>18#include <string>19#include <utility>20#include <vector>22#ifdef ENABLE_EXTERNAL_SIGNER24static RPCMethod enumeratesigners()25{26return RPCMethod{"enumeratesigners",27"Returns a list of external signers from -signer. Signers with duplicate master key fingerprints are skipped.",28{},29RPCResult{30RPCResult::Type::OBJ, "", "",31{32{RPCResult::Type::ARR, "signers", /*optional=*/false, "",33{34{RPCResult::Type::OBJ, "", "",35{36{RPCResult::Type::STR_HEX, "fingerprint", "Master key fingerprint"},37{RPCResult::Type::STR, "name", "Device name, the model returned by the signer"},38}},39},40}41}42},43RPCExamples{44HelpExampleCli("enumeratesigners", "")45+ HelpExampleRpc("enumeratesigners", "")46},47[](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue48{49const std::string command = gArgs.GetArg("-signer", "");50if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");51const std::string chain = gArgs.GetChainTypeString();52UniValue signers_res = UniValue::VARR;53try {54std::vector<ExternalSigner> signers;55ExternalSigner::Enumerate(command, signers, chain);56for (const ExternalSigner& signer : signers) {57UniValue signer_res = UniValue::VOBJ;58signer_res.pushKV("fingerprint", signer.m_fingerprint);59signer_res.pushKV("name", signer.m_name);60signers_res.push_back(std::move(signer_res));61}62} catch (const std::exception& e) {63throw JSONRPCError(RPC_MISC_ERROR, e.what());64}65UniValue result(UniValue::VOBJ);66result.pushKV("signers", std::move(signers_res));67return result;68}69};70}72void RegisterSignerRPCCommands(CRPCTable& t)73{74static const CRPCCommand commands[]{75{"signer", &enumeratesigners},76};77for (const auto& c : commands) {78t.appendCommand(c.name, &c);79}80}82#endif // ENABLE_EXTERNAL_SIGNER