mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 16:34:22 +01:00
rpc: add external signer RPC files
This commit is contained in:
parent
8ce7767071
commit
07b7c940a7
5 changed files with 82 additions and 1 deletions
|
@ -271,6 +271,7 @@ BITCOIN_CORE_H = \
|
||||||
wallet/fees.h \
|
wallet/fees.h \
|
||||||
wallet/ismine.h \
|
wallet/ismine.h \
|
||||||
wallet/load.h \
|
wallet/load.h \
|
||||||
|
wallet/rpcsigner.h \
|
||||||
wallet/rpcwallet.h \
|
wallet/rpcwallet.h \
|
||||||
wallet/salvage.h \
|
wallet/salvage.h \
|
||||||
wallet/scriptpubkeyman.h \
|
wallet/scriptpubkeyman.h \
|
||||||
|
@ -388,6 +389,7 @@ libbitcoin_wallet_a_SOURCES = \
|
||||||
wallet/interfaces.cpp \
|
wallet/interfaces.cpp \
|
||||||
wallet/load.cpp \
|
wallet/load.cpp \
|
||||||
wallet/rpcdump.cpp \
|
wallet/rpcdump.cpp \
|
||||||
|
wallet/rpcsigner.cpp \
|
||||||
wallet/rpcwallet.cpp \
|
wallet/rpcwallet.cpp \
|
||||||
wallet/scriptpubkeyman.cpp \
|
wallet/scriptpubkeyman.cpp \
|
||||||
wallet/wallet.cpp \
|
wallet/wallet.cpp \
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <wallet/fees.h>
|
#include <wallet/fees.h>
|
||||||
#include <wallet/ismine.h>
|
#include <wallet/ismine.h>
|
||||||
#include <wallet/load.h>
|
#include <wallet/load.h>
|
||||||
|
#include <wallet/rpcsigner.h>
|
||||||
#include <wallet/rpcwallet.h>
|
#include <wallet/rpcwallet.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
|
@ -518,6 +519,15 @@ public:
|
||||||
}, command.argNames, command.unique_id);
|
}, command.argNames, command.unique_id);
|
||||||
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
|
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||||
|
for (const CRPCCommand& command : GetSignerRPCCommands()) {
|
||||||
|
m_rpc_commands.emplace_back(command.category, command.name, [this, &command](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
|
||||||
|
return command.actor({request, m_context}, result, last_handler);
|
||||||
|
}, command.argNames, command.unique_id);
|
||||||
|
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
bool verify() override { return VerifyWallets(*m_context.chain); }
|
bool verify() override { return VerifyWallets(*m_context.chain); }
|
||||||
bool load() override { return LoadWallets(*m_context.chain); }
|
bool load() override { return LoadWallets(*m_context.chain); }
|
||||||
|
|
41
src/wallet/rpcsigner.cpp
Normal file
41
src/wallet/rpcsigner.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright (c) 2018-2021 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 <rpc/server.h>
|
||||||
|
#include <util/strencodings.h>
|
||||||
|
#include <wallet/rpcsigner.h>
|
||||||
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||||
|
|
||||||
|
// CRPCCommand table won't compile with an empty array
|
||||||
|
static RPCHelpMan dummy()
|
||||||
|
{
|
||||||
|
return RPCHelpMan{"dummy",
|
||||||
|
"\nDoes nothing.\n"
|
||||||
|
"",
|
||||||
|
{},
|
||||||
|
RPCResult{RPCResult::Type::NONE, "", ""},
|
||||||
|
RPCExamples{""},
|
||||||
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
|
{
|
||||||
|
return NullUniValue;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Span<const CRPCCommand> GetSignerRPCCommands()
|
||||||
|
{
|
||||||
|
// clang-format off
|
||||||
|
static const CRPCCommand commands[] =
|
||||||
|
{ // category actor (function)
|
||||||
|
// --------------------- ------------------------
|
||||||
|
{ "signer", &dummy, },
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
return MakeSpan(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ENABLE_EXTERNAL_SIGNER
|
25
src/wallet/rpcsigner.h
Normal file
25
src/wallet/rpcsigner.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) 2018-2021 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_WALLET_RPCSIGNER_H
|
||||||
|
#define BITCOIN_WALLET_RPCSIGNER_H
|
||||||
|
|
||||||
|
#include <span.h>
|
||||||
|
#include <util/system.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||||
|
|
||||||
|
class CRPCCommand;
|
||||||
|
|
||||||
|
namespace interfaces {
|
||||||
|
class Chain;
|
||||||
|
class Handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
Span<const CRPCCommand> GetSignerRPCCommands();
|
||||||
|
|
||||||
|
#endif // ENABLE_EXTERNAL_SIGNER
|
||||||
|
|
||||||
|
#endif //BITCOIN_WALLET_RPCSIGNER_H
|
|
@ -105,10 +105,13 @@ class HelpRpcTest(BitcoinTestFramework):
|
||||||
if self.is_wallet_compiled():
|
if self.is_wallet_compiled():
|
||||||
components.append('Wallet')
|
components.append('Wallet')
|
||||||
|
|
||||||
|
if self.is_external_signer_compiled():
|
||||||
|
components.append('Signer')
|
||||||
|
|
||||||
if self.is_zmq_compiled():
|
if self.is_zmq_compiled():
|
||||||
components.append('Zmq')
|
components.append('Zmq')
|
||||||
|
|
||||||
assert_equal(titles, components)
|
assert_equal(titles, sorted(components))
|
||||||
|
|
||||||
def dump_help(self):
|
def dump_help(self):
|
||||||
dump_dir = os.path.join(self.options.tmpdir, 'rpc_help_dump')
|
dump_dir = os.path.join(self.options.tmpdir, 'rpc_help_dump')
|
||||||
|
|
Loading…
Add table
Reference in a new issue