Skip to content

Commit

Permalink
Merge #1626: [GUI][Bug] Notify transaction creation failure reason
Browse files Browse the repository at this point in the history
05981ea [GUI] Add more explicative message for "Transaction too large" (random-zebra)
93ddc2d [GUI] Notify generic send error only when specific reason is empty (random-zebra)
fd96cf7 [GUI][Bug] Connect message signal emitted from wallet model (random-zebra)

Pull request description:

  Triggered by #1619

  - first commit fixes a bug where the `WalletModel::message` signal was not connected to pwidget, therefore the message with `strFailReason` -fired by `prepareTransaction`:
  https://github.com/PIVX-Project/PIVX/blob/f295ee4e4e089f76341a4f93058cfab3e974ccb9/src/qt/walletmodel.cpp#L526-L533
   was never displayed, and the user was presented only with the generic "Transaction creation failed!" -fired by `ProcessSendCoinsReturnAndInform`:
  https://github.com/PIVX-Project/PIVX/blob/f295ee4e4e089f76341a4f93058cfab3e974ccb9/src/qt/pivx/guitransactionsutils.cpp#L74-L79

  - second commit addresses the fact that, with the previous commit, the user is now presented with two consecutive dialogs: "Transaction too big" and "Transaction creation failed!", and merges them into one single message (which is already followed by a SnackBar with "Cannot create transaction").

  - third commit adds a clearer message when `strFailReason` is "Transaction too big" (which might be frequent e.g. sweeping a big number of masternode rewards or dust outputs). Reviewers are encouraged to offer better wording.

  Closes #1619

ACKs for top commit:
  Fuzzbawls:
    utACK 05981ea
  furszy:
    utACK 05981ea

Tree-SHA512: a922b5d20451cde8353b610f3c66767d58fee95c64526294050fef57373f5e92d320799bd3bccef781e6b4bddbeeedbe134632c9cd9e7deb53c77258ece9afc9
  • Loading branch information
furszy committed May 23, 2020
2 parents e0239f8 + 05981ea commit 5b064a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/qt/pivx/guitransactionsutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace GuiTransactionsUtils {
"Duplicate address found, can only send to each address once per send operation.");
break;
case WalletModel::TransactionCreationFailed:
retStr = parent->translate("Transaction creation failed!");
informType = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::TransactionCommitFailed:
Expand Down
1 change: 1 addition & 0 deletions src/qt/pivx/pivxgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ bool PIVXGUI::addWallet(const QString& name, WalletModel* walletModel)
}

// Connect actions..
connect(walletModel, &WalletModel::message, this, &PIVXGUI::message);
connect(masterNodesWidget, &MasterNodesWidget::message, this, &PIVXGUI::message);
connect(coldStakingWidget, &ColdStakingWidget::message, this, &PIVXGUI::message);
connect(topBar, &TopBar::message, this, &PIVXGUI::message);
Expand Down
8 changes: 6 additions & 2 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,12 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
if ((total + nFeeRequired) > nBalance) {
return SendCoinsReturn(AmountWithFeeExceedsBalance);
}
Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
CClientUIInterface::MSG_ERROR);

Q_EMIT message(tr("Send Coins"), tr("Transaction creation failed!\n%1").arg(
strFailReason == "Transaction too large" ?
tr("The size of the transaction is too big.\nSelect fewer inputs with coin control.") :
QString::fromStdString(strFailReason)),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class WalletModel : public QObject
AmountExceedsBalance,
AmountWithFeeExceedsBalance,
DuplicateAddress,
TransactionCreationFailed, // Error returned when wallet is still locked
TransactionCreationFailed,
TransactionCommitFailed,
StakingOnlyUnlocked,
InsaneFee,
Expand Down Expand Up @@ -360,7 +360,7 @@ class WalletModel : public QObject
void requireUnlock();

// Fired when a message should be reported to the user
void message(const QString& title, const QString& message, unsigned int style);
void message(const QString& title, const QString& body, unsigned int style, bool* ret = nullptr);

// Coins sent: from wallet, to recipient, in (serialized) transaction:
void coinsSent(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction);
Expand Down

0 comments on commit 5b064a6

Please sign in to comment.