mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
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.
This commit is contained in:
@@ -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))
|
||||
{
|
||||
CBitcoinAddress address(rv.address.toStdString());
|
||||
if (!address.IsValid())
|
||||
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;
|
||||
pasteEntry(rv);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
CBitcoinAddress address(rv.address.toStdString());
|
||||
if (!address.IsValid()) {
|
||||
QString strAddress(address.ToString().c_str());
|
||||
QMessageBox::warning(this, tr("Send Coins"),
|
||||
tr("Invalid payment address %1").arg(strAddress));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
pasteEntry(rv);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
|
||||
|
||||
Reference in New Issue
Block a user