|
|
@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
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); |
|
|
|
QObject::connect(ui->actionExport_Seed, &QAction::triggered, this, &MainWindow::exportSeed); |
|
|
|
|
|
|
|
// Export transactions
|
|
|
|
QObject::connect(ui->actionExport_transactions, &QAction::triggered, this, &MainWindow::exportTransactions); |
|
|
@ -648,36 +648,60 @@ void MainWindow::exportTransactions() { |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* Backup the wallet.dat file. This is kind of a hack, since it has to read from the filesystem rather than an RPC call |
|
|
|
* This might fail for various reasons - Remote zcashd, non-standard locations, custom params passed to zcashd, many others |
|
|
|
* Export the seed phrase. |
|
|
|
*/ |
|
|
|
void MainWindow::backupWalletDat() { |
|
|
|
void MainWindow::exportSeed() { |
|
|
|
if (!rpc->getConnection()) |
|
|
|
return; |
|
|
|
|
|
|
|
// QDir zcashdir(rpc->getConnection()->config->zcashDir);
|
|
|
|
// QString backupDefaultName = "zcash-wallet-backup-" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".dat";
|
|
|
|
|
|
|
|
// if (Settings::getInstance()->isTestnet()) {
|
|
|
|
// zcashdir.cd("testnet3");
|
|
|
|
// backupDefaultName = "testnet-" + backupDefaultName;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QFile wallet(zcashdir.filePath("wallet.dat"));
|
|
|
|
// if (!wallet.exists()) {
|
|
|
|
// QMessageBox::critical(this, tr("No wallet.dat"), tr("Couldn't find the wallet.dat on this computer") + "\n" +
|
|
|
|
// tr("You need to back it up from the machine zcashd is running on"), QMessageBox::Ok);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QUrl backupName = QFileDialog::getSaveFileUrl(this, tr("Backup wallet.dat"), backupDefaultName, "Data file (*.dat)");
|
|
|
|
// if (backupName.isEmpty())
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// if (!wallet.copy(backupName.toLocalFile())) {
|
|
|
|
// QMessageBox::critical(this, tr("Couldn't backup"), tr("Couldn't backup the wallet.dat file.") +
|
|
|
|
// tr("You need to back it up manually."), QMessageBox::Ok);
|
|
|
|
// }
|
|
|
|
QDialog d(this); |
|
|
|
Ui_PrivKey pui; |
|
|
|
pui.setupUi(&d); |
|
|
|
|
|
|
|
// Make the window big by default
|
|
|
|
auto ps = this->geometry(); |
|
|
|
QMargins margin = QMargins() + 50; |
|
|
|
d.setGeometry(ps.marginsRemoved(margin)); |
|
|
|
|
|
|
|
Settings::saveRestore(&d); |
|
|
|
|
|
|
|
pui.privKeyTxt->setPlainText(tr("This might take several minutes. Loading...")); |
|
|
|
pui.privKeyTxt->setReadOnly(true); |
|
|
|
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap); |
|
|
|
|
|
|
|
pui.helpLbl->setText(tr("This is your wallet seed. Please back it up carefully and safely.")); |
|
|
|
|
|
|
|
// Disable the save button until it finishes loading
|
|
|
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); |
|
|
|
pui.buttonBox->button(QDialogButtonBox::Ok)->setVisible(false); |
|
|
|
|
|
|
|
// Wire up save button
|
|
|
|
QObject::connect(pui.buttonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, [=] () { |
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), |
|
|
|
"zcash-seed.txt"); |
|
|
|
QFile file(fileName); |
|
|
|
if (!file.open(QIODevice::WriteOnly)) { |
|
|
|
QMessageBox::information(this, tr("Unable to open file"), file.errorString()); |
|
|
|
return; |
|
|
|
} |
|
|
|
QTextStream out(&file); |
|
|
|
out << pui.privKeyTxt->toPlainText(); |
|
|
|
}); |
|
|
|
|
|
|
|
rpc->fetchSeed([=](json reply) { |
|
|
|
if (isJsonError(reply)) { |
|
|
|
pui.privKeyTxt->setPlainText(tr("Error loading wallet seed: ") + QString::fromStdString(reply["error"])); |
|
|
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
pui.privKeyTxt->setPlainText(QString::fromStdString(reply.dump())); |
|
|
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
d.exec(); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::exportAllKeys() { |
|
|
@ -685,6 +709,9 @@ void MainWindow::exportAllKeys() { |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::exportKeys(QString addr) { |
|
|
|
if (!rpc->getConnection()) |
|
|
|
return; |
|
|
|
|
|
|
|
bool allKeys = addr.isEmpty() ? true : false; |
|
|
|
|
|
|
|
QDialog d(this); |
|
|
|