Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
tx_extra.h
Go to the documentation of this file.
1
// Copyrights(c) 2017-2021, The Electroneum Project
2
// Copyrights(c) 2014-2019, The Monero Project
3
//
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without modification, are
7
// permitted provided that the following conditions are met:
8
//
9
// 1. Redistributions of source code must retain the above copyright notice, this list of
10
// conditions and the following disclaimer.
11
//
12
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
// of conditions and the following disclaimer in the documentation and/or other
14
// materials provided with the distribution.
15
//
16
// 3. Neither the name of the copyright holder nor the names of its contributors may be
17
// used to endorse or promote products derived from this software without specific
18
// prior written permission.
19
//
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
//
30
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32
#pragma once
33
34
35
#define TX_EXTRA_PADDING_MAX_COUNT 255
36
#define TX_EXTRA_NONCE_MAX_COUNT 255
37
38
#define TX_EXTRA_TAG_PADDING 0x00
39
#define TX_EXTRA_TAG_PUBKEY 0x01
40
#define TX_EXTRA_NONCE 0x02
41
#define TX_EXTRA_MERGE_MINING_TAG 0x03
42
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS 0x04
43
#define TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS 0x05
44
#define TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS 0x06
45
#define TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG 0x07
46
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG 0xDE
47
48
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
49
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
50
51
namespace
cryptonote
52
{
53
struct
tx_extra_padding
54
{
55
size_t
size
;
56
57
// load
58
template
<
template
<
bool
>
class
Archive>
59
bool
do_serialize
(Archive<false>& ar)
60
{
61
// size - 1 - because of variant tag
62
for
(
size
= 1;
size
<=
TX_EXTRA_PADDING_MAX_COUNT
; ++
size
)
63
{
64
std::ios_base::iostate
state
= ar.stream().rdstate();
65
bool
eof = EOF == ar.stream().peek();
66
ar.stream().clear(
state
);
67
68
if
(eof)
69
break
;
70
71
uint8_t
zero;
72
if
(!
::do_serialize
(ar, zero))
73
return
false
;
74
75
if
(0 != zero)
76
return
false
;
77
}
78
79
return
size
<=
TX_EXTRA_PADDING_MAX_COUNT
;
80
}
81
82
// store
83
template
<
template
<
bool
>
class
Archive>
84
bool
do_serialize
(Archive<true>& ar)
85
{
86
if
(
TX_EXTRA_PADDING_MAX_COUNT
<
size
)
87
return
false
;
88
89
// i = 1 - because of variant tag
90
for
(
size_t
i = 1; i <
size
; ++i)
91
{
92
uint8_t
zero = 0;
93
if
(!
::do_serialize
(ar, zero))
94
return
false
;
95
}
96
return
true
;
97
}
98
};
99
100
struct
tx_extra_pub_key
101
{
102
crypto::public_key
pub_key
;
103
104
BEGIN_SERIALIZE
()
105
FIELD
(
pub_key
)
106
END_SERIALIZE
()
107
};
108
109
struct
tx_extra_nonce
110
{
111
std::string
nonce
;
112
113
BEGIN_SERIALIZE
()
114
FIELD
(
nonce
)
115
if
(
TX_EXTRA_NONCE_MAX_COUNT
<
nonce
.size()) return
false
;
116
END_SERIALIZE
()
117
};
118
119
struct
tx_extra_merge_mining_tag
120
{
121
struct
serialize_helper
122
{
123
tx_extra_merge_mining_tag
&
mm_tag
;
124
125
serialize_helper
(
tx_extra_merge_mining_tag
& mm_tag_) :
mm_tag
(mm_tag_)
126
{
127
}
128
129
BEGIN_SERIALIZE
()
130
VARINT_FIELD_N
(
"depth"
, mm_tag.
depth
)
131
FIELD_N
(
"merkle_root"
, mm_tag.
merkle_root
)
132
END_SERIALIZE
()
133
};
134
135
size_t
depth
;
136
crypto
::hash
merkle_root
;
137
138
// load
139
template <template <
bool
> class Archive>
140
bool
do_serialize
(Archive<
false
>& ar)
141
{
142
std::string field;
143
if
(!
::do_serialize
(ar, field))
144
return
false
;
145
146
std::istringstream iss(field);
147
binary_archive<false>
iar(iss);
148
serialize_helper
helper(*
this
);
149
return ::serialization::serialize(iar, helper);
150
}
151
152
// store
153
template
<
template
<
bool
>
class
Archive>
154
bool
do_serialize
(Archive<true>& ar)
155
{
156
std::ostringstream oss;
157
binary_archive<true>
oar(oss);
158
serialize_helper
helper(*
this
);
159
if
(!
::do_serialize
(oar, helper))
160
return
false
;
161
162
std::string field = oss.str();
163
return ::serialization::serialize(ar, field);
164
}
165
};
166
167
// per-output additional tx pubkey for multi-destination transfers involving at least one subaddress
168
struct
tx_extra_additional_pub_keys
169
{
170
std::vector<crypto::public_key>
data
;
171
172
BEGIN_SERIALIZE
()
173
FIELD
(
data
)
174
END_SERIALIZE
()
175
};
176
177
struct
tx_extra_bridge_source_address
178
{
179
std::string
data
;
180
181
BEGIN_SERIALIZE
()
182
FIELD
(
data
)
183
END_SERIALIZE
()
184
};
185
186
struct
tx_extra_bridge_smartchain_address
187
{
188
std::string
data
;
189
190
BEGIN_SERIALIZE
()
191
FIELD
(
data
)
192
END_SERIALIZE
()
193
};
194
195
struct
tx_extra_bridge_ownership_sig
196
{
197
std::string
data
;
198
199
BEGIN_SERIALIZE
()
200
FIELD
(
data
)
201
END_SERIALIZE
()
202
};
203
204
struct
tx_extra_mysterious_minergate
205
{
206
std::string
data
;
207
208
BEGIN_SERIALIZE
()
209
FIELD
(
data
)
210
END_SERIALIZE
()
211
};
212
213
// tx_extra_field format, except tx_extra_padding and tx_extra_pub_key:
214
// varint tag;
215
// varint size;
216
// varint data[];
217
typedef
boost
::variant<
tx_extra_padding
,
tx_extra_pub_key
,
tx_extra_nonce
,
tx_extra_merge_mining_tag
,
tx_extra_additional_pub_keys
,
tx_extra_bridge_source_address
,
tx_extra_bridge_smartchain_address
,
tx_extra_bridge_ownership_sig
,
tx_extra_mysterious_minergate
>
tx_extra_field
;
218
}
219
220
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_padding,
TX_EXTRA_TAG_PADDING
);
221
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_pub_key,
TX_EXTRA_TAG_PUBKEY
);
222
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_nonce,
TX_EXTRA_NONCE
);
223
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_merge_mining_tag,
TX_EXTRA_MERGE_MINING_TAG
);
224
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_additional_pub_keys,
TX_EXTRA_TAG_ADDITIONAL_PUBKEYS
);
225
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_bridge_source_address,
TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS
);
226
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_bridge_smartchain_address,
TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS
);
227
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_bridge_ownership_sig,
TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG
);
228
VARIANT_TAG
(
binary_archive
,
cryptonote
::tx_extra_mysterious_minergate,
TX_EXTRA_MYSTERIOUS_MINERGATE_TAG
);
boost
Definition
portable_binary_archive.hpp:29
crypto
crypto namespace.
Definition
crypto.cpp:58
crypto::public_key
POD_CLASS public_key
Definition
crypto.h:79
cryptonote
Holds cryptonote related classes and helpers.
Definition
ban.cpp:40
cryptonote::tx_extra_field
boost::variant< tx_extra_padding, tx_extra_pub_key, tx_extra_nonce, tx_extra_merge_mining_tag, tx_extra_additional_pub_keys, tx_extra_bridge_source_address, tx_extra_bridge_smartchain_address, tx_extra_bridge_ownership_sig, tx_extra_mysterious_minergate > tx_extra_field
Definition
tx_extra.h:217
BEGIN_SERIALIZE
#define BEGIN_SERIALIZE()
VARINT_FIELD_N
#define VARINT_FIELD_N(t, f)
FIELD
#define FIELD(f)
FIELD_N
#define FIELD_N(t, f)
false
#define false
END_SERIALIZE
#define END_SERIALIZE()
VARIANT_TAG
#define VARIANT_TAG(Archive, Type, Tag)
uint8_t
unsigned char uint8_t
Definition
stdint.h:124
binary_archive
Definition
binary_archive.h:94
cryptonote::tx_extra_additional_pub_keys
Definition
tx_extra.h:169
cryptonote::tx_extra_additional_pub_keys::data
std::vector< crypto::public_key > data
Definition
tx_extra.h:170
cryptonote::tx_extra_bridge_ownership_sig
Definition
tx_extra.h:196
cryptonote::tx_extra_bridge_ownership_sig::data
std::string data
Definition
tx_extra.h:197
cryptonote::tx_extra_bridge_smartchain_address
Definition
tx_extra.h:187
cryptonote::tx_extra_bridge_smartchain_address::data
std::string data
Definition
tx_extra.h:188
cryptonote::tx_extra_bridge_source_address
Definition
tx_extra.h:178
cryptonote::tx_extra_bridge_source_address::data
std::string data
Definition
tx_extra.h:179
cryptonote::tx_extra_merge_mining_tag::serialize_helper
Definition
tx_extra.h:122
cryptonote::tx_extra_merge_mining_tag::serialize_helper::serialize_helper
serialize_helper(tx_extra_merge_mining_tag &mm_tag_)
Definition
tx_extra.h:125
cryptonote::tx_extra_merge_mining_tag::serialize_helper::mm_tag
tx_extra_merge_mining_tag & mm_tag
Definition
tx_extra.h:123
cryptonote::tx_extra_merge_mining_tag
Definition
tx_extra.h:120
cryptonote::tx_extra_merge_mining_tag::depth
size_t depth
Definition
tx_extra.h:135
cryptonote::tx_extra_merge_mining_tag::merkle_root
crypto::hash merkle_root
Definition
tx_extra.h:136
cryptonote::tx_extra_merge_mining_tag::do_serialize
bool do_serialize(Archive< false > &ar)
Definition
tx_extra.h:140
cryptonote::tx_extra_merge_mining_tag::do_serialize
bool do_serialize(Archive< true > &ar)
Definition
tx_extra.h:154
cryptonote::tx_extra_mysterious_minergate
Definition
tx_extra.h:205
cryptonote::tx_extra_mysterious_minergate::data
std::string data
Definition
tx_extra.h:206
cryptonote::tx_extra_nonce
Definition
tx_extra.h:110
cryptonote::tx_extra_nonce::nonce
std::string nonce
Definition
tx_extra.h:111
cryptonote::tx_extra_nonce::if
if(TX_EXTRA_NONCE_MAX_COUNT< nonce.size()) return false
cryptonote::tx_extra_padding
Definition
tx_extra.h:54
cryptonote::tx_extra_padding::size
size_t size
Definition
tx_extra.h:55
cryptonote::tx_extra_padding::do_serialize
bool do_serialize(Archive< true > &ar)
Definition
tx_extra.h:84
cryptonote::tx_extra_padding::do_serialize
bool do_serialize(Archive< false > &ar)
Definition
tx_extra.h:59
cryptonote::tx_extra_pub_key
Definition
tx_extra.h:101
cryptonote::tx_extra_pub_key::pub_key
crypto::public_key pub_key
Definition
tx_extra.h:102
state
Definition
blake256.h:37
TX_EXTRA_NONCE_MAX_COUNT
#define TX_EXTRA_NONCE_MAX_COUNT
Definition
tx_extra.h:36
TX_EXTRA_TAG_PADDING
#define TX_EXTRA_TAG_PADDING
Definition
tx_extra.h:38
TX_EXTRA_TAG_PUBKEY
#define TX_EXTRA_TAG_PUBKEY
Definition
tx_extra.h:39
TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS
#define TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS
Definition
tx_extra.h:44
TX_EXTRA_NONCE
#define TX_EXTRA_NONCE
Definition
tx_extra.h:40
TX_EXTRA_MYSTERIOUS_MINERGATE_TAG
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG
Definition
tx_extra.h:46
TX_EXTRA_TAG_ADDITIONAL_PUBKEYS
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS
Definition
tx_extra.h:42
TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS
#define TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS
Definition
tx_extra.h:43
TX_EXTRA_PADDING_MAX_COUNT
#define TX_EXTRA_PADDING_MAX_COUNT
Definition
tx_extra.h:35
TX_EXTRA_MERGE_MINING_TAG
#define TX_EXTRA_MERGE_MINING_TAG
Definition
tx_extra.h:41
TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG
#define TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG
Definition
tx_extra.h:45
src
cryptonote_basic
tx_extra.h
Generated on
for Electroneum by
1.17.0