diff options
Diffstat (limited to 'src/wallet/dump.cpp')
-rw-r--r-- | src/wallet/dump.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/wallet/dump.cpp b/src/wallet/dump.cpp index 7dfb1d8839..6d8508fc72 100644 --- a/src/wallet/dump.cpp +++ b/src/wallet/dump.cpp @@ -4,9 +4,17 @@ #include <wallet/dump.h> +#include <fs.h> #include <util/translation.h> #include <wallet/wallet.h> +#include <algorithm> +#include <fstream> +#include <memory> +#include <string> +#include <utility> +#include <vector> + namespace wallet { static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP"; uint32_t DUMP_VERSION = 1; @@ -26,7 +34,7 @@ bool DumpWallet(CWallet& wallet, bilingual_str& error) error = strprintf(_("File %s already exists. If you are sure this is what you want, move it out of the way first."), fs::PathToString(path)); return false; } - fsbridge::ofstream dump_file; + std::ofstream dump_file; dump_file.open(path); if (dump_file.fail()) { error = strprintf(_("Unable to open %s for writing"), fs::PathToString(path)); @@ -47,12 +55,12 @@ bool DumpWallet(CWallet& wallet, bilingual_str& error) // Write out a magic string with version std::string line = strprintf("%s,%u\n", DUMP_MAGIC, DUMP_VERSION); dump_file.write(line.data(), line.size()); - hasher.write(line.data(), line.size()); + hasher.write(MakeByteSpan(line)); // Write out the file format line = strprintf("%s,%s\n", "format", db.Format()); dump_file.write(line.data(), line.size()); - hasher.write(line.data(), line.size()); + hasher.write(MakeByteSpan(line)); if (ret) { @@ -73,7 +81,7 @@ bool DumpWallet(CWallet& wallet, bilingual_str& error) std::string value_str = HexStr(ss_value); line = strprintf("%s,%s\n", key_str, value_str); dump_file.write(line.data(), line.size()); - hasher.write(line.data(), line.size()); + hasher.write(MakeByteSpan(line)); } } @@ -121,7 +129,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling error = strprintf(_("Dump file %s does not exist."), fs::PathToString(dump_path)); return false; } - fsbridge::ifstream dump_file(dump_path); + std::ifstream dump_file{dump_path}; // Compute the checksum CHashWriter hasher(0, 0); @@ -150,7 +158,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling return false; } std::string magic_hasher_line = strprintf("%s,%s\n", magic_key, version_value); - hasher.write(magic_hasher_line.data(), magic_hasher_line.size()); + hasher.write(MakeByteSpan(magic_hasher_line)); // Get the stored file format std::string format_key; @@ -181,7 +189,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling warnings.push_back(strprintf(_("Warning: Dumpfile wallet format \"%s\" does not match command line specified format \"%s\"."), format_value, file_format)); } std::string format_hasher_line = strprintf("%s,%s\n", format_key, format_value); - hasher.write(format_hasher_line.data(), format_hasher_line.size()); + hasher.write(MakeByteSpan(format_hasher_line)); DatabaseOptions options; DatabaseStatus status; @@ -225,7 +233,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling } std::string line = strprintf("%s,%s\n", key, value); - hasher.write(line.data(), line.size()); + hasher.write(MakeByteSpan(line)); if (key.empty() || value.empty()) { continue; |