Bitcoin Core  0.20.99
P2P Digital Currency
sendcoinsrecipient.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_QT_SENDCOINSRECIPIENT_H
6 #define BITCOIN_QT_SENDCOINSRECIPIENT_H
7 
8 #if defined(HAVE_CONFIG_H)
10 #endif
11 
12 #include <amount.h>
13 #include <serialize.h>
14 
15 #include <string>
16 
17 #include <QString>
18 
20 {
21 public:
23  explicit SendCoinsRecipient(const QString &addr, const QString &_label, const CAmount& _amount, const QString &_message):
24  address(addr), label(_label), amount(_amount), message(_message), fSubtractFeeFromAmount(false), nVersion(SendCoinsRecipient::CURRENT_VERSION) {}
25 
26  // If from an unauthenticated payment request, this is used for storing
27  // the addresses, e.g. address-A<br />address-B<br />address-C.
28  // Info: As we don't need to process addresses in here when using
29  // payment requests, we can abuse it for displaying an address list.
30  // Todo: This is a hack, should be replaced with a cleaner solution!
31  QString address;
32  QString label;
34  // If from a payment request, this is used for storing the memo
35  QString message;
36  // Keep the payment request around as a serialized string to ensure
37  // load/store is lossless.
38  std::string sPaymentRequest;
39  // Empty if no authentication or invalid signature/cert/etc.
41 
42  bool fSubtractFeeFromAmount; // memory only
43 
44  static const int CURRENT_VERSION = 1;
45  int nVersion;
46 
48  {
49  std::string address_str, label_str, message_str, auth_merchant_str;
50 
51  SER_WRITE(obj, address_str = obj.address.toStdString());
52  SER_WRITE(obj, label_str = obj.label.toStdString());
53  SER_WRITE(obj, message_str = obj.message.toStdString());
54  SER_WRITE(obj, auth_merchant_str = obj.authenticatedMerchant.toStdString());
55 
56  READWRITE(obj.nVersion, address_str, label_str, obj.amount, message_str, obj.sPaymentRequest, auth_merchant_str);
57 
58  SER_READ(obj, obj.address = QString::fromStdString(address_str));
59  SER_READ(obj, obj.label = QString::fromStdString(label_str));
60  SER_READ(obj, obj.message = QString::fromStdString(message_str));
61  SER_READ(obj, obj.authenticatedMerchant = QString::fromStdString(auth_merchant_str));
62  }
63 };
64 
65 #endif // BITCOIN_QT_SENDCOINSRECIPIENT_H
SERIALIZE_METHODS(SendCoinsRecipient, obj)
static const int CURRENT_VERSION
SendCoinsRecipient(const QString &addr, const QString &_label, const CAmount &_amount, const QString &_message)
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
#define SER_READ(obj, code)
Definition: serialize.h:173
#define SER_WRITE(obj, code)
Definition: serialize.h:174
std::string sPaymentRequest
#define READWRITE(...)
Definition: serialize.h:171