Browse Source

Pick from address for request payments

pull/45/head
adityapk00 5 years ago
parent
commit
ce2621abdf
  1. 1
      .gitignore
  2. 9
      src/mainwindow.cpp
  3. 2
      src/mainwindow.h
  4. 28
      src/requestdialog.cpp
  5. 2
      src/requestdialog.h
  6. 156
      src/requestdialog.ui
  7. 17
      src/settings.ui

1
.gitignore

@ -36,3 +36,4 @@ workspace.code-workspace
*.mak
zcashd
IDEWorkspaceChecks.plist
*.sln

9
src/mainwindow.cpp

@ -795,8 +795,9 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) {
// Pay the Zcash URI by showing a confirmation window. If the URI parameter is empty, the UI
// will prompt for one.
void MainWindow::payZcashURI(QString uri) {
// will prompt for one. If the myAddr is empty, then the default from address is used to send
// the transaction.
void MainWindow::payZcashURI(QString uri, QString myAddr) {
// If the Payments UI is not ready (i.e, all balances have not loaded), defer the payment URI
if (!uiPaymentsReady) {
qDebug() << "Payment UI not ready, waiting for UI to pay URI";
@ -825,6 +826,10 @@ void MainWindow::payZcashURI(QString uri) {
// Now, set the fields on the send tab
removeExtraAddresses();
if (!myAddr.isEmpty()) {
ui->inputsCombo->setCurrentText(myAddr);
}
ui->Address1->setText(paymentInfo.addr);
ui->Address1->setCursorPosition(0);
ui->Amount1->setText(Settings::getDecimalString(paymentInfo.amt.toDouble()));

2
src/mainwindow.h

@ -54,7 +54,7 @@ public:
void stopWebsocket();
void balancesReady();
void payZcashURI(QString uri = "");
void payZcashURI(QString uri = "", QString myAddr = "");
void updateLabels();
void updateTAddrCombo(bool checked);

28
src/requestdialog.cpp

@ -6,6 +6,7 @@
#include "rpc.h"
#include "settings.h"
#include "precompiled.h"
RequestDialog::RequestDialog(QWidget *parent) :
QDialog(parent),
@ -19,13 +20,26 @@ RequestDialog::~RequestDialog()
delete ui;
}
void RequestDialog::setupDialog(QDialog* d, Ui_RequestDialog* req) {
void RequestDialog::setupDialog(MainWindow* main, QDialog* d, Ui_RequestDialog* req) {
req->setupUi(d);
Settings::saveRestore(d);
// Setup
req->txtMemo->setLenDisplayLabel(req->lblMemoLen);
req->lblAmount->setText(req->lblAmount->text() + Settings::getTokenName());
if (!main || !main->getRPC() || !main->getRPC()->getAllZAddresses() || !main->getRPC()->getAllBalances())
return;
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);
}
}
req->cmbMyAddress->setCurrentText(main->getRPC()->getDefaultSaplingAddress());
}
// Static method that shows an incoming payment request and prompts the user to pay it
@ -39,7 +53,7 @@ void RequestDialog::showPaymentConfirmation(MainWindow* main, QString paymentURI
QDialog d(main);
Ui_RequestDialog req;
setupDialog(&d, &req);
setupDialog(main, &d, &req);
// In the view mode, all fields are read-only
req.txtAmount->setReadOnly(true);
@ -60,7 +74,7 @@ void RequestDialog::showPaymentConfirmation(MainWindow* main, QString paymentURI
req.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Pay"));
if (d.exec() == QDialog::Accepted) {
main->payZcashURI(paymentURI);
main->payZcashURI(paymentURI, req.cmbMyAddress->currentText());
}
}
@ -68,8 +82,8 @@ void RequestDialog::showPaymentConfirmation(MainWindow* main, QString paymentURI
void RequestDialog::showRequestZcash(MainWindow* main) {
QDialog d(main);
Ui_RequestDialog req;
req.setupUi(&d);
Settings::saveRestore(&d);
setupDialog(main, &d, &req);
// Setup the Label completer for the Address
req.txtFrom->setCompleter(main->getLabelCompleter());
@ -104,7 +118,7 @@ void RequestDialog::showRequestZcash(MainWindow* main) {
if (d.exec() == QDialog::Accepted) {
// Construct a zcash Payment URI with the data and pay it immediately.
QString memoURI = "zcash:" + main->getRPC()->getDefaultSaplingAddress()
QString memoURI = "zcash:" + req.cmbMyAddress->currentText()
+ "?amt=" + Settings::getDecimalString(req.txtAmount->text().toDouble())
+ "&memo=" + QUrl::toPercentEncoding(req.txtMemo->toPlainText());
@ -113,6 +127,6 @@ void RequestDialog::showRequestZcash(MainWindow* main) {
+ "&memo=" + QUrl::toPercentEncoding(memoURI);
qDebug() << "Paying " << sendURI;
main->payZcashURI(sendURI);
main->payZcashURI(sendURI, req.cmbMyAddress->currentText());
}
}

2
src/requestdialog.h

@ -19,7 +19,7 @@ public:
static void showRequestZcash(MainWindow* main);
static void showPaymentConfirmation(MainWindow* main, QString paymentURI);
static void setupDialog(QDialog* d, Ui_RequestDialog* req);
static void setupDialog(MainWindow* main, QDialog* d, Ui_RequestDialog* req);
private:
Ui::RequestDialog *ui;
};

156
src/requestdialog.ui

@ -6,29 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>1052</width>
<height>509</height>
<width>588</width>
<height>384</height>
</rect>
</property>
<property name="windowTitle">
<string>Payment Request</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="8" column="1" colspan="3">
<widget class="MemoEdit" name="txtMemo"/>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer">
<item row="15" column="2" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</spacer>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QLineEdit" name="txtAmount">
@ -40,16 +34,58 @@
</property>
</widget>
</item>
<item row="13" column="2" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<item row="7" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="txtFrom">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>z address</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="MemoEdit" name="txtMemo"/>
</item>
<item row="12" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="2" colspan="2">
<widget class="QLabel" name="lblMemoLen">
<property name="text">
@ -60,6 +96,26 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLabel" name="lblSaplingWarning">
<property name="styleSheet">
<string notr="true">color: red;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="14" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@ -67,19 +123,10 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="txtFrom">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>z address</string>
<item row="10" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -114,26 +161,6 @@
</item>
</layout>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLabel" name="lblSaplingWarning">
<property name="styleSheet">
<string notr="true">color: red;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QLabel" name="txtAmountUSD">
<property name="text">
@ -151,25 +178,15 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="11" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>My Address</string>
</property>
</widget>
</item>
<item row="10" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<item row="11" column="1" colspan="3">
<widget class="AddressCombo" name="cmbMyAddress"/>
</item>
</layout>
</widget>
@ -179,6 +196,11 @@
<extends>QPlainTextEdit</extends>
<header>memoedit.h</header>
</customwidget>
<customwidget>
<class>AddressCombo</class>
<extends>QComboBox</extends>
<header>addresscombo.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtFrom</tabstop>

17
src/settings.ui

@ -325,16 +325,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Rescan the blockchain for any missing wallet transactions and to correct your wallet balance. This will take several hours. You need to restart ZecWallet for this to take effect</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
@ -345,13 +335,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkRescan">
<property name="text">
<string>Rescan</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="Line" name="line_4">
<property name="orientation">

Loading…
Cancel
Save