diff options
Diffstat (limited to 'src/qt/sendcoinsdialog.cpp')
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2c7bab2045..9086f6614e 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -39,16 +39,17 @@ void SendCoinsDialog::setModel(WalletModel *model) { this->model = model; - for(int i = 0; i < ui->entries->count(); ++i) + if(model && model->getOptionsModel()) { - SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); - if(entry) + for(int i = 0; i < ui->entries->count(); ++i) { - entry->setModel(model); + SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); + if(entry) + { + entry->setModel(model); + } } - } - if(model && model->getOptionsModel()) - { + setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64))); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); @@ -93,11 +94,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 +308,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) |