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.cpp | 6 ++++-- src/wallet/rpcwallet.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 45c6e340c0..9050553a0e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2574,7 +2574,7 @@ static UniValue loadwallet(const JSONRPCRequest& request) std::string error; std::vector warning; - std::shared_ptr const wallet = LoadWallet(*g_rpc_node->chain, location, error, warning); + std::shared_ptr const wallet = LoadWallet(*g_rpc_chain, location, error, warning); if (!wallet) throw JSONRPCError(RPC_WALLET_ERROR, error); UniValue obj(UniValue::VOBJ); @@ -2700,7 +2700,7 @@ static UniValue createwallet(const JSONRPCRequest& request) std::string error; std::shared_ptr wallet; - WalletCreationStatus status = CreateWallet(*g_rpc_node->chain, passphrase, flags, request.params[0].get_str(), error, warnings, wallet); + WalletCreationStatus status = CreateWallet(*g_rpc_chain, passphrase, flags, request.params[0].get_str(), error, warnings, wallet); switch (status) { case WalletCreationStatus::CREATION_FAILED: throw JSONRPCError(RPC_WALLET_ERROR, error); @@ -4231,3 +4231,5 @@ void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector>& handlers); /** -- cgit v1.2.3