From c6c97e0f4e3d9d8d5b8a1e60174e9ff11e70b6c1 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 24 Oct 2013 16:02:39 +0200 Subject: [Qt] Rework of payment request UI (mainly for insecure pr) - this shows insecure (unsecured) payment requests in a new yellowish colored UI (based on the secure payment request UI) instead of our normal payment UI - allows us to receive paymentACK messages for insecure payment requests - allows us to handle expirations for insecure payment request - changed walletmodel, so that all types of payment requests don't touch the addressbook --- src/qt/forms/sendcoinsdialog.ui | 11 +- src/qt/forms/sendcoinsentry.ui | 514 +++++++++++++++++++++++++++++++++++++++- src/qt/paymentserver.cpp | 74 +++--- src/qt/sendcoinsdialog.cpp | 10 +- src/qt/sendcoinsentry.cpp | 66 ++++-- src/qt/walletmodel.cpp | 4 +- src/qt/walletmodel.h | 12 +- 7 files changed, 609 insertions(+), 82 deletions(-) (limited to 'src/qt') diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 67ea45d2fd..7547931ff1 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -29,7 +29,16 @@ - + + 0 + + + 0 + + + 0 + + 0 diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index db742d633d..199a14598a 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -10,13 +10,19 @@ 150 + + Qt::TabFocus + false 0 - + + + This is a normal payment. + QFrame::StyledPanel @@ -143,7 +149,495 @@ - + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 191 + + + + + + + 127 + 127 + 63 + + + + + + + 170 + 170 + 84 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 127 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 191 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 191 + + + + + + + 127 + 127 + 63 + + + + + + + 170 + 170 + 84 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 127 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 191 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 127 + 127 + 63 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 191 + + + + + + + 127 + 127 + 63 + + + + + + + 170 + 170 + 84 + + + + + + + 127 + 127 + 63 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 63 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 127 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + This is an unverified payment request. + + + true + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + 12 + + + + + Memo: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Amount: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Pay To: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + + + + + 0 + + + + + + + + + + Qt::PlainText + + + + + + @@ -586,6 +1080,9 @@ + + This is a verified payment request. + true @@ -607,35 +1104,26 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - addAsLabel - - A&mount: + Amount: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - payAmount_s - - Pay &To: + Pay To: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - payTo_s - diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 0f386680ac..50847c4c48 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -280,9 +280,6 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : connect(this, SIGNAL(receivedPaymentACK(QString)), this, SLOT(handlePaymentACK(QString))); } } - - // netManager is null until uiReady() is called - netManager = NULL; } PaymentServer::~PaymentServer() @@ -450,9 +447,36 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList > sendingTos = request.getPayTo(); - qint64 totalAmount = 0; + recipients.append(SendCoinsRecipient()); + + recipients[0].paymentRequest = request; + recipients[0].label = GUIUtil::HtmlEscape(request.getDetails().memo()); // Todo: Change to .message once available + + request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant); + + QList > sendingTos = request.getPayTo(); + + int i = 0; foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) { + // Extract and check destination addresses + CTxDestination dest; + if (ExtractDestination(sendingTo.first, dest)) { + // Append destination address (for payment requests .address is used ONLY for GUI display) + recipients[0].address.append(QString::fromStdString(CBitcoinAddress(dest).ToString())); + if (i < sendingTos.size() - 1) // prevent new-line for last entry + recipients[0].address.append("
"); + } + else if (!recipients[0].authenticatedMerchant.isEmpty()){ + // Insecure payments to custom bitcoin addresses are not supported + // (there is no good way to tell the user where they are paying in a way + // they'd have a chance of understanding). + emit message(tr("Payment request error"), + tr("Unverified payment requests to custom payment scripts are unsupported."), + CClientUIInterface::MSG_ERROR); + return false; + } + + // Extract and check amounts CTxOut txOut(sendingTo.second, sendingTo.first); if (txOut.IsDust(CTransaction::nMinRelayTxFee)) { QString msg = tr("Requested payment amount of %1 is too small (considered dust).") @@ -463,43 +487,17 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList"); - recipients.append(SendCoinsRecipient()); - - if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) { - recipients[0].paymentRequest = request; - recipients[0].amount = totalAmount; - qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant; + if (!recipient.authenticatedMerchant.isEmpty()) { + qDebug() << "PaymentServer::processPaymentRequest : Secure payment request from " << recipient.authenticatedMerchant; } else { - recipients.clear(); - // Insecure payment requests may turn into more than one recipient if - // the merchant is requesting payment to more than one address. - for (int i = 0; i < sendingTos.size(); i++) { - std::pair& sendingTo = sendingTos[i]; - recipients.append(SendCoinsRecipient()); - recipients[i].amount = sendingTo.second; - QString memo = QString::fromStdString(request.getDetails().memo()); - recipients[i].label = GUIUtil::HtmlEscape(memo); - CTxDestination dest; - if (ExtractDestination(sendingTo.first, dest)) { - if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs - recipients[i].paymentRequest = request; - recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString()); - qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address; - } - else { - // Insecure payments to custom bitcoin addresses are not supported - // (there is no good way to tell the user where they are paying in a way - // they'd have a chance of understanding). - emit message(tr("Payment request error"), - tr("Insecure requests to custom payment scripts unsupported"), - CClientUIInterface::MSG_ERROR); - return false; - } - } + qDebug() << "PaymentServer::processPaymentRequest : Insecure payment request to " << addresses.join(", "); } return true; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 51304bc05c..56079bb35f 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -102,7 +102,7 @@ void SendCoinsDialog::on_sendButton_clicked() QString recipientElement; - if (rcp.authenticatedMerchant.isEmpty()) + if (!rcp.paymentRequest.IsInitialized()) // normal payment { if(rcp.label.length() > 0) // label with address { @@ -114,10 +114,14 @@ void SendCoinsDialog::on_sendButton_clicked() recipientElement = tr("%1 to %2").arg(amount, address); } } - else // just merchant + else if(!rcp.authenticatedMerchant.isEmpty()) // secure payment request { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); } + else // insecure payment request + { + recipientElement = tr("%1 to %2").arg(amount, address); + } formatted.append(recipientElement); } @@ -313,7 +317,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) { QString strSendCoins = tr("Send Coins"); - if (!rv.authenticatedMerchant.isEmpty()) { + if (rv.paymentRequest.IsInitialized()) { // Expired payment request? const payments::PaymentDetails& details = rv.paymentRequest.getDetails(); if (details.has_expires() && (int64)details.expires() < GetTime()) diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 2d42ecb568..e833274256 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -18,7 +18,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) : { ui->setupUi(this); - setCurrentWidget(ui->SendCoinsInsecure); + setCurrentWidget(ui->SendCoins); #ifdef Q_OS_MAC ui->payToLayout->setSpacing(4); @@ -28,10 +28,12 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) : ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); #endif - setFocusPolicy(Qt::TabFocus); setFocusProxy(ui->payTo); + // normal bitcoin address field GUIUtil::setupAddressWidget(ui->payTo, this); + // just a label for displaying bitcoin address(es) + ui->payTo_is->setFont(GUIUtil::bitcoinAddressFont()); } SendCoinsEntry::~SendCoinsEntry() @@ -67,7 +69,7 @@ void SendCoinsEntry::setModel(WalletModel *model) { this->model = model; - if(model && model->getOptionsModel()) + if (model && model->getOptionsModel()) connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); clear(); @@ -80,11 +82,15 @@ void SendCoinsEntry::setRemoveEnabled(bool enabled) void SendCoinsEntry::clear() { - // clear UI elements for insecure payments + // clear UI elements for normal payment ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); - // and the ones for secure payments just to be sure + // clear UI elements for insecure payment request + ui->payTo_is->clear(); + ui->memoTextLabel_is->clear(); + ui->payAmount_is->clear(); + // clear UI elements for secure payment request ui->payTo_s->clear(); ui->memoTextLabel_s->clear(); ui->payAmount_s->clear(); @@ -102,20 +108,23 @@ void SendCoinsEntry::on_deleteButton_clicked() bool SendCoinsEntry::validate() { + if (!model) + return false; + // Check input validity bool retval = true; - if (!recipient.authenticatedMerchant.isEmpty()) + // Skip checks for payment request + if (recipient.paymentRequest.IsInitialized()) return retval; - if (!ui->payTo->hasAcceptableInput() || - (model && !model->validateAddress(ui->payTo->text()))) + if (!ui->payTo->hasAcceptableInput() || !model->validateAddress(ui->payTo->text())) { ui->payTo->setValid(false); retval = false; } - if(!ui->payAmount->validate()) + if (!ui->payAmount->validate()) { retval = false; } @@ -131,10 +140,11 @@ bool SendCoinsEntry::validate() SendCoinsRecipient SendCoinsEntry::getValue() { - if (!recipient.authenticatedMerchant.isEmpty()) + // Payment request + if (recipient.paymentRequest.IsInitialized()) return recipient; - // User-entered or non-authenticated: + // Normal payment recipient.address = ui->payTo->text(); recipient.label = ui->addAsLabel->text(); recipient.amount = ui->payAmount->value(); @@ -156,22 +166,31 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { recipient = value; - if (recipient.authenticatedMerchant.isEmpty()) + if (recipient.paymentRequest.IsInitialized()) // payment request + { + if (recipient.authenticatedMerchant.isEmpty()) // insecure + { + ui->payTo_is->setText(recipient.address); + ui->memoTextLabel_is->setText(recipient.label); + ui->payAmount_is->setValue(recipient.amount); + ui->payAmount_is->setReadOnly(true); + setCurrentWidget(ui->SendCoins_InsecurePaymentRequest); + } + else // secure + { + ui->payTo_s->setText(recipient.authenticatedMerchant); + ui->memoTextLabel_s->setText(recipient.label); + ui->payAmount_s->setValue(recipient.amount); + ui->payAmount_s->setReadOnly(true); + setCurrentWidget(ui->SendCoins_SecurePaymentRequest); + } + } + else // normal payment { ui->payTo->setText(recipient.address); ui->addAsLabel->setText(recipient.label); ui->payAmount->setValue(recipient.amount); } - else - { - const payments::PaymentDetails& details = recipient.paymentRequest.getDetails(); - - ui->payTo_s->setText(recipient.authenticatedMerchant); - ui->memoTextLabel_s->setText(QString::fromStdString(details.memo())); - ui->payAmount_s->setValue(recipient.amount); - ui->payAmount_s->setReadOnly(true); - setCurrentWidget(ui->SendCoinsSecure); - } } void SendCoinsEntry::setAddress(const QString &address) @@ -182,7 +201,7 @@ void SendCoinsEntry::setAddress(const QString &address) bool SendCoinsEntry::isClear() { - return ui->payTo->text().isEmpty() && ui->payTo_s->text().isEmpty(); + return ui->payTo->text().isEmpty() && ui->payTo_is->text().isEmpty() && ui->payTo_s->text().isEmpty(); } void SendCoinsEntry::setFocus() @@ -196,6 +215,7 @@ void SendCoinsEntry::updateDisplayUnit() { // Update payAmount with the current unit ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); + ui->payAmount_is->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); ui->payAmount_s->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); } } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 417bac9928..8086d6b5bb 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -258,8 +258,8 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran // and emit coinsSent signal for each recipient foreach(const SendCoinsRecipient &rcp, transaction.getRecipients()) { - // Don't touch the address book when we have a secure payment-request - if (rcp.authenticatedMerchant.isEmpty()) + // Don't touch the address book when we have a payment request + if (!rcp.paymentRequest.IsInitialized()) { std::string strAddress = rcp.address.toStdString(); CTxDestination dest = CBitcoinAddress(strAddress).Get(); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 2e99eaddcb..59227bb743 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -25,14 +25,22 @@ public: explicit SendCoinsRecipient(const QString &addr, const QString &label, quint64 amount, const QString &message): address(addr), label(label), amount(amount), message(message) {} + // If from an insecure payment request, this is used for storing + // the addresses, e.g. address-A
address-B
address-C. + // Info: As we don't need to process addresses in here when using + // payment requests, we can abuse it for displaying an address list. + // Todo: This is a hack, should be replaced with a cleaner solution! QString address; + // If from a payment request, this is used for storing the memo + // Todo: This is a hack, should be replaced with a cleaner solution! QString label; qint64 amount; QString message; // If from a payment request, paymentRequest.IsInitialized() will be true PaymentRequestPlus paymentRequest; - QString authenticatedMerchant; // Empty if no authentication or invalid signature/cert/etc. + // Empty if no authentication or invalid signature/cert/etc. + QString authenticatedMerchant; }; /** Interface to Bitcoin wallet from Qt view code. */ @@ -160,7 +168,7 @@ signals: // this means that the unlocking failed or was cancelled. void requireUnlock(); - // Asynchronous message notification + // Fired when a message should be reported to the user void message(const QString &title, const QString &message, unsigned int style); // Coins sent: from wallet, to recipient, in (serialized) transaction: -- cgit v1.2.3 From 983cef48027f1bdf651c19d72cf615cf4345dbe6 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sun, 27 Oct 2013 21:52:01 +0100 Subject: payment-request UI: use SendCoinsRecipient.message for memo --- src/qt/paymentserver.cpp | 2 +- src/qt/sendcoinsentry.cpp | 4 ++-- src/qt/walletmodel.h | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/qt') diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 50847c4c48..c113c0ff13 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -450,7 +450,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QListpayTo_is->setText(recipient.address); - ui->memoTextLabel_is->setText(recipient.label); + ui->memoTextLabel_is->setText(recipient.message); ui->payAmount_is->setValue(recipient.amount); ui->payAmount_is->setReadOnly(true); setCurrentWidget(ui->SendCoins_InsecurePaymentRequest); @@ -179,7 +179,7 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value) else // secure { ui->payTo_s->setText(recipient.authenticatedMerchant); - ui->memoTextLabel_s->setText(recipient.label); + ui->memoTextLabel_s->setText(recipient.message); ui->payAmount_s->setValue(recipient.amount); ui->payAmount_s->setReadOnly(true); setCurrentWidget(ui->SendCoins_SecurePaymentRequest); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 59227bb743..467c3dea12 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -31,10 +31,9 @@ public: // payment requests, we can abuse it for displaying an address list. // Todo: This is a hack, should be replaced with a cleaner solution! QString address; - // If from a payment request, this is used for storing the memo - // Todo: This is a hack, should be replaced with a cleaner solution! QString label; qint64 amount; + // If from a payment request, this is used for storing the memo QString message; // If from a payment request, paymentRequest.IsInitialized() will be true -- cgit v1.2.3 From 952d2cdb56cb997b2158d363d8db3ee11fd49d11 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 28 Oct 2013 13:29:13 +0100 Subject: make processPaymentRequest() use a single SendCoinsRecipient - as one this pulls main purpose is to change a payment request to be displayed as a single sendcoins entry --- src/qt/paymentserver.cpp | 39 +++++++++++++++++---------------------- src/qt/paymentserver.h | 2 +- 2 files changed, 18 insertions(+), 23 deletions(-) (limited to 'src/qt') diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index c113c0ff13..71a5bb4550 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -375,6 +375,7 @@ void PaymentServer::handleURIOrFile(const QString& s) fetchRequest(fetchUrl); else qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl; + return; } @@ -385,18 +386,17 @@ void PaymentServer::handleURIOrFile(const QString& s) emit message(tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."), CClientUIInterface::ICON_WARNING); + return; } if (QFile::exists(s)) { PaymentRequestPlus request; - QList recipients; - if (readPaymentRequest(s, request) && processPaymentRequest(request, recipients)) { - foreach (const SendCoinsRecipient& recipient, recipients){ - emit receivedPaymentRequest(recipient); - } - } + SendCoinsRecipient recipient; + if (readPaymentRequest(s, request) && processPaymentRequest(request, recipient)) + emit receivedPaymentRequest(recipient); + return; } } @@ -442,17 +442,15 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl return request.parse(data); } -bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList& recipients) +bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient) { if (!optionsModel) return false; - recipients.append(SendCoinsRecipient()); - - recipients[0].paymentRequest = request; - recipients[0].message = GUIUtil::HtmlEscape(request.getDetails().memo()); + recipient.paymentRequest = request; + recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo()); - request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant); + request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant); QList > sendingTos = request.getPayTo(); @@ -462,11 +460,11 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList"); + recipient.address.append("
"); } - else if (!recipients[0].authenticatedMerchant.isEmpty()){ + else if (!recipient.authenticatedMerchant.isEmpty()){ // Insecure payments to custom bitcoin addresses are not supported // (there is no good way to tell the user where they are paying in a way // they'd have a chance of understanding). @@ -487,7 +485,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList recipients; - if (request.parse(data) && processPaymentRequest(request, recipients)) { - foreach (const SendCoinsRecipient& recipient, recipients) { - emit receivedPaymentRequest(recipient); - } - } + SendCoinsRecipient recipient; + if (request.parse(data) && processPaymentRequest(request, recipient)) + emit receivedPaymentRequest(recipient); else qDebug() << "PaymentServer::netRequestFinished : Error processing payment request"; diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 9f43571edc..b504e968e9 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -109,7 +109,7 @@ private slots: private: static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request); - bool processPaymentRequest(PaymentRequestPlus& request, QList& recipients); + bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient); void handleURIOrFile(const QString& s); void fetchRequest(const QUrl& url); -- cgit v1.2.3 From 395d0d5af017bbf6d432471075608efaf4104a03 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Wed, 30 Oct 2013 11:26:44 +0100 Subject: rework an ugly hack in processPaymentRequest() - use a QStringList to store valid addresses and format them for GUI and debug.log usage via .join() --- src/qt/paymentserver.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/qt') diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 71a5bb4550..b6c869a2c9 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -453,16 +453,14 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant); QList > sendingTos = request.getPayTo(); + QStringList addresses; - int i = 0; foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) { // Extract and check destination addresses CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) { - // Append destination address (for payment requests .address is used ONLY for GUI display) - recipient.address.append(QString::fromStdString(CBitcoinAddress(dest).ToString())); - if (i < sendingTos.size() - 1) // prevent new-line for last entry - recipient.address.append("
"); + // Append destination address + addresses.append(QString::fromStdString(CBitcoinAddress(dest).ToString())); } else if (!recipient.authenticatedMerchant.isEmpty()){ // Insecure payments to custom bitcoin addresses are not supported @@ -486,7 +484,6 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins } recipient.amount += sendingTo.second; - i++; } // Store addresses and format them to fit nicely into the GUI recipient.address = addresses.join("
"); -- cgit v1.2.3