From 3fdbdc5de07bf8531ec411a9995da56fb937e9c6 Mon Sep 17 00:00:00 2001 From: adityapk00 Date: Sat, 23 Mar 2019 10:55:13 -0700 Subject: [PATCH] Handle 0-balance edge cases --- src/requestdialog.cpp | 11 ++- src/requestdialog.ui | 175 ++++++++++++++++++++++-------------------- 2 files changed, 98 insertions(+), 88 deletions(-) diff --git a/src/requestdialog.cpp b/src/requestdialog.cpp index 1adcb75..406d71a 100644 --- a/src/requestdialog.cpp +++ b/src/requestdialog.cpp @@ -33,8 +33,6 @@ void RequestDialog::setupDialog(MainWindow* main, QDialog* d, Ui_RequestDialog* for (auto addr : *main->getRPC()->getAllZAddresses()) { auto bal = main->getRPC()->getAllBalances()->value(addr); - if (bal == 0) - continue; if (Settings::getInstance()->isSaplingAddress(addr)) { req->cmbMyAddress->addItem(addr, bal); } @@ -126,7 +124,12 @@ void RequestDialog::showRequestZcash(MainWindow* main) { + "?amt=0.0001" + "&memo=" + QUrl::toPercentEncoding(memoURI); - qDebug() << "Paying " << sendURI; - main->payZcashURI(sendURI, req.cmbMyAddress->currentText()); + // If the disclosed address in the memo doesn't have a balance, then we can't send the Tx from that address, + QString payFrom = ""; + if (main->getRPC()->getAllBalances()->value(req.cmbMyAddress->currentText()) > 0) { + payFrom = req.cmbMyAddress->currentText(); + } + + main->payZcashURI(sendURI, payFrom); } } diff --git a/src/requestdialog.ui b/src/requestdialog.ui index db1a3cc..d50db6d 100644 --- a/src/requestdialog.ui +++ b/src/requestdialog.ui @@ -14,16 +14,6 @@ Payment Request - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -34,46 +24,14 @@ - - - - - - - - - + + Qt::Horizontal - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - z address - - - - - + Qt::Vertical @@ -86,16 +44,6 @@ - - - - 0 / 512 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -109,26 +57,8 @@ - - - - Qt::Horizontal - - - - - - - Memo - - - - - - - Qt::Horizontal - - + + @@ -161,20 +91,20 @@ - - - - Amount USD + + + + Qt::Horizontal - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + - Amount in + Memo @@ -185,9 +115,86 @@ + + + + Qt::Horizontal + + + + + + + 0 / 512 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Amount in + + + + + + + Amount USD + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + z address + + + + + + + The recipient will see this address in the "to" field when they pay your request. + + +