LCOV - code coverage report
Current view: top level - src/qt - sendcoinsrecipient.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 2 16 12.5 %
Date: 2020-09-26 01:30:44 Functions: 5 26 19.2 %

          Line data    Source code
       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             : #include <amount.h>
      13             : #include <serialize.h>
      14             : 
      15             : #include <string>
      16             : 
      17             : #include <QString>
      18             : 
      19          32 : class SendCoinsRecipient
      20             : {
      21             : public:
      22          24 :     explicit SendCoinsRecipient() : amount(0), fSubtractFeeFromAmount(false), nVersion(SendCoinsRecipient::CURRENT_VERSION) { }
      23           0 :     explicit SendCoinsRecipient(const QString &addr, const QString &_label, const CAmount& _amount, const QString &_message):
      24           0 :         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;
      33             :     CAmount amount;
      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.
      40             :     QString authenticatedMerchant;
      41             : 
      42             :     bool fSubtractFeeFromAmount; // memory only
      43             : 
      44             :     static const int CURRENT_VERSION = 1;
      45             :     int nVersion;
      46             : 
      47           0 :     SERIALIZE_METHODS(SendCoinsRecipient, obj)
      48             :     {
      49           0 :         std::string address_str, label_str, message_str, auth_merchant_str;
      50             : 
      51           0 :         SER_WRITE(obj, address_str = obj.address.toStdString());
      52           0 :         SER_WRITE(obj, label_str = obj.label.toStdString());
      53           0 :         SER_WRITE(obj, message_str = obj.message.toStdString());
      54           0 :         SER_WRITE(obj, auth_merchant_str = obj.authenticatedMerchant.toStdString());
      55             : 
      56           0 :         READWRITE(obj.nVersion, address_str, label_str, obj.amount, message_str, obj.sPaymentRequest, auth_merchant_str);
      57             : 
      58           0 :         SER_READ(obj, obj.address = QString::fromStdString(address_str));
      59           0 :         SER_READ(obj, obj.label = QString::fromStdString(label_str));
      60           0 :         SER_READ(obj, obj.message = QString::fromStdString(message_str));
      61           0 :         SER_READ(obj, obj.authenticatedMerchant = QString::fromStdString(auth_merchant_str));
      62           0 :     }
      63             : };
      64             : 
      65             : #endif // BITCOIN_QT_SENDCOINSRECIPIENT_H

Generated by: LCOV version 1.15