diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp old mode 100644 new mode 100755 index 346fc51a3c..52175fd770 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -217,6 +217,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) : connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole())); connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork())); connect(openPeersAction, SIGNAL(triggered()), rpcConsole, SLOT(showPeers())); + connect(openRepairAction, SIGNAL(triggered()), rpcConsole, SLOT(showRepair())); connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor())); connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups())); connect(labelConnectionsIcon, SIGNAL(clicked()), rpcConsole, SLOT(showPeers())); @@ -352,6 +353,8 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle) openNetworkAction->setStatusTip(tr("Show network monitor")); openPeersAction = new QAction(QIcon(":/icons/connect_4"), tr("&Peers list"), this); openPeersAction->setStatusTip(tr("Show peers info")); + openRepairAction = new QAction(QIcon(":/icons/options"), tr("&Repair Wallet"), this); + openRepairAction->setStatusTip(tr("Repair Wallet Options")); openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this); openConfEditorAction->setStatusTip(tr("Open configuration file")); showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Automatic &Backups"), this); @@ -435,6 +438,7 @@ void BitcoinGUI::createMenuBar() tools->addAction(openRPCConsoleAction); tools->addAction(openNetworkAction); tools->addAction(openPeersAction); + tools->addAction(openRepairAction); tools->addSeparator(); tools->addAction(openConfEditorAction); tools->addAction(showBackupsAction); @@ -602,6 +606,7 @@ void BitcoinGUI::createTrayIconMenu() trayIconMenu->addAction(openRPCConsoleAction); trayIconMenu->addAction(openNetworkAction); trayIconMenu->addAction(openPeersAction); + trayIconMenu->addAction(openRepairAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(openConfEditorAction); trayIconMenu->addAction(showBackupsAction); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h old mode 100644 new mode 100755 index 31a98036c5..3c01f55af7 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -109,6 +109,7 @@ private: QAction *openRPCConsoleAction; QAction *openNetworkAction; QAction *openPeersAction; + QAction *openRepairAction; QAction *openConfEditorAction; QAction *showBackupsAction; QAction *openAction; diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 9be3caea97..49e9bca55c 100755 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -1064,6 +1064,257 @@ + + + &Wallet Repair + + + + + 10 + 90 + 180 + 23 + + + + + 180 + 23 + + + + Salvage Wallet + + + + + + 10 + 140 + 180 + 23 + + + + + 180 + 23 + + + + Rescan blockhain files + + + + + + 10 + 190 + 180 + 23 + + + + + 180 + 23 + + + + Recover transactions 1 + + + + + + 10 + 240 + 180 + 23 + + + + + 180 + 23 + + + + Recover transactions 2 + + + + + + 10 + 290 + 180 + 23 + + + + + 180 + 23 + + + + Upgrade wallet format + + + + + + 10 + 30 + 711 + 41 + + + + + 50 + false + + + + The buttons below will restart the wallet with command-line options to repair the wallet, fix issues with corrupt blockhain files or missing/obsolete transactions. + + + true + + + + + + 210 + 80 + 511 + 41 + + + + -salvagewallet: Attempt to recover private keys from a corrupt wallet.dat. + + + true + + + + + + 210 + 129 + 511 + 41 + + + + -rescan: Rescan the block chain for missing wallet transactions. + + + true + + + + + + 210 + 179 + 511 + 41 + + + + -zapwallettxes=1: Recover transactions from blockchain (keep meta-data, e.g. account owner). + + + true + + + + + + 210 + 229 + 511 + 41 + + + + -zapwallettxes=2: Recover transactions from blockchain (drop meta-data). + + + true + + + + + + 210 + 279 + 511 + 41 + + + + -upgradewallet: Upgrade wallet to latest format on startup. (Note: this is NOT an update of the wallet itself !) + + + true + + + + + + 10 + 10 + 711 + 16 + + + + + 10 + 75 + true + + + + Wallet repair options. + + + true + + + + + + 10 + 340 + 181 + 23 + + + + Rebuild index + + + + + + 210 + 330 + 511 + 41 + + + + -reindex: Rebuild block chain index from current blk000??.dat files. + + + diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index b6a21a632f..375bd71528 100755 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -220,6 +220,14 @@ RPCConsole::RPCConsole(QWidget *parent) : connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear())); + + // Wallet Repair + connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(wallet_salvage())); + connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(wallet_rescan())); + connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(wallet_zaptxes1())); + connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(wallet_zaptxes2())); + connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(wallet_upgrade())); + connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(wallet_reindex())); // set library version labels ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION)); @@ -336,6 +344,61 @@ static QString categoryClass(int category) } } +void RPCConsole::wallet_salvage() +{ + restart(1); +} + +void RPCConsole::wallet_rescan() +{ + restart(2); +} + +void RPCConsole::wallet_zaptxes1() +{ + restart(3); +} + +void RPCConsole::wallet_zaptxes2() +{ + restart(4); +} + +void RPCConsole::wallet_upgrade() +{ + restart(5); +} + +void RPCConsole::wallet_reindex() +{ + restart(6); +} + +void RPCConsole::restart(int reason) +{ + switch(reason) + { + case 1: // -salvagewallet + printf("-salvagewallet\n"); + break; + case 2: // -rescan + printf("-rescan\n"); + break; + case 3: // -zapwallettxes=1 + printf("-zapwallettxes=1\n"); + break; + case 4: // -zapwallettxes=2 + printf("-zapwallettxes=2\n"); + break; + case 5: // -upgradewallet + printf("-upgradewallet\n"); + break; + case 6: // -reindex + printf("-reindex\n"); + break; + } +} + void RPCConsole::clear() { ui->messagesWidget->clear(); @@ -550,6 +613,12 @@ void RPCConsole::showPeers() show(); } +void RPCConsole::showRepair() +{ + ui->tabWidget->setCurrentIndex(4); + show(); +} + void RPCConsole::showConfEditor() { GUIUtil::openConfigfile(); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index e20d8fec9f..875a8f4df6 100755 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -32,6 +32,7 @@ public: ~RPCConsole(); void setClientModel(ClientModel *model); + void restart(int reason); enum MessageClass { MC_ERROR, @@ -59,6 +60,15 @@ private slots: public slots: void clear(); + + /** Wallet repair options */ + void wallet_salvage(); + void wallet_rescan(); + void wallet_zaptxes1(); + void wallet_zaptxes2(); + void wallet_upgrade(); + void wallet_reindex(); + void reject(); void message(int category, const QString &message, bool html = false); /** Set number of connections shown in the UI */ @@ -79,6 +89,8 @@ public slots: void showNetwork(); /** Switch to peers tab and show */ void showPeers(); + /** Switch to wallet-repair tab and show */ + void showRepair(); /** Open external (default) editor with dash.conf */ void showConfEditor(); /** Handle selection of peer in peers list */