From a4356328e00155796cd7aa188e96c51c09562423 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 6 Jan 2017 17:53:06 +0000 Subject: [PATCH] Move wallet RPC declarations to rpcwallet.h --- src/rpc/misc.cpp | 4 ++++ src/rpc/rawtransaction.cpp | 1 + src/rpc/server.h | 11 ----------- src/wallet/rpcdump.cpp | 2 ++ src/wallet/rpcwallet.h | 13 +++++++++++++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index fe46f61d8..e543781e7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -14,6 +14,7 @@ #include "util.h" #include "utilstrencodings.h" #ifdef ENABLE_WALLET +#include "wallet/rpcwallet.h" #include "wallet/wallet.h" #include "wallet/walletdb.h" #endif @@ -234,6 +235,9 @@ UniValue validateaddress(const JSONRPCRequest& request) return ret; } +// Needed even with !ENABLE_WALLET, to pass (ignored) pointers around +class CWallet; + /** * Used by addmultisigaddress / createmultisig: */ diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index ce7afcbe5..79b27d047 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -24,6 +24,7 @@ #include "uint256.h" #include "utilstrencodings.h" #ifdef ENABLE_WALLET +#include "wallet/rpcwallet.h" #include "wallet/wallet.h" #endif diff --git a/src/rpc/server.h b/src/rpc/server.h index 0850f68f1..68d8a6ec9 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -196,17 +196,6 @@ extern double GetDifficulty(const CBlockIndex* blockindex = NULL); extern std::string HelpExampleCli(const std::string& methodname, const std::string& args); extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args); -// Needed even with !ENABLE_WALLET, to pass (ignored) pointers around -class CWallet; - -#ifdef ENABLE_WALLET -// New code should accessing the wallet should be under the ../wallet/ directory -CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest&); -std::string HelpRequiringPassphrase(CWallet *); -void EnsureWalletIsUnlocked(CWallet *); -bool EnsureWalletIsAvailable(CWallet *, bool avoidException); -#endif - bool StartRPC(); void InterruptRPC(); void StopRPC(); diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 8f7393245..e4d4d6b36 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -16,6 +16,8 @@ #include "merkleblock.h" #include "core_io.h" +#include "rpcwallet.h" + #include #include diff --git a/src/wallet/rpcwallet.h b/src/wallet/rpcwallet.h index 3a68ccf1b..bd5dad18c 100644 --- a/src/wallet/rpcwallet.h +++ b/src/wallet/rpcwallet.h @@ -6,7 +6,20 @@ #define BITCOIN_WALLET_RPCWALLET_H class CRPCTable; +class JSONRPCRequest; void RegisterWalletRPCCommands(CRPCTable &t); +/** + * Figures out what wallet, if any, to use for a JSONRPCRequest. + * + * @param[in] request JSONRPCRequest that wishes to access a wallet + * @return NULL if no wallet should be used, or a pointer to the CWallet + */ +CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest&); + +std::string HelpRequiringPassphrase(CWallet *); +void EnsureWalletIsUnlocked(CWallet *); +bool EnsureWalletIsAvailable(CWallet *, bool avoidException); + #endif //BITCOIN_WALLET_RPCWALLET_H