Also, is there any reason to pass a shared_ptr, when a reference suffices?
Suggested diff for first commit:
0diff --git a/src/wallet/dump.cpp b/src/wallet/dump.cpp
1index 242d8dc31c..2e366b2a19 100644
2--- a/src/wallet/dump.cpp
3+++ b/src/wallet/dump.cpp
4@@ -2,13 +2,15 @@
5 // Distributed under the MIT software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7
8+#include <wallet/dump.h>
9+
10 #include <util/translation.h>
11 #include <wallet/wallet.h>
12
13 static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
14 uint32_t DUMP_VERSION = 1;
15
16-bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
17+bool DumpWallet(CWallet& wallet, bilingual_str& error)
18 {
19 // Get the dumpfile
20 std::string dump_filename = gArgs.GetArg("-dumpfile", "");
21@@ -32,7 +34,7 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
22
23 CHashWriter hasher(0, 0);
24
25- WalletDatabase& db = wallet->GetDatabase();
26+ WalletDatabase& db = wallet.GetDatabase();
27 std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
28
29 bool ret = true;
30@@ -52,7 +54,6 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
31 hasher.write(line.data(), line.size());
32
33 if (ret) {
34-
35 // Read the records
36 while (true) {
37 CDataStream ss_key(SER_DISK, CLIENT_VERSION);
38@@ -78,7 +79,7 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
39 batch.reset();
40
41 // Close the wallet after we're done with it. The caller won't be doing this
42- wallet->Close();
43+ wallet.Close();
44
45 if (ret) {
46 // Write the hash
47diff --git a/src/wallet/dump.h b/src/wallet/dump.h
48index a62c388b72..0f17ee1d0d 100644
49--- a/src/wallet/dump.h
50+++ b/src/wallet/dump.h
51@@ -9,6 +9,6 @@ class CWallet;
52
53 struct bilingual_str;
54
55-bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error);
56+bool DumpWallet(CWallet& wallet, bilingual_str& error);
57
58 #endif // BITCOIN_WALLET_DUMP_H
59diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
60index 1fed63b755..f78ebd4376 100644
61--- a/src/wallet/wallettool.cpp
62+++ b/src/wallet/wallettool.cpp
63@@ -149,7 +149,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
64 std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, /* create= */ false);
65 if (!wallet_instance) return false;
66 bilingual_str error;
67- bool ret = DumpWallet(wallet_instance, error);
68+ bool ret = DumpWallet(*wallet_instance, error);
69 if (!ret && !error.empty()) {
70 tfm::format(std::cerr, "%s\n", error.original);
71 return ret;