diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-07-22 16:50:39 +1000 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-08-22 16:18:25 +1000 |
commit | a41d5fe01947f2f878c055670986a165af800f9a (patch) | |
tree | 40eeada1ebc180f8e3669a7d164104686dc0c618 /src/qt/sendcoinsdialog.cpp | |
parent | 47d0534368fbf0e3fb2cad7d05d60501d29f62aa (diff) |
Payment Protocol: X509-validated payment requests
Add support for a Payment Protocol to Bitcoin-Qt.
Payment messages are protocol-buffer encoded and communicated over
http(s), so this adds a dependency on the Google protocol buffer
library, and requires Qt with OpenSSL support.
Diffstat (limited to 'src/qt/sendcoinsdialog.cpp')
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2c7bab2045..09d83b1a29 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -93,11 +93,26 @@ void SendCoinsDialog::on_sendButton_clicked() QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { + QString amount = BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount); + if (rcp.authenticatedMerchant.isEmpty()) + { + QString address = rcp.address; #if QT_VERSION < 0x050000 - formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); + QString to = Qt::escape(rcp.label); #else - formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address)); + QString to = rcp.label.toHtmlEscaped(); #endif + formatted.append(tr("<b>%1</b> to %2 (%3)").arg(amount, to, address)); + } + else + { +#if QT_VERSION < 0x050000 + QString merchant = Qt::escape(rcp.authenticatedMerchant); +#else + QString merchant = rcp.authenticatedMerchant.toHtmlEscaped(); +#endif + formatted.append(tr("<b>%1</b> to %2").arg(amount, merchant)); + } } fNewRecipientAllowed = false; @@ -292,20 +307,30 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) entry->setValue(rv); } -bool SendCoinsDialog::handleURI(const QString &uri) +bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) { - SendCoinsRecipient rv; - // URI has to be valid - if (GUIUtil::parseBitcoinURI(uri, &rv)) - { + if (!rv.authenticatedMerchant.isEmpty()) { + // Expired payment request? + const payments::PaymentDetails& details = rv.paymentRequest.getDetails(); + if (details.has_expires() && (int64)details.expires() < GetTime()) + { + QMessageBox::warning(this, tr("Send Coins"), + tr("Payment request expired")); + return false; + } + } + else { CBitcoinAddress address(rv.address.toStdString()); - if (!address.IsValid()) + if (!address.IsValid()) { + QString strAddress(address.ToString().c_str()); + QMessageBox::warning(this, tr("Send Coins"), + tr("Invalid payment address %1").arg(strAddress)); return false; - pasteEntry(rv); - return true; + } } - return false; + pasteEntry(rv); + return true; } void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance) |