From 22a51207ae1e05d2a14663c8e583dd3ab307693b Mon Sep 17 00:00:00 2001 From: Cozz Lovan Date: Tue, 21 Jan 2014 23:39:29 +0100 Subject: [PATCH] [Qt] Show and store message of normal bitcoin:URI --- src/qt/forms/sendcoinsentry.ui | 17 +++++++++++++++++ src/qt/sendcoinsentry.cpp | 9 +++++++++ src/qt/transactiondesc.cpp | 5 +++++ src/qt/walletmodel.cpp | 2 ++ 4 files changed, 33 insertions(+) diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index b6cec5baf0..96c922af4d 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -141,6 +141,23 @@ + + + + Message: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::PlainText + + + diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 3f5d0cda3a..b4e74b078c 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -88,6 +88,9 @@ void SendCoinsEntry::clear() ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); + ui->messageTextLabel->clear(); + ui->messageTextLabel->hide(); + ui->messageLabel->hide(); // clear UI elements for insecure payment request ui->payTo_is->clear(); ui->memoTextLabel_is->clear(); @@ -148,6 +151,7 @@ SendCoinsRecipient SendCoinsEntry::getValue() recipient.address = ui->payTo->text(); recipient.label = ui->addAsLabel->text(); recipient.amount = ui->payAmount->value(); + recipient.message = ui->messageTextLabel->text(); return recipient; } @@ -188,6 +192,11 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value) } else // normal payment { + // message + ui->messageTextLabel->setText(recipient.message); + ui->messageTextLabel->setVisible(!recipient.message.isEmpty()); + ui->messageLabel->setVisible(!recipient.message.isEmpty()); + ui->payTo->setText(recipient.address); ui->addAsLabel->setText(recipient.label); ui->payAmount->setValue(recipient.amount); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index c0c4d53732..2c3a9e3a5c 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -224,6 +224,11 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int u strHTML += "" + tr("Transaction ID") + ": " + TransactionRecord::formatSubTxId(wtx.GetHash(), vout) + "
"; + // Message from normal bitcoin:URI (bitcoin:123...?message=example) + foreach (const PAIRTYPE(string, string)& r, wtx.vOrderForm) + if (r.first == "Message") + strHTML += "
" + tr("Message") + ":
" + GUIUtil::HtmlEscape(r.second, true) + "
"; + // // PaymentRequest info: // diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 14f29c933b..33db145db0 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -269,6 +269,8 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran rcp.paymentRequest.SerializeToString(&value); newTx->vOrderForm.push_back(make_pair(key, value)); } + else if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example) + newTx->vOrderForm.push_back(make_pair("Message", rcp.message.toStdString())); } CReserveKey *keyChange = transaction.getPossibleKeyChange();