From 362ded410b8cb1104b7ef31ff8488fec4824a7d5 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Tue, 17 Sep 2019 19:05:26 -0400 Subject: Avoid using g_rpc_node global in wallet code Wallet code should use interfaces::Chain and not directly access to node state. Add a g_rpc_chain replacement global for wallet code to use, and move g_rpc_node definition to a libbitcoin_server source file so there are link errors if wallet code tries to access it. --- src/wallet/rpcwallet.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/wallet/rpcwallet.h') diff --git a/src/wallet/rpcwallet.h b/src/wallet/rpcwallet.h index 1c0523c90b..31d3f7a5f9 100644 --- a/src/wallet/rpcwallet.h +++ b/src/wallet/rpcwallet.h @@ -21,6 +21,12 @@ class Chain; class Handler; } +//! Pointer to chain interface that needs to be declared as a global to be +//! accessible loadwallet and createwallet methods. Due to limitations of the +//! 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>& handlers); /** -- cgit v1.2.3