Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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)
9#include <config/bitcoin-config.h>
10#endif
11
12#ifdef ENABLE_BIP70
14#endif
15
16#include <consensus/amount.h>
17#include <serialize.h>
18
19#include <string>
20
21#include <QString>
22
24public:
33
34 // If from an unauthenticated payment request, this is used for storing the
35 // addresses, e.g. address-A<br />address-B<br />address-C.
36 // Info: As we don't need to process addresses in here when using payment
37 // requests, we can abuse it for displaying an address list.
38 // TOFO: This is a hack, should be replaced with a cleaner solution!
42 // If from a payment request, this is used for storing the memo
44
45#ifdef ENABLE_BIP70
46 // If from a payment request, paymentRequest.IsInitialized() will be true
47 PaymentRequestPlus paymentRequest;
48#else
49 // If building with BIP70 is disabled, keep the payment request around as
50 // serialized string to ensure load/store is lossless
51 std::string sPaymentRequest;
52#endif
53 // Empty if no authentication or invalid signature/cert/etc.
55
56 // memory only
58
59 static const int CURRENT_VERSION = 1;
61
63 std::string address_str, label_str, message_str, auth_merchant_str;
64 std::string payment_request_str;
65
66 SER_WRITE(obj, address_str = obj.address.toStdString());
67 SER_WRITE(obj, label_str = obj.label.toStdString());
68 SER_WRITE(obj, message_str = obj.message.toStdString());
69#ifdef ENABLE_BIP70
70 if (obj.paymentRequest.IsInitialized()) {
71 SER_WRITE(obj, obj.paymentRequest.SerializeToString(
73 }
74#else
75 SER_WRITE(obj, payment_request_str = obj.sPaymentRequest);
76#endif
78 auth_merchant_str = obj.authenticatedMerchant.toStdString());
79
80 READWRITE(obj.nVersion, address_str, label_str, obj.amount, message_str,
82
83 SER_READ(obj, obj.address = QString::fromStdString(address_str));
84 SER_READ(obj, obj.label = QString::fromStdString(label_str));
85 SER_READ(obj, obj.message = QString::fromStdString(message_str));
86#ifdef ENABLE_BIP70
87 if (!payment_request_str.empty()) {
88 SER_READ(obj, obj.paymentRequest.parse(QByteArray::fromRawData(
90 payment_request_str.size())));
91 }
92#else
93 SER_READ(obj, obj.sPaymentRequest = payment_request_str);
94#endif
95 SER_READ(obj, obj.authenticatedMerchant =
96 QString::fromStdString(auth_merchant_str));
97 }
98};
99
100#endif // BITCOIN_QT_SENDCOINSRECIPIENT_H
SendCoinsRecipient(const QString &addr, const QString &_label, const Amount _amount, const QString &_message)
static const int CURRENT_VERSION
SERIALIZE_METHODS(SendCoinsRecipient, obj)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define SER_WRITE(obj, code)
Definition serialize.h:173
#define SER_READ(obj, code)
Definition serialize.h:169
#define READWRITE(...)
Definition serialize.h:166