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
This commit is contained in:
parent
983cef4802
commit
952d2cdb56
@ -375,6 +375,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
|||||||
fetchRequest(fetchUrl);
|
fetchRequest(fetchUrl);
|
||||||
else
|
else
|
||||||
qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl;
|
qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,18 +386,17 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
|||||||
emit message(tr("URI handling"),
|
emit message(tr("URI handling"),
|
||||||
tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
|
tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
|
||||||
CClientUIInterface::ICON_WARNING);
|
CClientUIInterface::ICON_WARNING);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QFile::exists(s))
|
if (QFile::exists(s))
|
||||||
{
|
{
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
QList<SendCoinsRecipient> recipients;
|
SendCoinsRecipient recipient;
|
||||||
if (readPaymentRequest(s, request) && processPaymentRequest(request, recipients)) {
|
if (readPaymentRequest(s, request) && processPaymentRequest(request, recipient))
|
||||||
foreach (const SendCoinsRecipient& recipient, recipients){
|
emit receivedPaymentRequest(recipient);
|
||||||
emit receivedPaymentRequest(recipient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,17 +442,15 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl
|
|||||||
return request.parse(data);
|
return request.parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<SendCoinsRecipient>& recipients)
|
bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient)
|
||||||
{
|
{
|
||||||
if (!optionsModel)
|
if (!optionsModel)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
recipients.append(SendCoinsRecipient());
|
recipient.paymentRequest = request;
|
||||||
|
recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo());
|
||||||
|
|
||||||
recipients[0].paymentRequest = request;
|
request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant);
|
||||||
recipients[0].message = GUIUtil::HtmlEscape(request.getDetails().memo());
|
|
||||||
|
|
||||||
request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant);
|
|
||||||
|
|
||||||
QList<std::pair<CScript, qint64> > sendingTos = request.getPayTo();
|
QList<std::pair<CScript, qint64> > sendingTos = request.getPayTo();
|
||||||
|
|
||||||
@ -462,11 +460,11 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
|
|||||||
CTxDestination dest;
|
CTxDestination dest;
|
||||||
if (ExtractDestination(sendingTo.first, dest)) {
|
if (ExtractDestination(sendingTo.first, dest)) {
|
||||||
// Append destination address (for payment requests .address is used ONLY for GUI display)
|
// 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
|
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
|
// 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
|
// (there is no good way to tell the user where they are paying in a way
|
||||||
// they'd have a chance of understanding).
|
// they'd have a chance of understanding).
|
||||||
@ -487,7 +485,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
recipients[0].amount += sendingTo.second;
|
recipient.amount += sendingTo.second;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
// Store addresses and format them to fit nicely into the GUI
|
// Store addresses and format them to fit nicely into the GUI
|
||||||
@ -588,12 +586,9 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
|
|||||||
if (requestType == "PaymentRequest")
|
if (requestType == "PaymentRequest")
|
||||||
{
|
{
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
QList<SendCoinsRecipient> recipients;
|
SendCoinsRecipient recipient;
|
||||||
if (request.parse(data) && processPaymentRequest(request, recipients)) {
|
if (request.parse(data) && processPaymentRequest(request, recipient))
|
||||||
foreach (const SendCoinsRecipient& recipient, recipients) {
|
emit receivedPaymentRequest(recipient);
|
||||||
emit receivedPaymentRequest(recipient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
qDebug() << "PaymentServer::netRequestFinished : Error processing payment request";
|
qDebug() << "PaymentServer::netRequestFinished : Error processing payment request";
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request);
|
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 handleURIOrFile(const QString& s);
|
||||||
void fetchRequest(const QUrl& url);
|
void fetchRequest(const QUrl& url);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user