mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Merge 29117 via wallettool_dump_just_db-26+knots
This commit is contained in:
commit
d5a583542e
@ -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(CWallet& wallet, bilingual_str& error, const std::string& dump_filename)
|
||||
bool DumpWallet(WalletDatabase& db, bilingual_str& error, const std::string& dump_filename)
|
||||
{
|
||||
fs::path path = fs::PathFromString(dump_filename);
|
||||
path = fs::absolute(path);
|
||||
@ -37,7 +38,6 @@ bool DumpWallet(CWallet& wallet, bilingual_str& error, const std::string& dump_f
|
||||
|
||||
HashWriter hasher{};
|
||||
|
||||
WalletDatabase& db = wallet.GetDatabase();
|
||||
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
|
||||
|
||||
bool ret = true;
|
||||
|
@ -14,8 +14,9 @@ struct bilingual_str;
|
||||
class ArgsManager;
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
bool DumpWallet(CWallet& wallet, bilingual_str& error, const std::string& dump_filename);
|
||||
class WalletDatabase;
|
||||
|
||||
bool DumpWallet(WalletDatabase& db, bilingual_str& error, const std::string& dump_filename);
|
||||
bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
} // namespace wallet
|
||||
|
||||
|
@ -167,7 +167,10 @@ public:
|
||||
bool backupWallet(const std::string& filename, const WalletBackupFormat format, bilingual_str& error) override {
|
||||
switch (format) {
|
||||
case WalletBackupFormat::DbDump:
|
||||
return DumpWallet(*m_wallet, error, filename);
|
||||
{
|
||||
WalletDatabase& db = m_wallet->GetDatabase();
|
||||
return DumpWallet(db, error, filename);
|
||||
}
|
||||
case WalletBackupFormat::Raw:
|
||||
return m_wallet->BackupWallet(filename);
|
||||
}
|
||||
|
@ -235,8 +235,13 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
DatabaseOptions options;
|
||||
ReadDatabaseArgs(args, options);
|
||||
options.require_existing = true;
|
||||
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
if (!wallet_instance) return false;
|
||||
DatabaseStatus status;
|
||||
bilingual_str error;
|
||||
std::unique_ptr<WalletDatabase> database = MakeDatabase(path, options, status, error);
|
||||
if (!database) {
|
||||
tfm::format(std::cerr, "%s\n", error.original);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the dumpfile
|
||||
std::string dump_filename = args.GetArg("-dumpfile", "");
|
||||
@ -245,9 +250,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
return false;
|
||||
}
|
||||
|
||||
bilingual_str error;
|
||||
bool ret = DumpWallet(*wallet_instance, error, dump_filename);
|
||||
wallet_instance->Close();
|
||||
bool ret = DumpWallet(*database, error, dump_filename);
|
||||
if (!ret && !error.empty()) {
|
||||
tfm::format(std::cerr, "%s\n", error.original);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user