mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +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/fs.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
#include <wallet/walletdb.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -20,7 +21,7 @@ namespace wallet {
|
|||||||
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
|
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
|
||||||
uint32_t DUMP_VERSION = 1;
|
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);
|
fs::path path = fs::PathFromString(dump_filename);
|
||||||
path = fs::absolute(path);
|
path = fs::absolute(path);
|
||||||
@ -37,7 +38,6 @@ bool DumpWallet(CWallet& wallet, bilingual_str& error, const std::string& dump_f
|
|||||||
|
|
||||||
HashWriter hasher{};
|
HashWriter hasher{};
|
||||||
|
|
||||||
WalletDatabase& db = wallet.GetDatabase();
|
|
||||||
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
|
std::unique_ptr<DatabaseBatch> batch = db.MakeBatch();
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
@ -14,8 +14,9 @@ struct bilingual_str;
|
|||||||
class ArgsManager;
|
class ArgsManager;
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
class CWallet;
|
class WalletDatabase;
|
||||||
bool DumpWallet(CWallet& wallet, bilingual_str& error, const std::string& dump_filename);
|
|
||||||
|
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);
|
bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
||||||
|
@ -167,7 +167,10 @@ public:
|
|||||||
bool backupWallet(const std::string& filename, const WalletBackupFormat format, bilingual_str& error) override {
|
bool backupWallet(const std::string& filename, const WalletBackupFormat format, bilingual_str& error) override {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case WalletBackupFormat::DbDump:
|
case WalletBackupFormat::DbDump:
|
||||||
return DumpWallet(*m_wallet, error, filename);
|
{
|
||||||
|
WalletDatabase& db = m_wallet->GetDatabase();
|
||||||
|
return DumpWallet(db, error, filename);
|
||||||
|
}
|
||||||
case WalletBackupFormat::Raw:
|
case WalletBackupFormat::Raw:
|
||||||
return m_wallet->BackupWallet(filename);
|
return m_wallet->BackupWallet(filename);
|
||||||
}
|
}
|
||||||
|
@ -235,8 +235,13 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
|||||||
DatabaseOptions options;
|
DatabaseOptions options;
|
||||||
ReadDatabaseArgs(args, options);
|
ReadDatabaseArgs(args, options);
|
||||||
options.require_existing = true;
|
options.require_existing = true;
|
||||||
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
DatabaseStatus status;
|
||||||
if (!wallet_instance) return false;
|
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
|
// Get the dumpfile
|
||||||
std::string dump_filename = args.GetArg("-dumpfile", "");
|
std::string dump_filename = args.GetArg("-dumpfile", "");
|
||||||
@ -245,9 +250,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bilingual_str error;
|
bool ret = DumpWallet(*database, error, dump_filename);
|
||||||
bool ret = DumpWallet(*wallet_instance, error, dump_filename);
|
|
||||||
wallet_instance->Close();
|
|
||||||
if (!ret && !error.empty()) {
|
if (!ret && !error.empty()) {
|
||||||
tfm::format(std::cerr, "%s\n", error.original);
|
tfm::format(std::cerr, "%s\n", error.original);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user