hdac SDK
SDK for hdac blockchain development
asset.h
1 #ifndef ASSET_H
2 #define ASSET_H
3 
4 #include <cstdint>
5 #include <cstddef>
6 
7 #define MC_AST_ASSET_REF_SIZE 10
8 #define MC_AST_ASSET_BUF_TOTAL_SIZE 22
9 #define MC_AST_SHORT_TXID_OFFSET 16
10 #define MC_AST_SHORT_TXID_SIZE 16
11 
12 #define MC_AST_ASSET_BUFFER_REF_SIZE 32
13 #define MC_AST_ASSET_FULLREF_SIZE 36
14 #define MC_AST_ASSET_QUANTITY_OFFSET 36
15 #define MC_AST_ASSET_QUANTITY_SIZE 8
16 #define MC_AST_ASSET_FULLREF_BUF_SIZE 48
17 
18 #define MC_AST_ASSET_REF_TYPE_REF 0
19 #define MC_AST_ASSET_REF_TYPE_SHORT_TXID 1
20 #define MC_AST_ASSET_REF_TYPE_TXID 2
21 
22 #define MC_ENT_REF_SIZE 10
23 #define MC_ENT_REF_PREFIX_SIZE 2
24 #define MC_ENT_MAX_NAME_SIZE 32
25 #define MC_ENT_MAX_ITEM_KEY_SIZE 256
26 #define MC_ENT_MAX_SCRIPT_SIZE 4096
27 #define MC_ENT_MAX_FIXED_FIELDS_SIZE 128
28 #define MC_ENT_MAX_STORED_ISSUERS 128
29 #define MC_ENT_SCRIPT_ALLOC_SIZE 8192 // > MC_ENT_MAX_SCRIPT_SIZE + MC_ENT_MAX_FIXED_FIELDS_SIZE + 27*MC_ENT_MAX_STORED_ISSUERS
30 
31 #define MC_ENT_KEY_SIZE 32
32 #define MC_ENT_KEYTYPE_TXID 0x00000001
33 #define MC_ENT_KEYTYPE_REF 0x00000002
34 #define MC_ENT_KEYTYPE_NAME 0x00000003
35 #define MC_ENT_KEYTYPE_SHORT_TXID 0x00000004
36 #define MC_ENT_KEYTYPE_MASK 0x000000FF
37 #define MC_ENT_KEYTYPE_FOLLOW_ON 0x00000100
38 
39 #define MC_ENT_TYPE_ANY 0xFF
40 #define MC_ENT_TYPE_NONE 0x00
41 #define MC_ENT_TYPE_ASSET 0x01
42 #define MC_ENT_TYPE_STREAM 0x02
43 #define MC_ENT_TYPE_STREAM_MAX 0x0F
44 #define MC_ENT_TYPE_UPGRADE 0x10
45 #define MC_ENT_TYPE_MAX 0x10
46 
47 #define MC_ENT_SPRM_NAME 0x01
48 #define MC_ENT_SPRM_FOLLOW_ONS 0x02
49 #define MC_ENT_SPRM_ISSUER 0x03
50 #define MC_ENT_SPRM_ANYONE_CAN_WRITE 0x04
51 #define MC_ENT_SPRM_JSON_DETAILS 0x05
52 #define MC_ENT_SPRM_ASSET_MULTIPLE 0x41
53 #define MC_ENT_SPRM_UPGRADE_PROTOCOL_VERSION 0x42
54 #define MC_ENT_SPRM_UPGRADE_START_BLOCK 0x43
55 
58 typedef struct mc_EntityLedgerRow
59 {
60  unsigned char m_Key[MC_ENT_KEY_SIZE]; // Entity key size - txid/entity-ref/name
61  uint32_t m_KeyType; // Entity key type - MC_ENT_KEYTYPE_ constants
62  int32_t m_Block; // Block entity is confirmed in
63  int32_t m_Offset; // Offset of the entity in the block
64  uint32_t m_ScriptSize; // Script Size
65  int64_t m_Quantity; // Total quantity of the entity (including follow-ons)
66  uint32_t m_EntityType; // Entity type - MC_ENT_TYPE_ constants
67  uint32_t m_Reserved1; // Reserved to align to 96 bytes
68  int64_t m_PrevPos; // Position of the previous entity in the ledger
69  int64_t m_FirstPos; // Position in the ledger corresponding to first object in the chain
70  int64_t m_LastPos; // Position in the ledger corresponding to last object in the chain before this object
71  int64_t m_ChainPos; // Position in the ledger corresponding to last object in the chain
72  unsigned char m_Script[MC_ENT_SCRIPT_ALLOC_SIZE]; // Script > MC_ENT_MAX_SCRIPT_SIZE + MC_ENT_MAX_FIXED_FIELDS_SIZE + 27*MC_ENT_MAX_STORED_ISSUERS
73 
74  void Zero();
76 
79 typedef struct mc_EntityDetails
80 {
81  unsigned char m_Ref[MC_ENT_REF_SIZE]; // Entity reference
82  unsigned char m_FullRef[MC_AST_ASSET_QUANTITY_OFFSET]; // Full Entity reference, derived from short txid from v 10007
83  char m_Name[MC_ENT_MAX_NAME_SIZE+6]; // Entity name
84  uint32_t m_Flags;
85  unsigned char m_Reserved[36];
86  mc_EntityLedgerRow m_LedgerRow;
87  void Zero();
88  void Set(mc_EntityLedgerRow *row);
89  const char* GetName();
90  const unsigned char* GetTxID();
91  const unsigned char* GetRef();
92  const unsigned char* GetFullRef();
93  const unsigned char* GetShortRef();
94  const unsigned char* GetScript();
95  int IsUnconfirmedGenesis();
96  int GetAssetMultiple();
97  int IsFollowOn();
98 // int HasFollowOns();
99  int AllowedFollowOns();
100  int AnyoneCanWrite();
101  int UpgradeProtocolVersion();
102  uint32_t UpgradeStartBlock();
103  uint64_t GetQuantity();
104  uint32_t GetEntityType();
105  const void* GetSpecialParam(uint32_t param,size_t* bytes);
106  const void* GetParam(const char *param,size_t* bytes);
107  int32_t NextParam(uint32_t offset,uint32_t* param_value_start,size_t *bytes);
109 
110 uint32_t mc_GetABScriptType(void *ptr);
111 void mc_SetABScriptType(void *ptr,uint32_t type);
112 uint32_t mc_GetABRefType(void *ptr);
113 void mc_SetABRefType(void *ptr,uint32_t type);
114 int64_t mc_GetABQuantity(void *ptr);
115 void mc_SetABQuantity(void *ptr,int64_t quantity);
116 struct mc_Buffer;
117 void mc_InitABufferDefault(mc_Buffer *buf);
118 
119 // TODO : m_AssetRefSize is from mc_HdacParams
120 static int m_AssetRefSize = MC_AST_SHORT_TXID_SIZE;
121 
122 #endif // ASSET_H
Definition: utility.h:10
Definition: asset.h:79
Definition: asset.h:58