From 07d398a7117db2000d57f7433c729427083d3a59 Mon Sep 17 00:00:00 2001 From: Arjun Date: Tue, 30 Jul 2019 10:43:56 -0700 Subject: [PATCH] Add empty amount check --- src/sendtab.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sendtab.cpp b/src/sendtab.cpp index eedfce0..7487d60 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -512,7 +512,12 @@ Tx MainWindow::createTxFromSendPage() { // If address is sprout, then we can't send change to sapling, because of turnstile. sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr); - double amt = ui->sendToWidgets->findChild(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble(); + QString amtStr = ui->sendToWidgets->findChild(QString("Amount") % QString::number(i+1))->text().trimmed(); + if (amtStr.isEmpty()) { + amtStr = "-1";; // The user didn't specify an amount + } + + double amt = amtStr.toDouble(); totalAmt += amt; QString memo = ui->sendToWidgets->findChild(QString("MemoTxt") % QString::number(i+1))->text().trimmed(); @@ -521,8 +526,7 @@ Tx MainWindow::createTxFromSendPage() { if (Settings::getInstance()->getAllowCustomFees()) { tx.fee = ui->minerFeeAmt->text().toDouble(); - } - else { + } else { tx.fee = Settings::getMinerFee(); } @@ -731,6 +735,8 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { // Send button clicked void MainWindow::sendButton() { + // Create a Tx from the values on the send tab. Note that this Tx object + // might not be valid yet. Tx tx = createTxFromSendPage(); QString error = doSendTxValidations(tx); @@ -810,7 +816,7 @@ QString MainWindow::doSendTxValidations(Tx tx) { // This technically shouldn't be possible, but issue #62 seems to have discovered a bug // somewhere, so just add a check to make sure. if (toAddr.amount < 0) { - return QString(tr("Amount '%1' is invalid!").arg(toAddr.amount)); + return QString(tr("Amount for address '%1' is invalid!").arg(toAddr.addr)); } }