Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/init.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2017 The Bitcoin Core developers | // Copyright (c) 2009-2017 The Bitcoin Core developers | ||||
// Copyright (c) 2018 The Bitcoin developers | // Copyright (c) 2018 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "wallet/init.h" | #include "wallet/init.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "net.h" | #include "net.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include "wallet/rpcwallet.h" | |||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
std::string GetWalletHelpString(bool showDebug) { | std::string GetWalletHelpString(bool showDebug) { | ||||
std::string strUsage = HelpMessageGroup(_("Wallet options:")); | std::string strUsage = HelpMessageGroup(_("Wallet options:")); | ||||
strUsage += HelpMessageOpt( | strUsage += HelpMessageOpt( | ||||
"-disablewallet", | "-disablewallet", | ||||
_("Do not load the wallet and disable wallet RPC calls")); | _("Do not load the wallet and disable wallet RPC calls")); | ||||
strUsage += HelpMessageOpt( | strUsage += HelpMessageOpt( | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | bool WalletParameterInteraction() { | ||||
nTxConfirmTarget = | nTxConfirmTarget = | ||||
gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); | gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); | ||||
bSpendZeroConfChange = | bSpendZeroConfChange = | ||||
gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); | gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); | ||||
return true; | return true; | ||||
} | } | ||||
bool WalletVerify(const CChainParams &chainParams) { | void RegisterWalletRPC(CRPCTable &t) { | ||||
if (gArgs.GetBoolArg("-disablewallet", false)) { | |||||
return; | |||||
} | |||||
RegisterWalletRPCCommands(t); | |||||
} | |||||
bool VerifyWallets(const CChainParams &chainParams) { | |||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
uiInterface.InitMessage(_("Verifying wallet(s)...")); | uiInterface.InitMessage(_("Verifying wallet(s)...")); | ||||
// Keep track of each wallet absolute path to detect duplicates. | // Keep track of each wallet absolute path to detect duplicates. | ||||
std::set<fs::path> wallet_paths; | std::set<fs::path> wallet_paths; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
InitError(strError); | InitError(strError); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool InitLoadWallet(const CChainParams &chainParams) { | bool OpenWallets(const CChainParams &chainParams) { | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
LogPrintf("Wallet disabled!\n"); | LogPrintf("Wallet disabled!\n"); | ||||
return true; | return true; | ||||
} | } | ||||
for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
CWallet *const pwallet = | CWallet *const pwallet = | ||||
CWallet::CreateWalletFromFile(chainParams, walletFile); | CWallet::CreateWalletFromFile(chainParams, walletFile); | ||||
if (!pwallet) { | if (!pwallet) { | ||||
return false; | return false; | ||||
} | } | ||||
vpwallets.push_back(pwallet); | vpwallets.push_back(pwallet); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void StartWallets(CScheduler &scheduler) { | |||||
for (CWalletRef pwallet : vpwallets) { | |||||
pwallet->postInitProcess(scheduler); | |||||
} | |||||
} | |||||
void FlushWallets() { | |||||
for (CWalletRef pwallet : vpwallets) { | |||||
pwallet->Flush(false); | |||||
} | |||||
} | |||||
void StopWallets() { | |||||
for (CWalletRef pwallet : vpwallets) { | |||||
pwallet->Flush(true); | |||||
} | |||||
} | |||||
void CloseWallets() { | |||||
for (CWalletRef pwallet : vpwallets) { | |||||
delete pwallet; | |||||
} | |||||
vpwallets.clear(); | |||||
} |