mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-08-04 05:54:48 +02:00
Wallet: Pass dump_filename to DumpWallet as an argument
This commit is contained in:
parent
55bd5d8015
commit
111058215c
@ -21,15 +21,8 @@ namespace wallet {
|
||||
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
|
||||
uint32_t DUMP_VERSION = 1;
|
||||
|
||||
bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error)
|
||||
bool DumpWallet(WalletDatabase& db, bilingual_str& error, const std::string& dump_filename)
|
||||
{
|
||||
// Get the dumpfile
|
||||
std::string dump_filename = args.GetArg("-dumpfile", "");
|
||||
if (dump_filename.empty()) {
|
||||
error = _("No dump file provided. To use dump, -dumpfile=<filename> must be provided.");
|
||||
return false;
|
||||
}
|
||||
|
||||
fs::path path = fs::PathFromString(dump_filename);
|
||||
path = fs::absolute(path);
|
||||
if (fs::exists(path)) {
|
||||
|
@ -16,7 +16,7 @@ class ArgsManager;
|
||||
namespace wallet {
|
||||
class WalletDatabase;
|
||||
|
||||
bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error);
|
||||
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
|
||||
|
||||
|
@ -193,6 +193,14 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
DatabaseOptions options;
|
||||
ReadDatabaseArgs(args, options);
|
||||
options.require_existing = true;
|
||||
|
||||
// Get the dumpfile
|
||||
std::string dump_filename = args.GetArg("-dumpfile", "");
|
||||
if (dump_filename.empty()) {
|
||||
tfm::format(std::cerr, "No dump file provided. To use dump, -dumpfile=<filename> must be provided.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
DatabaseStatus status;
|
||||
bilingual_str error;
|
||||
std::unique_ptr<WalletDatabase> database = MakeDatabase(path, options, status, error);
|
||||
@ -201,7 +209,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = DumpWallet(args, *database, error);
|
||||
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