mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
This is a follow-up to previous commits moving the chain constants out of chainparamsbase. The script removes the chainparamsbase header in all files where it is included, but not used. This is done by filtering against all defined symbols of the header as well as its respective .cpp file. The kernel chainparams now no longer relies on chainparamsbase. -BEGIN VERIFY SCRIPT- sed -i '/#include <chainparamsbase.h>/d' $( git grep -l 'chainparamsbase.h' | xargs grep -L 'CBaseChainParams\|CreateBaseChainParams\|SetupChainParamsBaseOptions\|BaseParams\|SelectBaseParams\|chainparamsbase.cpp' ) -END VERIFY SCRIPT-
77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
// Copyright (c) 2018-2022 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 <common/args.h>
|
|
#include <external_signer.h>
|
|
#include <rpc/protocol.h>
|
|
#include <rpc/server.h>
|
|
#include <rpc/util.h>
|
|
#include <util/strencodings.h>
|
|
#include <util/system.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
|
|
|
static RPCHelpMan enumeratesigners()
|
|
{
|
|
return RPCHelpMan{"enumeratesigners",
|
|
"Returns a list of external signers from -signer.",
|
|
{},
|
|
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"},
|
|
}},
|
|
},
|
|
}
|
|
}
|
|
},
|
|
RPCExamples{
|
|
HelpExampleCli("enumeratesigners", "")
|
|
+ HelpExampleRpc("enumeratesigners", "")
|
|
},
|
|
[&](const RPCHelpMan& 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(signer_res);
|
|
}
|
|
} catch (const std::exception& e) {
|
|
throw JSONRPCError(RPC_MISC_ERROR, e.what());
|
|
}
|
|
UniValue result(UniValue::VOBJ);
|
|
result.pushKV("signers", 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
|