diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -66,6 +66,9 @@ static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; static const bool DEFAULT_WALLETBROADCAST = true; static const bool DEFAULT_DISABLE_WALLET = false; +//! -walletallowsymboliclink default +static const bool DEFAULT_WALLET_ALLOW_SYMBOLIC_LINK = false; + //! if set, all keys will be derived by using BIP32 static const bool DEFAULT_USE_HD_WALLET = true; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4,7 +4,6 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "wallet/wallet.h" - #include "chain.h" #include "checkpoints.h" #include "config.h" @@ -209,17 +208,15 @@ // child-index-range // example: 1 | BIP32_HARDENED_KEY_LIMIT == 0x80000001 == 2147483649 if (internal) { - chainChildKey.Derive(childKey, - hdChain.nInternalChainCounter | - BIP32_HARDENED_KEY_LIMIT); + chainChildKey.Derive(childKey, hdChain.nInternalChainCounter | + BIP32_HARDENED_KEY_LIMIT); metadata.hdKeypath = "m/0'/1'/" + std::to_string(hdChain.nInternalChainCounter) + "'"; hdChain.nInternalChainCounter++; } else { - chainChildKey.Derive(childKey, - hdChain.nExternalChainCounter | - BIP32_HARDENED_KEY_LIMIT); + chainChildKey.Derive(childKey, hdChain.nExternalChainCounter | + BIP32_HARDENED_KEY_LIMIT); metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'"; @@ -575,6 +572,11 @@ dbw->Flush(shutdown); } +static bool allowSymbolicLink() { + return gArgs.GetBoolArg("-walletallowsymboliclink", + DEFAULT_WALLET_ALLOW_SYMBOLIC_LINK); +} + bool CWallet::Verify(const CChainParams &chainParams) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return true; @@ -600,9 +602,10 @@ } fs::path wallet_path = fs::absolute(walletFile, GetDataDir()); + if (fs::exists(wallet_path) && + (!fs::is_regular_file(wallet_path) || + (fs::is_symlink(wallet_path) && !allowSymbolicLink()))) { - if (fs::exists(wallet_path) && (!fs::is_regular_file(wallet_path) || - fs::is_symlink(wallet_path))) { return InitError(strprintf(_("Error loading wallet %s. -wallet " "filename must be a regular file."), walletFile)); @@ -4071,6 +4074,12 @@ HelpMessageOpt("-wallet=", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); + + strUsage += HelpMessageOpt( + "-walletallowsymboliclink", + strprintf(_("Allow symbolic link for wallet (default: %u)"), + DEFAULT_WALLET_ALLOW_SYMBOLIC_LINK)); + strUsage += HelpMessageOpt( "-walletbroadcast", _("Make the wallet broadcast transactions") + " " +