Add backup wallet option

This commit is contained in:
adityapk00
2018-11-18 18:55:24 -08:00
parent b572dfadef
commit 0bce364f0b
6 changed files with 41 additions and 8 deletions

View File

@@ -48,6 +48,9 @@ MainWindow::MainWindow(QWidget *parent) :
// Export All Private Keys
QObject::connect(ui->actionExport_All_Private_Keys, &QAction::triggered, this, &MainWindow::exportAllKeys);
// Backup wallet.dat
QObject::connect(ui->actionBackup_wallet_dat, &QAction::triggered, this, &MainWindow::backupWalletDat);
// z-Board.net
QObject::connect(ui->actionz_board_net, &QAction::triggered, this, &MainWindow::postToZBoard);
@@ -633,6 +636,26 @@ void MainWindow::importPrivKey() {
}
}
void MainWindow::backupWalletDat() {
QFile wallet(QDir(rpc->getConnection()->config->zcashDir).filePath("wallet.dat"));
if (!wallet.exists()) {
QMessageBox::critical(this, "No wallet.dat", "Couldn't find the wallet.dat on this computer."
"You need to backup it up from the machine zcashd is running on", QMessageBox::Ok);
return;
}
QUrl backupName = QFileDialog::getSaveFileUrl(this, "Backup wallet.dat",
"zcash-wallet-backup-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".dat",
"Data file (*.dat)");
if (backupName.isEmpty())
return;
if (!wallet.copy(backupName.toLocalFile())) {
QMessageBox::critical(this, "Couldn't backup", "Couldn't backup the wallet.dat file."
"You need to backup it up manually.", QMessageBox::Ok);
}
}
void MainWindow::exportAllKeys() {
QDialog d(this);
Ui_PrivKey pui;