aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletmodel.h
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-01-14 05:05:43 +0100
committerCozz Lovan <cozzlovan@yahoo.com>2014-01-19 18:21:54 +0100
commit8476d5d407645229faf3017b390f041ce0666247 (patch)
tree3bd9c035a61b8f066b81662b0b77743eee995dfe /src/qt/walletmodel.h
parentb10e147096b0e27fdff8c22029bc8b7a1a14f042 (diff)
downloadbitcoin-8476d5d407645229faf3017b390f041ce0666247.tar.xz
[Qt] Permanently store requested payments in wallet
Diffstat (limited to 'src/qt/walletmodel.h')
-rw-r--r--src/qt/walletmodel.h42
1 files changed, 40 insertions, 2 deletions
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<br />address-B<br />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<SendCoinsRecipient*>(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<COutPoint>& vOutpts);
+ void loadReceiveRequests(std::vector<std::string>& vReceiveRequests);
+ bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest);
+
private:
CWallet *wallet;