Create new rpc connection during shutdown if we don't have one and debug logging

This commit is contained in:
Duke Leto
2022-02-17 11:27:17 -05:00
parent fd2fb3757a
commit 42b5d182ee
2 changed files with 17 additions and 4 deletions

View File

@@ -1987,6 +1987,11 @@ void Controller::refreshHUSHPrice()
void Controller::shutdownhushd() void Controller::shutdownhushd()
{ {
// Save the wallet and exit the lightclient library cleanly. // Save the wallet and exit the lightclient library cleanly.
if (!zrpc) {
zrpc = new LiteInterface();
qDebug() << __func__ << ": created new rpc connection zrpc=" << zrpc;
}
if (zrpc && zrpc->haveConnection()) if (zrpc && zrpc->haveConnection())
{ {
QDialog d(main); QDialog d(main);
@@ -2018,13 +2023,13 @@ void Controller::shutdownhushd()
if (!finished) if (!finished)
d.accept(); d.accept();
finished = true; finished = true;
qDebug() << "saveWallet during shutdownhushd"; qDebug() << __func__ << ": saveWallet finished";
}); });
if (!finished) if (!finished)
d.exec(); d.exec();
} else { } else {
qDebug() << "No zrpc object, unclean shutdown and unable to call saveWallet!"; qDebug() << __func__ << ": No zrpc object, unclean shutdown and unable to call saveWallet!";
} }
} }

View File

@@ -434,8 +434,12 @@ void MainWindow::closeEvent(QCloseEvent* event) {
void MainWindow::closeEventpw(QCloseEvent* event) { void MainWindow::closeEventpw(QCloseEvent* event) {
// Let the RPC know to shut down any running service. // Let the RPC know to shut down any running service.
qDebug() << __func__ << ": event=" << event; qDebug() << __func__ << ": event=" << event << " this=" << this;
rpc->shutdownhushd(); if (rpc) {
rpc->shutdownhushd();
} else {
qDebug() << __func__ << ": invalid rpc object!";
}
} }
void MainWindow::encryptWallet() { void MainWindow::encryptWallet() {
@@ -444,6 +448,8 @@ void MainWindow::encryptWallet() {
Ui_encryptionDialog ed; Ui_encryptionDialog ed;
ed.setupUi(&d); ed.setupUi(&d);
qDebug() << __func__ << ": start";
// Handle edits on the password box // Handle edits on the password box
auto fnPasswordEdited = [=](const QString&) { auto fnPasswordEdited = [=](const QString&) {
@@ -500,6 +506,7 @@ void MainWindow::encryptWallet() {
QString("Please close some other programs to free up memory and try again"), QString("Please close some other programs to free up memory and try again"),
QMessageBox::Ok QMessageBox::Ok
); );
qDebug() << __func__ << ": out of memory!";
exit(1); exit(1);
} }
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex(); QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
@@ -520,6 +527,7 @@ void MainWindow::encryptWallet() {
QMessageBox::Ok QMessageBox::Ok
); );
} }
qDebug() << __func__ << ": finish";
} }
void MainWindow::removeWalletEncryption() { void MainWindow::removeWalletEncryption() {