refactor: replace RegisterWalletRPCCommands with GetWalletRPCCommands

pull/19096/head
Russell Yanofsky 5 years ago
parent 55b4c65bd1
commit e783197bf0

@ -9,6 +9,7 @@
#include <interfaces/handler.h>
#include <policy/fees.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <script/standard.h>
#include <support/allocators/secure.h>
#include <sync.h>
@ -487,7 +488,9 @@ public:
void registerRpcs() override
{
g_rpc_chain = &m_chain;
return RegisterWalletRPCCommands(m_chain, m_rpc_handlers);
for (const CRPCCommand& command : GetWalletRPCCommands()) {
m_rpc_handlers.emplace_back(m_chain.handleRpc(command));
}
}
bool verify() override { return VerifyWallets(m_chain, m_wallet_filenames); }
bool load() override { return LoadWallets(m_chain, m_wallet_filenames); }

@ -4263,7 +4263,7 @@ UniValue removeprunedfunds(const JSONRPCRequest& request);
UniValue importmulti(const JSONRPCRequest& request);
UniValue importdescriptors(const JSONRPCRequest& request);
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers)
Span<const CRPCCommand> GetWalletRPCCommands()
{
// clang-format off
static const CRPCCommand commands[] =
@ -4329,9 +4329,7 @@ static const CRPCCommand commands[] =
{ "wallet", "walletprocesspsbt", &walletprocesspsbt, {"psbt","sign","sighashtype","bip32derivs"} },
};
// clang-format on
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
handlers.emplace_back(chain.handleRpc(commands[vcidx]));
return MakeSpan(commands);
}
interfaces::Chain* g_rpc_chain = nullptr;

@ -5,11 +5,13 @@
#ifndef BITCOIN_WALLET_RPCWALLET_H
#define BITCOIN_WALLET_RPCWALLET_H
#include <span.h>
#include <memory>
#include <string>
#include <vector>
class CRPCTable;
class CRPCCommand;
class CWallet;
class JSONRPCRequest;
class LegacyScriptPubKeyMan;
@ -19,7 +21,6 @@ class CTransaction;
namespace interfaces {
class Chain;
class Handler;
}
//! Pointer to chain interface that needs to be declared as a global to be
@ -27,8 +28,7 @@ class Handler;
//! RPC framework, there's currently no direct way to pass in state to RPC
//! methods without globals.
extern interfaces::Chain* g_rpc_chain;
void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique_ptr<interfaces::Handler>>& handlers);
Span<const CRPCCommand> GetWalletRPCCommands();
/**
* Figures out what wallet, if any, to use for a JSONRPCRequest.

Loading…
Cancel
Save