/
githubmirror
/
bitcoin
Обзор
Документация
Войти
/
githubmirror
/
bitcoin
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/rpc/external_signer.cpp
78 строк
3 KB
woltx
doc, rpc: document enumerate model field and fingerprint deduplication
11 июн 2026, 20:32
11 июн 2026, 20:32
fab9225
Код
Авторство
О чём код?
// Copyright (c) 2018-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <bitcoin-build-config.h> // IWYU pragma: keep #include <common/args.h> #include <common/system.h> #include <external_signer.h> #include <rpc/protocol.h> #include <rpc/server.h> #include <rpc/util.h> #include <util/strencodings.h> #include <string> #include <vector> #ifdef ENABLE_EXTERNAL_SIGNER static RPCMethod enumeratesigners() { return RPCMethod{"enumeratesigners", "Returns a list of external signers from -signer. Signers with duplicate master key fingerprints are skipped.", {}, RPCResult{ RPCResult::Type::OBJ, "", "", { {RPCResult::Type::ARR, "signers", /*optional=*/false, "", { {RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR_HEX, "fingerprint", "Master key fingerprint"}, {RPCResult::Type::STR, "name", "Device name, the model returned by the signer"}, }}, }, } } }, RPCExamples{ HelpExampleCli("enumeratesigners", "") + HelpExampleRpc("enumeratesigners", "") }, [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue { const std::string command = gArgs.GetArg("-signer", ""); if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>"); const std::string chain = gArgs.GetChainTypeString(); UniValue signers_res = UniValue::VARR; try { std::vector<ExternalSigner> signers; ExternalSigner::Enumerate(command, signers, chain); for (const ExternalSigner& signer : signers) { UniValue signer_res = UniValue::VOBJ; signer_res.pushKV("fingerprint", signer.m_fingerprint); signer_res.pushKV("name", signer.m_name); signers_res.push_back(std::move(signer_res)); } } catch (const std::exception& e) { throw JSONRPCError(RPC_MISC_ERROR, e.what()); } UniValue result(UniValue::VOBJ); result.pushKV("signers", std::move(signers_res)); return result; } }; } void RegisterSignerRPCCommands(CRPCTable& t) { static const CRPCCommand commands[]{ {"signer", &enumeratesigners}, }; for (const auto& c : commands) { t.appendCommand(c.name, &c); } } #endif // ENABLE_EXTERNAL_SIGNER