GUI: Support backup to DumpWallet format

This commit is contained in:
Luke Dashjr 2021-02-27 16:54:54 +00:00
parent ce88a6dea4
commit 6b1898af6d

View File

@ -210,21 +210,31 @@ void WalletView::encryptWallet()
void WalletView::backupWallet() void WalletView::backupWallet()
{ {
QString filetype_str;
QString filename = GUIUtil::getSaveFileName(this, QString filename = GUIUtil::getSaveFileName(this,
tr("Backup Wallet"), QString(), tr("Backup Wallet"), QString(),
//: Name of the wallet data file format. //: Name of the wallet data file format.
tr("Wallet Data") + QLatin1String(" (*.dat)"), nullptr); tr("Wallet Data") + QLatin1String(" (*.dat);;") + tr("Wallet Database Dump File") + QLatin1String(" (*.walletdbdump)"),
&filetype_str);
if (filename.isEmpty()) if (filename.isEmpty())
return; return;
constexpr WalletBackupFormat filetype = WalletBackupFormat::Raw; WalletBackupFormat filetype;
if (filetype_str == "walletdbdump") {
filetype = WalletBackupFormat::DbDump;
} else {
filetype = WalletBackupFormat::Raw;
}
bilingual_str error; bilingual_str error;
if (!walletModel->wallet().backupWallet(filename.toLocal8Bit().data(), filetype, error)) { if (!walletModel->wallet().backupWallet(filename.toLocal8Bit().data(), filetype, error)) {
Q_EMIT message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to %1.").arg(filename), if (error.empty()) {
CClientUIInterface::MSG_ERROR); Q_EMIT message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to %1.").arg(filename), CClientUIInterface::MSG_ERROR);
} else {
Q_EMIT message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to %1: %2").arg(filename).arg(QString::fromStdString(error.translated)), CClientUIInterface::MSG_ERROR);
} }
else { } else {
Q_EMIT message(tr("Backup Successful"), tr("The wallet data was successfully saved to %1.").arg(filename), Q_EMIT message(tr("Backup Successful"), tr("The wallet data was successfully saved to %1.").arg(filename),
CClientUIInterface::MSG_INFORMATION); CClientUIInterface::MSG_INFORMATION);
} }