From 8476d5d407645229faf3017b390f041ce0666247 Mon Sep 17 00:00:00 2001 From: Cozz Lovan Date: Tue, 14 Jan 2014 05:05:43 +0100 Subject: [Qt] Permanently store requested payments in wallet --- src/qt/walletmodel.h | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src/qt/walletmodel.h') diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 1a4d25615a..600bef346b 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -36,9 +36,9 @@ QT_END_NAMESPACE class SendCoinsRecipient { public: - explicit SendCoinsRecipient() : amount(0) { } + explicit SendCoinsRecipient() : amount(0), nVersion(SendCoinsRecipient::CURRENT_VERSION) { } explicit SendCoinsRecipient(const QString &addr, const QString &label, quint64 amount, const QString &message): - address(addr), label(label), amount(amount), message(message) {} + address(addr), label(label), amount(amount), message(message), nVersion(SendCoinsRecipient::CURRENT_VERSION) {} // If from an insecure payment request, this is used for storing // the addresses, e.g. address-A
address-B
address-C. @@ -55,6 +55,41 @@ public: PaymentRequestPlus paymentRequest; // Empty if no authentication or invalid signature/cert/etc. QString authenticatedMerchant; + + static const int CURRENT_VERSION=1; + int nVersion; + + IMPLEMENT_SERIALIZE + ( + SendCoinsRecipient* pthis = const_cast(this); + + std::string sAddress = pthis->address.toStdString(); + std::string sLabel = pthis->label.toStdString(); + std::string sMessage = pthis->message.toStdString(); + std::string sPaymentRequest; + if (!fRead && pthis->paymentRequest.IsInitialized()) + pthis->paymentRequest.SerializeToString(&sPaymentRequest); + std::string sAuthenticatedMerchant = pthis->authenticatedMerchant.toStdString(); + + READWRITE(pthis->nVersion); + nVersion = pthis->nVersion; + READWRITE(sAddress); + READWRITE(sLabel); + READWRITE(amount); + READWRITE(sMessage); + READWRITE(sPaymentRequest); + READWRITE(sAuthenticatedMerchant); + + if (fRead) + { + pthis->address = QString::fromStdString(sAddress); + pthis->label = QString::fromStdString(sLabel); + pthis->message = QString::fromStdString(sMessage); + if (!sPaymentRequest.empty()) + pthis->paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size())); + pthis->authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant); + } + ) }; /** Interface to Bitcoin wallet from Qt view code. */ @@ -152,6 +187,9 @@ public: void unlockCoin(COutPoint& output); void listLockedCoins(std::vector& vOutpts); + void loadReceiveRequests(std::vector& vReceiveRequests); + bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest); + private: CWallet *wallet; -- cgit v1.2.3