From 58cfbc38e040925b51cb8d35d23b50e9cf06fb2a Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 20 Oct 2020 17:48:20 +0200 Subject: Ignoring (but warn) on duplicate -wallet parameters --- src/wallet/load.cpp | 8 ++++++-- test/functional/wallet_multiwallet.py | 4 ++-- 2 files changed, 8 insertions(+), 4 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 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; diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index 72e2108d59..3f6a17269e 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -134,8 +134,8 @@ class MultiWalletTest(BitcoinTestFramework): self.nodes[0].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" is a relative path', cwd=data_dir()) self.nodes[0].assert_start_raises_init_error(['-walletdir=debug.log'], 'Error: Specified -walletdir "debug.log" is not a directory', cwd=data_dir()) - # should not initialize if there are duplicate wallets - self.nodes[0].assert_start_raises_init_error(['-wallet=w1', '-wallet=w1'], 'Error: Error loading wallet w1. Duplicate -wallet filename specified.') + self.start_node(0, ['-wallet=w1', '-wallet=w1']) + self.stop_node(0, 'Warning: Ignoring duplicate -wallet w1.') if not self.options.descriptors: # 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 -- cgit v1.2.3