aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-11-05 07:50:51 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-11-05 07:51:07 +0100
commit83650e4df5caac2dbe734f9021430e525d5cc6a5 (patch)
tree5d7bc780d7da160ac20b3930e1e445cb207c0206 /src
parent67600880159a8a00393ea4969288393a7dfc514d (diff)
parent58cfbc38e040925b51cb8d35d23b50e9cf06fb2a (diff)
downloadbitcoin-83650e4df5caac2dbe734f9021430e525d5cc6a5.tar.xz
Merge #20199: wallet: ignore (but warn) on duplicate -wallet parameters
58cfbc38e040925b51cb8d35d23b50e9cf06fb2a Ignoring (but warn) on duplicate -wallet parameters (Jonas Schnelli) Pull request description: I expect that there are many users with load on startup wallet definitions in `bitcoin.conf` or via startup CLI argument. With the new `settings.json` r/w configuration file, users unloading and loading a wallet through the GUI or via the RPC calls might end up with a duplicate `-wallet` entry (one that still remains in bitcoin.conf or CLI) plus the new duplication in `settings.json` due to the unload/load. Steps to reproduce * create wallet (if via RPC set `load_on_startup` or unloadwallet/loadwallet then set `load_on_startup`). * stop bitcoin * start bitcoind again with same `--wallet=mywallet` I guess it is acceptable to skip duplicates. ACKs for top commit: achow101: Tested ACK 58cfbc38e040925b51cb8d35d23b50e9cf06fb2a meshcollider: Code review ACK 58cfbc38e040925b51cb8d35d23b50e9cf06fb2a ryanofsky: Code review ACK 58cfbc38e040925b51cb8d35d23b50e9cf06fb2a. Changes since previous review: rebased, tweaked warning message, squashed/fixed test Tree-SHA512: f94e5a999bdd7dc291f0bc142911b0a8033929350d6f6a35b58c4a06a3c8f83147be0f0c402d4e946dedbbcc85b7e023b672c731b6d7a8984d4780017c961cfb
Diffstat (limited to 'src')
-rw-r--r--src/wallet/load.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
index 1cdcb35fc7..036fd4956f 100644
--- a/src/wallet/load.cpp
+++ b/src/wallet/load.cpp
@@ -65,8 +65,8 @@ bool VerifyWallets(interfaces::Chain& chain)
const fs::path path = fs::absolute(wallet_file, GetWalletDir());
if (!wallet_paths.insert(path).second) {
- chain.initError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified."), wallet_file));
- return false;
+ chain.initWarning(strprintf(_("Ignoring duplicate -wallet %s."), wallet_file));
+ continue;
}
DatabaseOptions options;
@@ -90,7 +90,11 @@ bool VerifyWallets(interfaces::Chain& chain)
bool LoadWallets(interfaces::Chain& chain)
{
try {
+ std::set<fs::path> wallet_paths;
for (const std::string& name : gArgs.GetArgs("-wallet")) {
+ if (!wallet_paths.insert(name).second) {
+ continue;
+ }
DatabaseOptions options;
DatabaseStatus status;
options.require_existing = true;