Skip to content

Commit 3333e5a

Browse files
author
MarcoFalke
committed
[qt] Return useful error message on ATMP failure
1 parent d2143dc commit 3333e5a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
534534
msgParams.second = CClientUIInterface::MSG_ERROR;
535535
break;
536536
case WalletModel::TransactionCommitFailed:
537-
msgParams.first = tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
537+
msgParams.first = tr("The transaction was rejected with the following reason: %1").arg(sendCoinsReturn.reasonCommitFailed);
538538
msgParams.second = CClientUIInterface::MSG_ERROR;
539539
break;
540540
case WalletModel::AbsurdFee:

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
331331
CReserveKey *keyChange = transaction.getPossibleKeyChange();
332332
CValidationState state;
333333
if(!wallet->CommitTransaction(*newTx, *keyChange, g_connman.get(), state))
334-
return TransactionCommitFailed;
334+
return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(state.GetRejectReason()));
335335

336336
CTransaction* t = (CTransaction*)newTx;
337337
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);

src/qt/walletmodel.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ class WalletModel : public QObject
144144
// Return status record for SendCoins, contains error id + information
145145
struct SendCoinsReturn
146146
{
147-
SendCoinsReturn(StatusCode _status = OK):
148-
status(_status) {}
147+
SendCoinsReturn(StatusCode _status = OK, QString _reasonCommitFailed = "")
148+
: status(_status),
149+
reasonCommitFailed(_reasonCommitFailed)
150+
{
151+
}
149152
StatusCode status;
153+
QString reasonCommitFailed;
150154
};
151155

152156
// prepare transaction for getting txfee before sending coins

0 commit comments

Comments
 (0)