Skip to content

Commit

Permalink
[GUI] Masternode creation wizard, creation fail event properly detail…
Browse files Browse the repository at this point in the history
…ing the failure cause in the subsequent error dialog.

Github-Pull: #1211
Rebased-From: fc9946c
  • Loading branch information
furszy authored and Fuzzbawls committed Jan 11, 2020
1 parent 447265f commit fa73ae3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/qt/pivx/masternodewizarddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,22 @@ bool MasterNodeWizardDialog::createMN(){

prepareStatus = walletModel->prepareTransaction(currentTransaction);

QString returnMsg = "Unknown error";
// process prepareStatus and on error generate message shown to user
processSendCoinsReturn(prepareStatus,
returnMsg = processSendCoinsReturn(prepareStatus,
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(),
currentTransaction.getTransactionFee()),
true
);

if (prepareStatus.status != WalletModel::OK) {
returnStr = tr("Prepare master node failed..");
returnStr = tr("Prepare master node failed.\n\n%1\n").arg(returnMsg);
return false;
}

WalletModel::SendCoinsReturn sendStatus = walletModel->sendCoins(currentTransaction);
// process sendStatus and on error generate message shown to user
processSendCoinsReturn(sendStatus);
returnMsg = processSendCoinsReturn(sendStatus);

if (sendStatus.status == WalletModel::OK) {
// now change the conf
Expand Down Expand Up @@ -286,7 +287,7 @@ bool MasterNodeWizardDialog::createMN(){
}
}
if (indexOut == -1) {
returnStr = tr("Invalid collaterall output index");
returnStr = tr("Invalid collateral output index");
return false;
}
std::string indexOutStr = std::to_string(indexOut);
Expand Down Expand Up @@ -323,6 +324,8 @@ bool MasterNodeWizardDialog::createMN(){
} else{
returnStr = tr("masternode.conf file doesn't exists");
}
} else {
returnStr = tr("Cannot send collateral transaction.\n\n%1").arg(returnMsg);
}
}
return false;
Expand Down Expand Up @@ -359,7 +362,7 @@ void MasterNodeWizardDialog::onBackClicked(){
}
}

void MasterNodeWizardDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn& sendCoinsReturn, const QString& msgArg, bool fPrepare)
QString MasterNodeWizardDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn& sendCoinsReturn, const QString& msgArg, bool fPrepare)
{
bool fAskForUnlock = false;

Expand Down Expand Up @@ -408,7 +411,7 @@ void MasterNodeWizardDialog::processSendCoinsReturn(const WalletModel::SendCoins
// included to prevent a compiler warning.
case WalletModel::OK:
default:
return;
return msgParams.first;
}

// Unlock wallet if it wasn't fully unlocked already
Expand All @@ -419,11 +422,11 @@ void MasterNodeWizardDialog::processSendCoinsReturn(const WalletModel::SendCoins
}
else {
// Wallet unlocked
return;
return msgParams.first;
}
}

inform(msgParams.first);
return msgParams.first;
}

void MasterNodeWizardDialog::inform(QString text){
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/masternodewizarddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private slots:
// Process WalletModel::SendCoinsReturn and generate a pair consisting
// of a message and message flags for use in emit message().
// Additional parameter msgArg can be used via .arg(msgArg).
void processSendCoinsReturn(const WalletModel::SendCoinsReturn& sendCoinsReturn, const QString& msgArg = QString(), bool fPrepare = false);
QString processSendCoinsReturn(const WalletModel::SendCoinsReturn& sendCoinsReturn, const QString& msgArg = QString(), bool fPrepare = false);
void inform(QString text);
void initBtn(std::initializer_list<QPushButton*> args);
};
Expand Down

0 comments on commit fa73ae3

Please sign in to comment.