aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-11-05 13:17:01 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-11-05 13:17:03 +0100
commit46eb2755d456ca736c1cb7a0922bfece63c5151e (patch)
treee70dbc130a17b3ddd842ce8d47b671a6b31873bf /src/wallet/wallet.h
parent69d574ac6c24d85f1f1947bd67cb8c44c2a5f290 (diff)
parent65f3672f3b82a6fa30e5171f85bc8d8a29e0797e (diff)
downloadbitcoin-46eb2755d456ca736c1cb7a0922bfece63c5151e.tar.xz
Merge #14350: Add WalletLocation class
65f3672f3b82a6fa30e5171f85bc8d8a29e0797e wallet: Refactor to use WalletLocation (João Barbosa) 01a4c095c87500650663341533f000c6b613e9da wallet: Add WalletLocation utility class (João Barbosa) Pull request description: Advantages of this change: - avoid resolving wallet absolute path and name repetitively and in multiple places; - avoid calling `GetWalletDir` in multiple places; - extract these details from the actual wallet implementation. The `WalletLocation` class can be a way to represent a wallet not yet loaded that exists in the wallet directory. Tree-SHA512: 71ec09786e038499710e7acafe92d66ab9883fc894964e267443ae9c10a6872a10995c3987a169c436a4e793dae96b28fb97bd7f78483c4b72ac930fa23f8686
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 200564870b..74eaa09506 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -20,7 +20,7 @@
#include <wallet/crypter.h>
#include <wallet/coinselection.h>
#include <wallet/walletdb.h>
-#include <wallet/rpcwallet.h>
+#include <wallet/walletutil.h>
#include <algorithm>
#include <atomic>
@@ -676,12 +676,8 @@ private:
*/
bool AddWatchOnly(const CScript& dest) override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- /**
- * Wallet filename from wallet=<path> command line or config option.
- * Used in debug logs and to send RPCs to the right wallet instance when
- * more than one wallet is loaded.
- */
- std::string m_name;
+ /** Wallet location which includes wallet name (see WalletLocation). */
+ WalletLocation m_location;
/** Internal database handle. */
std::unique_ptr<WalletDatabase> database;
@@ -721,9 +717,11 @@ public:
bool SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet,
const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ const WalletLocation& GetLocation() const { return m_location; }
+
/** Get a name for this wallet for logging/debugging purposes.
*/
- const std::string& GetName() const { return m_name; }
+ const std::string& GetName() const { return m_location.GetName(); }
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
@@ -739,7 +737,7 @@ public:
unsigned int nMasterKeyMaxID = 0;
/** Construct wallet with specified name and database implementation. */
- CWallet(std::string name, std::unique_ptr<WalletDatabase> database) : m_name(std::move(name)), database(std::move(database))
+ CWallet(const WalletLocation& location, std::unique_ptr<WalletDatabase> database) : m_location(location), database(std::move(database))
{
}
@@ -1059,10 +1057,10 @@ public:
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
//! Verify wallet naming and perform salvage on the wallet if required
- static bool Verify(std::string wallet_file, bool salvage_wallet, std::string& error_string, std::string& warning_string);
+ static bool Verify(const WalletLocation& location, bool salvage_wallet, std::string& error_string, std::string& warning_string);
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
- static std::shared_ptr<CWallet> CreateWalletFromFile(const std::string& name, const fs::path& path, uint64_t wallet_creation_flags = 0);
+ static std::shared_ptr<CWallet> CreateWalletFromFile(const WalletLocation& location, uint64_t wallet_creation_flags = 0);
/**
* Wallet post-init setup