aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2013-10-28 13:29:13 +0100
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2013-10-31 17:51:39 +0100
commit952d2cdb56cb997b2158d363d8db3ee11fd49d11 (patch)
treededc9bf6aff8e1cc54d86c5744d6cb1051ef5434 /src/qt
parent983cef48027f1bdf651c19d72cf615cf4345dbe6 (diff)
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
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/paymentserver.cpp39
-rw-r--r--src/qt/paymentserver.h2
2 files changed, 18 insertions, 23 deletions
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<SendCoinsRecipient> 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<SendCoinsRecipient>& 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<std::pair<CScript, qint64> > sendingTos = request.getPayTo();
@@ -462,11 +460,11 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
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()));
+ recipient.address.append(QString::fromStdString(CBitcoinAddress(dest).ToString()));
if (i < sendingTos.size() - 1) // prevent new-line for last entry
- recipients[0].address.append("<br />");
+ recipient.address.append("<br />");
}
- 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<Sen
return false;
}
- recipients[0].amount += sendingTo.second;
+ recipient.amount += sendingTo.second;
i++;
}
// Store addresses and format them to fit nicely into the GUI
@@ -588,12 +586,9 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
if (requestType == "PaymentRequest")
{
PaymentRequestPlus request;
- QList<SendCoinsRecipient> 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<SendCoinsRecipient>& recipients);
+ bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
void handleURIOrFile(const QString& s);
void fetchRequest(const QUrl& url);