Also, is there any reason to pass a shared_ptr, when a reference suffices?
Suggested diff for first commit:
diff --git a/src/wallet/dump.cpp b/src/wallet/dump.cpp
index 242d8dc31c..2e366b2a19 100644
--- a/src/wallet/dump.cpp
+++ b/src/wallet/dump.cpp
@@ -2,13 +2,15 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <wallet/dump.h>
+
#include <util/translation.h>
#include <wallet/wallet.h>
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
uint32_t DUMP_VERSION = 1;
-bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
+bool DumpWallet(CWallet& wallet, bilingual_str& error)
{
// Get the dumpfile
std::string dump_filename = gArgs.GetArg("-dumpfile", "");
@@ -32,7 +34,7 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
CHashWriter hasher(0, 0);
- WalletDatabase& db = wallet->GetDatabase();
+ WalletDatabase& db = wallet.GetDatabase();
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
bool ret = true;
@@ -52,7 +54,6 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
hasher.write(line.data(), line.size());
if (ret) {
-
// Read the records
while (true) {
CDataStream ss_key(SER_DISK, CLIENT_VERSION);
@@ -78,7 +79,7 @@ bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error)
batch.reset();
// Close the wallet after we're done with it. The caller won't be doing this
- wallet->Close();
+ wallet.Close();
if (ret) {
// Write the hash
diff --git a/src/wallet/dump.h b/src/wallet/dump.h
index a62c388b72..0f17ee1d0d 100644
--- a/src/wallet/dump.h
+++ b/src/wallet/dump.h
@@ -9,6 +9,6 @@ class CWallet;
struct bilingual_str;
-bool DumpWallet(std::shared_ptr<CWallet> wallet, bilingual_str& error);
+bool DumpWallet(CWallet& wallet, bilingual_str& error);
#endif // BITCOIN_WALLET_DUMP_H
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
index 1fed63b755..f78ebd4376 100644
--- a/src/wallet/wallettool.cpp
+++ b/src/wallet/wallettool.cpp
@@ -149,7 +149,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, /* create= */ false);
if (!wallet_instance) return false;
bilingual_str error;
- bool ret = DumpWallet(wallet_instance, error);
+ bool ret = DumpWallet(*wallet_instance, error);
if (!ret && !error.empty()) {
tfm::format(std::cerr, "%s\n", error.original);
return ret;