Skip to content

Commit 83650e4

Browse files
author
MarcoFalke
committed
Merge bitcoin#20199: wallet: ignore (but warn) on duplicate -wallet parameters
58cfbc3 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 58cfbc3 meshcollider: Code review ACK 58cfbc3 ryanofsky: Code review ACK 58cfbc3. Changes since previous review: rebased, tweaked warning message, squashed/fixed test Tree-SHA512: f94e5a999bdd7dc291f0bc142911b0a8033929350d6f6a35b58c4a06a3c8f83147be0f0c402d4e946dedbbcc85b7e023b672c731b6d7a8984d4780017c961cfb
2 parents 6760088 + 58cfbc3 commit 83650e4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/wallet/load.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ bool VerifyWallets(interfaces::Chain& chain)
6565
const fs::path path = fs::absolute(wallet_file, GetWalletDir());
6666

6767
if (!wallet_paths.insert(path).second) {
68-
chain.initError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified."), wallet_file));
69-
return false;
68+
chain.initWarning(strprintf(_("Ignoring duplicate -wallet %s."), wallet_file));
69+
continue;
7070
}
7171

7272
DatabaseOptions options;
@@ -90,7 +90,11 @@ bool VerifyWallets(interfaces::Chain& chain)
9090
bool LoadWallets(interfaces::Chain& chain)
9191
{
9292
try {
93+
std::set<fs::path> wallet_paths;
9394
for (const std::string& name : gArgs.GetArgs("-wallet")) {
95+
if (!wallet_paths.insert(name).second) {
96+
continue;
97+
}
9498
DatabaseOptions options;
9599
DatabaseStatus status;
96100
options.require_existing = true;

test/functional/wallet_multiwallet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def wallet_file(name):
134134
self.nodes[0].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" is a relative path', cwd=data_dir())
135135
self.nodes[0].assert_start_raises_init_error(['-walletdir=debug.log'], 'Error: Specified -walletdir "debug.log" is not a directory', cwd=data_dir())
136136

137-
# should not initialize if there are duplicate wallets
138-
self.nodes[0].assert_start_raises_init_error(['-wallet=w1', '-wallet=w1'], 'Error: Error loading wallet w1. Duplicate -wallet filename specified.')
137+
self.start_node(0, ['-wallet=w1', '-wallet=w1'])
138+
self.stop_node(0, 'Warning: Ignoring duplicate -wallet w1.')
139139

140140
if not self.options.descriptors:
141141
# Only BDB doesn't open duplicate wallet files. SQLite does not have this limitation. While this may be desired in the future, it is not necessary

0 commit comments

Comments
 (0)