Add backup wallet option
This commit is contained in:
@@ -478,6 +478,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectZcashConf() {
|
|||||||
zcashconf->host = "127.0.0.1";
|
zcashconf->host = "127.0.0.1";
|
||||||
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD;
|
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD;
|
||||||
zcashconf->usingZcashConf = true;
|
zcashconf->usingZcashConf = true;
|
||||||
|
zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath();
|
||||||
|
|
||||||
Settings::getInstance()->setUsingZcashConf(confLocation);
|
Settings::getInstance()->setUsingZcashConf(confLocation);
|
||||||
|
|
||||||
@@ -526,7 +527,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::loadFromSettings() {
|
|||||||
if (username.isEmpty() || password.isEmpty())
|
if (username.isEmpty() || password.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, ConnectionType::UISettingsZCashD };
|
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, "", ConnectionType::UISettingsZCashD};
|
||||||
|
|
||||||
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct ConnectionConfig {
|
|||||||
QString rpcuser;
|
QString rpcuser;
|
||||||
QString rpcpassword;
|
QString rpcpassword;
|
||||||
bool usingZcashConf;
|
bool usingZcashConf;
|
||||||
|
QString zcashDir;
|
||||||
|
|
||||||
ConnectionType connType;
|
ConnectionType connType;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// Export All Private Keys
|
// Export All Private Keys
|
||||||
QObject::connect(ui->actionExport_All_Private_Keys, &QAction::triggered, this, &MainWindow::exportAllKeys);
|
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
|
// z-Board.net
|
||||||
QObject::connect(ui->actionz_board_net, &QAction::triggered, this, &MainWindow::postToZBoard);
|
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() {
|
void MainWindow::exportAllKeys() {
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_PrivKey pui;
|
Ui_PrivKey pui;
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ private:
|
|||||||
void postToZBoard();
|
void postToZBoard();
|
||||||
void importPrivKey();
|
void importPrivKey();
|
||||||
void exportAllKeys();
|
void exportAllKeys();
|
||||||
|
void backupWalletDat();
|
||||||
|
|
||||||
void doImport(QList<QString>* keys);
|
void doImport(QList<QString>* keys);
|
||||||
|
|
||||||
void restoreSavedStates();
|
void restoreSavedStates();
|
||||||
|
|||||||
@@ -316,8 +316,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>920</width>
|
<width>928</width>
|
||||||
<height>334</height>
|
<height>380</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="sendToLayout">
|
<layout class="QVBoxLayout" name="sendToLayout">
|
||||||
@@ -849,7 +849,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>968</width>
|
<width>968</width>
|
||||||
<height>22</height>
|
<height>19</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@@ -858,6 +858,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="actionImport_Private_Key"/>
|
<addaction name="actionImport_Private_Key"/>
|
||||||
<addaction name="actionExport_All_Private_Keys"/>
|
<addaction name="actionExport_All_Private_Keys"/>
|
||||||
|
<addaction name="actionBackup_wallet_dat"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -932,7 +933,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionExport_All_Private_Keys">
|
<action name="actionExport_All_Private_Keys">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Export all private keys</string>
|
<string>&Export all private keys</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionz_board_net">
|
<action name="actionz_board_net">
|
||||||
@@ -951,6 +952,11 @@
|
|||||||
<string>Ctrl+B</string>
|
<string>Ctrl+B</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionBackup_wallet_dat">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Backup wallet.dat</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ struct Tx;
|
|||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Settings* init();
|
static Settings* init();
|
||||||
static Settings* getInstance();
|
static Settings* getInstance();
|
||||||
|
|
||||||
Config getSettings();
|
Config getSettings();
|
||||||
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
static const int updateSpeed = 20 * 1000; // 20 sec
|
||||||
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
|
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
|
||||||
static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr
|
static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This class can only be accessed through Settings::getInstance()
|
// This class can only be accessed through Settings::getInstance()
|
||||||
|
|||||||
Reference in New Issue
Block a user