Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/init.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | bool WalletParameterInteraction() { | ||||
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | ||||
gArgs.SoftSetBoolArg("-walletbroadcast", false)) { | gArgs.SoftSetBoolArg("-walletbroadcast", false)) { | ||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting " | LogPrint(BCLog::WALLET, | ||||
"%s: parameter interaction: -blocksonly=1 -> setting " | |||||
"-walletbroadcast=0\n", | "-walletbroadcast=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
if (gArgs.GetBoolArg("-salvagewallet", false) && | if (gArgs.GetBoolArg("-salvagewallet", false) && | ||||
gArgs.SoftSetBoolArg("-rescan", true)) { | gArgs.SoftSetBoolArg("-rescan", true)) { | ||||
if (is_multiwallet) { | if (is_multiwallet) { | ||||
return InitError( | return InitError( | ||||
strprintf("%s is only allowed with a single wallet file", | strprintf("%s is only allowed with a single wallet file", | ||||
"-salvagewallet")); | "-salvagewallet")); | ||||
} | } | ||||
// Rewrite just private keys: rescan to find transactions | // Rewrite just private keys: rescan to find transactions | ||||
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting " | LogPrint(BCLog::WALLET, | ||||
"%s: parameter interaction: -salvagewallet=1 -> setting " | |||||
"-rescan=1\n", | "-rescan=1\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0); | int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0); | ||||
// -zapwallettxes implies dropping the mempool on startup | // -zapwallettxes implies dropping the mempool on startup | ||||
if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) { | if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) { | ||||
LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting " | LogPrint(BCLog::WALLET, | ||||
"%s: parameter interaction: -zapwallettxes=%s -> setting " | |||||
"-persistmempool=0\n", | "-persistmempool=0\n", | ||||
__func__, zapwallettxes); | __func__, zapwallettxes); | ||||
} | } | ||||
// -zapwallettxes implies a rescan | // -zapwallettxes implies a rescan | ||||
if (zapwallettxes != 0) { | if (zapwallettxes != 0) { | ||||
if (is_multiwallet) { | if (is_multiwallet) { | ||||
return InitError( | return InitError( | ||||
strprintf("%s is only allowed with a single wallet file", | strprintf("%s is only allowed with a single wallet file", | ||||
"-zapwallettxes")); | "-zapwallettxes")); | ||||
} | } | ||||
if (gArgs.SoftSetBoolArg("-rescan", true)) { | if (gArgs.SoftSetBoolArg("-rescan", true)) { | ||||
LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting " | LogPrint(BCLog::WALLET, | ||||
"%s: parameter interaction: -zapwallettxes=%s -> setting " | |||||
"-rescan=1\n", | "-rescan=1\n", | ||||
__func__, zapwallettxes); | __func__, zapwallettxes); | ||||
} | } | ||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting " | LogPrint(BCLog::WALLET, | ||||
"%s: parameter interaction: -zapwallettxes=<mode> -> setting " | |||||
"-rescan=1\n", | "-rescan=1\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
if (is_multiwallet) { | if (is_multiwallet) { | ||||
if (gArgs.GetBoolArg("-upgradewallet", false)) { | if (gArgs.GetBoolArg("-upgradewallet", false)) { | ||||
return InitError( | return InitError( | ||||
strprintf("%s is only allowed with a single wallet file", | strprintf("%s is only allowed with a single wallet file", | ||||
"-upgradewallet")); | "-upgradewallet")); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | for (const std::string &walletFile : gArgs.GetArgs("-wallet")) { | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool InitLoadWallet(const CChainParams &chainParams) { | bool InitLoadWallet(const CChainParams &chainParams) { | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
LogPrintf("Wallet disabled!\n"); | LogPrint(BCLog::WALLET, "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; | ||||
} | } |