mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge #19096: Remove g_rpc_chain global
4a7253ab6cRemove g_rpc_chain global (Russell Yanofsky)e783197bf0refactor: replace RegisterWalletRPCCommands with GetWalletRPCCommands (Russell Yanofsky) Pull request description: Replace with RPC request reference to new WalletContext struct similar to the existing NodeContext struct and reference. This PR is a followup to #18740 removing the g_rpc_node global. Some later PRs will follow this up and move more wallet globals to the WalletContext struct. ACKs for top commit: MarcoFalke: ACK4a7253ab6c🎋 ariard: Code Review ACK4a7253a, feel free to ignore comment it's super nit. Tree-SHA512: 5bb5561c89f81811ca5232a58bf450e230d4218e62471c03227d142395fd36131672e99cb88329b33b9680a235db01e8b9d1c1e2a18288349e57205528deabab
This commit is contained in:
@@ -9,13 +9,16 @@
|
||||
#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>
|
||||
#include <ui_interface.h>
|
||||
#include <uint256.h>
|
||||
#include <util/check.h>
|
||||
#include <util/ref.h>
|
||||
#include <util/system.h>
|
||||
#include <wallet/context.h>
|
||||
#include <wallet/feebumper.h>
|
||||
#include <wallet/fees.h>
|
||||
#include <wallet/ismine.h>
|
||||
@@ -481,16 +484,21 @@ class WalletClientImpl : public ChainClient
|
||||
{
|
||||
public:
|
||||
WalletClientImpl(Chain& chain, std::vector<std::string> wallet_filenames)
|
||||
: m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
|
||||
: m_wallet_filenames(std::move(wallet_filenames))
|
||||
{
|
||||
m_context.chain = &chain;
|
||||
}
|
||||
void registerRpcs() override
|
||||
{
|
||||
g_rpc_chain = &m_chain;
|
||||
return RegisterWalletRPCCommands(m_chain, m_rpc_handlers);
|
||||
for (const CRPCCommand& command : GetWalletRPCCommands()) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
bool verify() override { return VerifyWallets(m_chain, m_wallet_filenames); }
|
||||
bool load() override { return LoadWallets(m_chain, m_wallet_filenames); }
|
||||
bool verify() override { return VerifyWallets(*m_context.chain, m_wallet_filenames); }
|
||||
bool load() override { return LoadWallets(*m_context.chain, m_wallet_filenames); }
|
||||
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
|
||||
void flush() override { return FlushWallets(); }
|
||||
void stop() override { return StopWallets(); }
|
||||
@@ -505,9 +513,10 @@ public:
|
||||
}
|
||||
~WalletClientImpl() override { UnloadWallets(); }
|
||||
|
||||
Chain& m_chain;
|
||||
WalletContext m_context;
|
||||
std::vector<std::string> m_wallet_filenames;
|
||||
std::vector<std::unique_ptr<Handler>> m_rpc_handlers;
|
||||
std::list<CRPCCommand> m_rpc_commands;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user