Pick from address for request payments
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -36,3 +36,4 @@ workspace.code-workspace
|
|||||||
*.mak
|
*.mak
|
||||||
zcashd
|
zcashd
|
||||||
IDEWorkspaceChecks.plist
|
IDEWorkspaceChecks.plist
|
||||||
|
*.sln
|
||||||
|
|||||||
@@ -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
|
// Pay the Zcash URI by showing a confirmation window. If the URI parameter is empty, the UI
|
||||||
// will prompt for one.
|
// will prompt for one. If the myAddr is empty, then the default from address is used to send
|
||||||
void MainWindow::payZcashURI(QString uri) {
|
// 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 the Payments UI is not ready (i.e, all balances have not loaded), defer the payment URI
|
||||||
if (!uiPaymentsReady) {
|
if (!uiPaymentsReady) {
|
||||||
qDebug() << "Payment UI not ready, waiting for UI to pay URI";
|
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
|
// Now, set the fields on the send tab
|
||||||
removeExtraAddresses();
|
removeExtraAddresses();
|
||||||
|
if (!myAddr.isEmpty()) {
|
||||||
|
ui->inputsCombo->setCurrentText(myAddr);
|
||||||
|
}
|
||||||
|
|
||||||
ui->Address1->setText(paymentInfo.addr);
|
ui->Address1->setText(paymentInfo.addr);
|
||||||
ui->Address1->setCursorPosition(0);
|
ui->Address1->setCursorPosition(0);
|
||||||
ui->Amount1->setText(Settings::getDecimalString(paymentInfo.amt.toDouble()));
|
ui->Amount1->setText(Settings::getDecimalString(paymentInfo.amt.toDouble()));
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
void stopWebsocket();
|
void stopWebsocket();
|
||||||
|
|
||||||
void balancesReady();
|
void balancesReady();
|
||||||
void payZcashURI(QString uri = "");
|
void payZcashURI(QString uri = "", QString myAddr = "");
|
||||||
|
|
||||||
void updateLabels();
|
void updateLabels();
|
||||||
void updateTAddrCombo(bool checked);
|
void updateTAddrCombo(bool checked);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
|
|
||||||
RequestDialog::RequestDialog(QWidget *parent) :
|
RequestDialog::RequestDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@@ -19,13 +20,26 @@ RequestDialog::~RequestDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestDialog::setupDialog(QDialog* d, Ui_RequestDialog* req) {
|
void RequestDialog::setupDialog(MainWindow* main, QDialog* d, Ui_RequestDialog* req) {
|
||||||
req->setupUi(d);
|
req->setupUi(d);
|
||||||
Settings::saveRestore(d);
|
Settings::saveRestore(d);
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
req->txtMemo->setLenDisplayLabel(req->lblMemoLen);
|
req->txtMemo->setLenDisplayLabel(req->lblMemoLen);
|
||||||
req->lblAmount->setText(req->lblAmount->text() + Settings::getTokenName());
|
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
|
// 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);
|
QDialog d(main);
|
||||||
Ui_RequestDialog req;
|
Ui_RequestDialog req;
|
||||||
setupDialog(&d, &req);
|
setupDialog(main, &d, &req);
|
||||||
|
|
||||||
// In the view mode, all fields are read-only
|
// In the view mode, all fields are read-only
|
||||||
req.txtAmount->setReadOnly(true);
|
req.txtAmount->setReadOnly(true);
|
||||||
@@ -60,7 +74,7 @@ void RequestDialog::showPaymentConfirmation(MainWindow* main, QString paymentURI
|
|||||||
req.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Pay"));
|
req.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Pay"));
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted) {
|
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) {
|
void RequestDialog::showRequestZcash(MainWindow* main) {
|
||||||
QDialog d(main);
|
QDialog d(main);
|
||||||
Ui_RequestDialog req;
|
Ui_RequestDialog req;
|
||||||
req.setupUi(&d);
|
|
||||||
Settings::saveRestore(&d);
|
setupDialog(main, &d, &req);
|
||||||
|
|
||||||
// Setup the Label completer for the Address
|
// Setup the Label completer for the Address
|
||||||
req.txtFrom->setCompleter(main->getLabelCompleter());
|
req.txtFrom->setCompleter(main->getLabelCompleter());
|
||||||
@@ -104,7 +118,7 @@ void RequestDialog::showRequestZcash(MainWindow* main) {
|
|||||||
|
|
||||||
if (d.exec() == QDialog::Accepted) {
|
if (d.exec() == QDialog::Accepted) {
|
||||||
// Construct a zcash Payment URI with the data and pay it immediately.
|
// 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())
|
+ "?amt=" + Settings::getDecimalString(req.txtAmount->text().toDouble())
|
||||||
+ "&memo=" + QUrl::toPercentEncoding(req.txtMemo->toPlainText());
|
+ "&memo=" + QUrl::toPercentEncoding(req.txtMemo->toPlainText());
|
||||||
|
|
||||||
@@ -113,6 +127,6 @@ void RequestDialog::showRequestZcash(MainWindow* main) {
|
|||||||
+ "&memo=" + QUrl::toPercentEncoding(memoURI);
|
+ "&memo=" + QUrl::toPercentEncoding(memoURI);
|
||||||
|
|
||||||
qDebug() << "Paying " << sendURI;
|
qDebug() << "Paying " << sendURI;
|
||||||
main->payZcashURI(sendURI);
|
main->payZcashURI(sendURI, req.cmbMyAddress->currentText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
static void showRequestZcash(MainWindow* main);
|
static void showRequestZcash(MainWindow* main);
|
||||||
static void showPaymentConfirmation(MainWindow* main, QString paymentURI);
|
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:
|
private:
|
||||||
Ui::RequestDialog *ui;
|
Ui::RequestDialog *ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,29 +6,23 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1052</width>
|
<width>588</width>
|
||||||
<height>509</height>
|
<height>384</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Payment Request</string>
|
<string>Payment Request</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="8" column="1" colspan="3">
|
<item row="15" column="2" colspan="2">
|
||||||
<widget class="MemoEdit" name="txtMemo"/>
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
</item>
|
|
||||||
<item row="10" column="0">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="standardButtons">
|
||||||
<size>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1" colspan="3">
|
<item row="5" column="1" colspan="3">
|
||||||
<widget class="QLineEdit" name="txtAmount">
|
<widget class="QLineEdit" name="txtAmount">
|
||||||
@@ -40,32 +34,25 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="2" colspan="2">
|
<item row="7" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="3">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="sizeHint" stdset="0">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
|
||||||
<item row="9" column="2" colspan="2">
|
|
||||||
<widget class="QLabel" name="lblMemoLen">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">0 / 512</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Memo</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="3">
|
<item row="1" column="1" colspan="3">
|
||||||
<widget class="QLineEdit" name="txtFrom">
|
<widget class="QLineEdit" name="txtFrom">
|
||||||
@@ -83,6 +70,66 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
||||||
|
<string notr="true">0 / 512</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</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">
|
||||||
|
<string>Memo</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="4">
|
||||||
|
<widget class="Line" name="line_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="lblAddress">
|
<widget class="QLabel" name="lblAddress">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -114,26 +161,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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">
|
<item row="6" column="1" colspan="3">
|
||||||
<widget class="QLabel" name="txtAmountUSD">
|
<widget class="QLabel" name="txtAmountUSD">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -151,25 +178,15 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="0" colspan="4">
|
<item row="11" column="0">
|
||||||
<widget class="Line" name="line">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>My Address</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="3">
|
<item row="11" column="1" colspan="3">
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="AddressCombo" name="cmbMyAddress"/>
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -179,6 +196,11 @@
|
|||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
<header>memoedit.h</header>
|
<header>memoedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AddressCombo</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>addresscombo.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>txtFrom</tabstop>
|
<tabstop>txtFrom</tabstop>
|
||||||
|
|||||||
@@ -325,16 +325,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QLabel" name="label_11">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -345,13 +335,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="8" column="0">
|
||||||
<widget class="Line" name="line_4">
|
<widget class="Line" name="line_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user