refactor: Use ToIntegral in CreateFromDump

The unsigned version is never serialized with a `+` prefix, so the
stricter ToIntegral can be used.
This commit is contained in:
MarcoFalke 2025-04-28 15:49:42 +02:00
parent fa23ed7fc2
commit fa98041325
No known key found for this signature in database

View File

@ -151,13 +151,13 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
return false;
}
// Check the version number (value of first record)
uint32_t ver;
if (!ParseUInt32(version_value, &ver)) {
error =strprintf(_("Error: Unable to parse version %u as a uint32_t"), version_value);
const auto ver{ToIntegral<uint32_t>(version_value)};
if (!ver) {
error = strprintf(_("Error: Unable to parse version %u as a uint32_t"), version_value);
dump_file.close();
return false;
}
if (ver != DUMP_VERSION) {
if (*ver != DUMP_VERSION) {
error = strprintf(_("Error: Dumpfile version is not supported. This version of bitcoin-wallet only supports version 1 dumpfiles. Got dumpfile with version %s"), version_value);
dump_file.close();
return false;