CatapultServer  v0.5.0.1 (Elephant)
TransferTransaction.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "TransferEntityType.h"
23 #include "catapult/model/Mosaic.h"
25 
26 namespace catapult { namespace model {
27 
28 #pragma pack(push, 1)
29 
31  template<typename THeader>
32  struct TransferTransactionBody : public THeader {
33  private:
35 
36  public:
37  DEFINE_TRANSACTION_CONSTANTS(Entity_Type_Transfer, 1)
38 
39  public:
42 
44  uint16_t MessageSize;
45 
47  uint8_t MosaicsCount;
48 
49  // followed by message data if MessageSize != 0
51 
52  // followed by mosaics data if MosaicsCount != 0
54 
55  private:
56  template<typename T>
57  static auto* MessagePtrT(T& transaction) {
58  return transaction.MessageSize ? THeader::PayloadStart(transaction) : nullptr;
59  }
60 
61  template<typename T>
62  static auto* MosaicsPtrT(T& transaction) {
63  auto* pPayloadStart = THeader::PayloadStart(transaction);
64  return transaction.MosaicsCount && pPayloadStart ? pPayloadStart + transaction.MessageSize : nullptr;
65  }
66 
67  public:
68  // Calculates the real size of transfer \a transaction.
69  static constexpr uint64_t CalculateRealSize(const TransactionType& transaction) noexcept {
70  return sizeof(TransactionType) + transaction.MessageSize + transaction.MosaicsCount * sizeof(UnresolvedMosaic);
71  }
72  };
73 
75 
76 #pragma pack(pop)
77 }}
Mosaic.h
catapult::model::TransferTransactionBody::MosaicsCount
uint8_t MosaicsCount
Number of mosaics.
Definition: TransferTransaction.h:47
catapult::model::MosaicT< UnresolvedMosaicId >
Transaction.h
catapult::model::TransferTransactionBody::MosaicsPtrT
static auto * MosaicsPtrT(T &transaction)
Definition: TransferTransaction.h:62
catapult::model::TransferTransactionBody::Recipient
UnresolvedAddress Recipient
Transaction recipient.
Definition: TransferTransaction.h:41
catapult::model::TransferTransactionBody::MessagePtrT
static auto * MessagePtrT(T &transaction)
Definition: TransferTransaction.h:57
DEFINE_EMBEDDABLE_TRANSACTION
#define DEFINE_EMBEDDABLE_TRANSACTION(NAME)
Defines a transaction with NAME that supports embedding.
Definition: Transaction.h:69
catapult::model::TransferTransactionBody::TransactionType
TransferTransactionBody< THeader > TransactionType
Definition: TransferTransaction.h:34
TransferEntityType.h
Message
std::string Message
Definition: RawFile.cpp:72
catapult::model::TransferTransactionBody::MessageSize
uint16_t MessageSize
Message size in bytes.
Definition: TransferTransaction.h:44
catapult::model::TransferTransactionBody
Binary layout for a transfer transaction body.
Definition: TransferTransaction.h:32
catapult::model::TransferTransactionBody::CalculateRealSize
static constexpr uint64_t CalculateRealSize(const TransactionType &transaction) noexcept
Definition: TransferTransaction.h:69
DEFINE_TRANSACTION_CONSTANTS
#define DEFINE_TRANSACTION_CONSTANTS(TYPE, VERSION)
Defines constants for a transaction with TYPE and VERSION.
Definition: Transaction.h:50
catapult
Definition: AddressExtractionExtension.cpp:28
DEFINE_TRANSACTION_VARIABLE_DATA_ACCESSORS
#define DEFINE_TRANSACTION_VARIABLE_DATA_ACCESSORS(NAME, TYPE)
Defines NAME (TYPE typed) variable data accessors around a similarly named templated untyped data acc...
Definition: Transaction.h:57
catapult::utils::ByteArray< Address_Decoded_Size, UnresolvedAddress_tag >