aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/dump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/dump.cpp')
-rw-r--r--src/wallet/dump.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/wallet/dump.cpp b/src/wallet/dump.cpp
index 3ac5cf03b1..db2756e0ca 100644
--- a/src/wallet/dump.cpp
+++ b/src/wallet/dump.cpp
@@ -8,6 +8,7 @@
#include <util/fs.h>
#include <util/translation.h>
#include <wallet/wallet.h>
+#include <wallet/walletdb.h>
#include <algorithm>
#include <fstream>
@@ -20,7 +21,7 @@ namespace wallet {
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
uint32_t DUMP_VERSION = 1;
-bool DumpWallet(const ArgsManager& args, CWallet& wallet, bilingual_str& error)
+bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error)
{
// Get the dumpfile
std::string dump_filename = args.GetArg("-dumpfile", "");
@@ -44,7 +45,6 @@ bool DumpWallet(const ArgsManager& args, CWallet& wallet, bilingual_str& error)
HashWriter hasher{};
- WalletDatabase& db = wallet.GetDatabase();
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
bool ret = true;
@@ -60,7 +60,13 @@ bool DumpWallet(const ArgsManager& args, CWallet& wallet, bilingual_str& error)
hasher << Span{line};
// Write out the file format
- line = strprintf("%s,%s\n", "format", db.Format());
+ std::string format = db.Format();
+ // BDB files that are opened using BerkeleyRODatabase have it's format as "bdb_ro"
+ // We want to override that format back to "bdb"
+ if (format == "bdb_ro") {
+ format = "bdb";
+ }
+ line = strprintf("%s,%s\n", "format", format);
dump_file.write(line.data(), line.size());
hasher << Span{line};
@@ -90,9 +96,6 @@ bool DumpWallet(const ArgsManager& args, CWallet& wallet, bilingual_str& error)
cursor.reset();
batch.reset();
- // Close the wallet after we're done with it. The caller won't be doing this
- wallet.Close();
-
if (ret) {
// Write the hash
tfm::format(dump_file, "checksum,%s\n", HexStr(hasher.GetHash()));
@@ -183,6 +186,8 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
data_format = DatabaseFormat::BERKELEY;
} else if (file_format == "sqlite") {
data_format = DatabaseFormat::SQLITE;
+ } else if (file_format == "bdb_swap") {
+ data_format = DatabaseFormat::BERKELEY_SWAP;
} else {
error = strprintf(_("Unknown wallet file format \"%s\" provided. Please provide one of \"bdb\" or \"sqlite\"."), file_format);
return false;