argsman.AddArg("-dumpfile=<file name>","When used with 'dump', writes out the records to this file.",ArgsManager::ALLOW_STRING,OptionsCategory::OPTIONS);
argsman.AddArg("-dumpfile=<file name>","When used with 'dump', writes out the records to this file. When used with 'createfromdump', loads the records into a new wallet.",ArgsManager::ALLOW_STRING,OptionsCategory::OPTIONS);
argsman.AddArg("-debug=<category>","Output debugging information (default: 0).",ArgsManager::ALLOW_ANY,OptionsCategory::DEBUG_TEST);
argsman.AddArg("-descriptors","Create descriptors wallet. Only for create",ArgsManager::ALLOW_BOOL,OptionsCategory::OPTIONS);
argsman.AddArg("-format=<format>","The format of the wallet file to create. Either \"bdb\" or \"sqlite\". Only used with 'createfromdump'",ArgsManager::ALLOW_ANY,OptionsCategory::OPTIONS);
argsman.AddArg("-printtoconsole","Send trace/debug info to console (default: 1 when no -debug is true, 0 otherwise).",ArgsManager::ALLOW_ANY,OptionsCategory::DEBUG_TEST);
argsman.AddArg("create","Create new wallet file",ArgsManager::ALLOW_ANY,OptionsCategory::COMMANDS);
argsman.AddArg("salvage","Attempt to recover private keys from a corrupt wallet. Warning: 'salvage' is experimental.",ArgsManager::ALLOW_ANY,OptionsCategory::COMMANDS);
argsman.AddArg("dump","Print out all of the wallet key-value records",ArgsManager::ALLOW_ANY,OptionsCategory::COMMANDS);
argsman.AddArg("createfromdump","Create new wallet file from dumped records",ArgsManager::ALLOW_ANY,OptionsCategory::COMMANDS);
error=_("No dump file provided. To use createfromdump, -dumpfile=<filename> must be provided.");
returnfalse;
}
fs::pathdump_path=dump_filename;
dump_path=fs::absolute(dump_path);
if(!fs::exists(dump_path)){
error=strprintf(_("Dump file %s does not exist."),dump_path.string());
returnfalse;
}
fsbridge::ifstreamdump_file(dump_path);
// Compute the checksum
CHashWriterhasher(0,0);
uint256checksum;
// Check the magic and version
std::stringmagic_key;
std::getline(dump_file,magic_key,',');
std::stringversion_value;
std::getline(dump_file,version_value,'\n');
if(magic_key!=DUMP_MAGIC){
error=strprintf(_("Error: Dumpfile identifier record is incorrect. Got \"%s\", expected \"%s\"."),magic_key,DUMP_MAGIC);
dump_file.close();
returnfalse;
}
// Check the version number (value of first record)
uint32_tver;
if(!ParseUInt32(version_value,&ver)){
error=strprintf(_("Error: Unable to parse version %u as a uint32_t"),version_value);
dump_file.close();
returnfalse;
}
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);
error=_("No wallet file format provided. To use createfromdump, -format=<format> must be provided.");
returnfalse;
}
DatabaseFormatdata_format;
if(file_format=="bdb"){
data_format=DatabaseFormat::BERKELEY;
}elseif(file_format=="sqlite"){
data_format=DatabaseFormat::SQLITE;
}else{
error=strprintf(_("Unknown wallet file format \"%s\" provided. Please provide one of \"bdb\" or \"sqlite\"."),file_format);
returnfalse;
}
if(file_format!=format_value){
warnings.push_back(strprintf(_("Warning: Dumpfile wallet format \"%s\" does not match command line specified format \"%s\"."),format_value,file_format));