34 #include <boost/variant.hpp>
35 #include <boost/functional/hash/hash.hpp>
46 #include "serialization/keyvalue_serialization.h"
50 #include "misc_language.h"
63 std::vector<crypto::public_key>
keys;
229 void invalidate_hashes();
230 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
231 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
235 void set_blob_size(
size_t sz) { blob_size = sz; set_blob_size_valid(
true); }
238 if (!typename Archive<W>::is_saving())
240 set_hash_valid(
false);
241 set_blob_size_valid(
false);
244 const unsigned int start_pos =
getpos(ar);
249 prefix_size =
getpos(ar) - start_pos;
254 unprunable_size =
getpos(ar) - start_pos;
256 ar.tag(
"signatures");
259 bool signatures_not_expected = signatures.empty();
260 if (!signatures_not_expected && vin.size() != signatures.size())
263 if (!pruned)
for (
size_t i = 0; i < vin.size(); ++i)
265 size_t signature_size = get_signature_size(vin[i]);
266 if (signatures_not_expected)
268 if (0 == signature_size)
275 if (signature_size != signatures[i].size())
280 if (vin.size() - i > 1)
287 ar.tag(
"rct_signatures");
292 if (!r || !ar.stream().good())
return false;
296 unprunable_size =
getpos(ar) - start_pos;
300 ar.tag(
"rctsig_prunable");
303 vin.size() > 0 && vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
304 if (!r || !ar.stream().good())
return false;
309 if (!
typename Archive<W>::is_saving())
313 template<
bool W, template <
bool> class Archive>
314 bool serialize_base(Archive<W> &ar)
323 ar.tag(
"rct_signatures");
328 if (!r || !ar.stream().good())
return false;
332 if (!
typename Archive<W>::is_saving())
334 return ar.stream().good();
338 static size_t get_signature_size(
const txin_v& tx_in);
359 set_hash_valid(
false);
360 set_blob_size_valid(
false);
369 set_hash_valid(
false);
370 set_blob_size_valid(
false);
376 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
378 size_t operator()(
const txin_gen& txin)
const{
return 0;}
384 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
418 block &
operator=(
const block &
b) { block_header::operator=(
b); hash_valid =
false; miner_tx =
b.miner_tx; tx_hashes =
b.tx_hashes;
signature =
b.signature; signatory =
b.signatory;
if (
b.is_hash_valid()) {
hash =
b.hash; set_hash_valid(
true); }
return *
this; }
420 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
421 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
433 if (!typename Archive<W>::is_saving())
434 set_hash_valid(
false);
458 FIELD(m_spend_public_key)
459 FIELD(m_view_public_key)
462 BEGIN_KV_SERIALIZE_MAP()
463 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
464 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
465 END_KV_SERIALIZE_MAP()
469 return m_spend_public_key == rhs.m_spend_public_key &&
470 m_view_public_key == rhs.m_view_public_key;
475 return !(*
this == rhs);
uint64_t height
Definition: blockchain.cpp:91
uint8_t version
Definition: blockchain.cpp:90
Definition: cryptonote_basic.h:171
std::vector< uint8_t > extra
Definition: cryptonote_basic.h:181
std::vector< txin_v > vin
Definition: cryptonote_basic.h:178
size_t version
Definition: cryptonote_basic.h:175
void set_null()
Definition: cryptonote_basic.h:194
std::vector< tx_out > vout
Definition: cryptonote_basic.h:179
uint64_t unlock_time
Definition: cryptonote_basic.h:176
Definition: cryptonote_basic.h:205
bool is_hash_valid() const
Definition: cryptonote_basic.h:230
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:213
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:226
void set_hash(const crypto::hash &h)
Definition: cryptonote_basic.h:234
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:209
void set_null()
Definition: cryptonote_basic.h:354
transaction()
Definition: cryptonote_basic.h:343
std::atomic< unsigned int > unprunable_size
Definition: cryptonote_basic.h:221
std::atomic< unsigned int > prefix_size
Definition: cryptonote_basic.h:222
bool pruned
Definition: cryptonote_basic.h:219
void set_blob_size(size_t sz)
Definition: cryptonote_basic.h:235
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:231
static size_t get_signature_size(const txin_v &tx_in)
Definition: cryptonote_basic.h:374
transaction(const transaction &t)
Definition: cryptonote_basic.h:225
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:212
void invalidate_hashes()
Definition: cryptonote_basic.h:367
virtual ~transaction()
Definition: cryptonote_basic.h:349
size_t blob_size
Definition: cryptonote_basic.h:217
void set_blob_size_valid(bool v) const
Definition: cryptonote_basic.h:233
crypto::hash hash
Definition: cryptonote_basic.h:216
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:232
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:208
Definition: device.hpp:87
virtual crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false)=0
VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff)
BLOB_SERIALIZER(cryptonote::txout_to_key)
#define CRYPTONOTE_MAX_TX_PER_BLOCK
Definition: cryptonote_config.h:43
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:47
const uint32_t T[512]
Definition: groestl_tables.h:37
#define inline
Definition: inline_c.h:35
int b
Definition: base.py:1
void load(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:55
Definition: unordered_containers_boost_serialization.h:39
const
Definition: build_protob.py:9
POD_CLASS signature
Definition: crypto.h:108
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
POD_CLASS public_key
Definition: crypto.h:76
POD_CLASS key_image
Definition: crypto.h:102
POD_CLASS hash
Definition: hash.h:50
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:226
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key > txout_target_v
Definition: cryptonote_basic.h:140
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:138
std::vector< crypto::signature > ring_signature
Definition: cryptonote_basic.h:56
static unsigned int getpos(T &ar)
Definition: cryptonote_basic.h:156
@ RCTTypeNull
Definition: rctTypes.h:229
Definition: blockchain_ancestry.cpp:73
#define BEGIN_SERIALIZE()
Begins the environment of the DSL \detailed for describing how to serialize an of an archive type.
Definition: serialization.h:181
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:190
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:203
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:254
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:263
#define false
Definition: stdbool.h:38
Definition: binary_archive.h:99
Definition: binary_archive.h:182
stream_type & stream()
Definition: binary_archive.h:77
Definition: binary_archive.h:94
Definition: cryptonote_basic.h:453
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:455
bool operator!=(const account_public_address &rhs) const
Definition: cryptonote_basic.h:473
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:454
Definition: cryptonote_basic.h:410
transaction miner_tx
Definition: cryptonote_basic.h:423
std::vector< uint8_t > signature
Definition: cryptonote_basic.h:426
void invalidate_hashes()
Definition: cryptonote_basic.h:419
block()
Definition: cryptonote_basic.h:416
crypto::hash hash
Definition: cryptonote_basic.h:430
bool is_hash_valid() const
Definition: cryptonote_basic.h:420
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:421
std::vector< uint8_t > signatory
Definition: cryptonote_basic.h:427
block(const block &b)
Definition: cryptonote_basic.h:417
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:424
block & operator=(const block &b)
Definition: cryptonote_basic.h:418
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:413
Definition: cryptonote_basic.h:480
crypto::secret_key sec
Definition: cryptonote_basic.h:482
static keypair generate(hw::device &hwdev)
Definition: cryptonote_basic.h:484
crypto::public_key pub
Definition: cryptonote_basic.h:481
Definition: cryptonote_basic.h:144
txout_target_v target
Definition: cryptonote_basic.h:146
uint64_t amount
Definition: cryptonote_basic.h:145
Definition: cryptonote_basic.h:88
size_t height
Definition: cryptonote_basic.h:89
Definition: cryptonote_basic.h:125
crypto::key_image k_image
Definition: cryptonote_basic.h:128
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:127
uint64_t amount
Definition: cryptonote_basic.h:126
Definition: cryptonote_basic.h:97
crypto::hash prev
Definition: cryptonote_basic.h:98
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:100
size_t prevout
Definition: cryptonote_basic.h:99
Definition: cryptonote_basic.h:110
size_t prevout
Definition: cryptonote_basic.h:112
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:114
txout_to_script script
Definition: cryptonote_basic.h:113
crypto::hash prev
Definition: cryptonote_basic.h:111
Definition: cryptonote_basic.h:78
crypto::public_key key
Definition: cryptonote_basic.h:81
txout_to_key()
Definition: cryptonote_basic.h:79
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:80
Definition: cryptonote_basic.h:62
std::vector< crypto::public_key > keys
Definition: cryptonote_basic.h:63
std::vector< uint8_t > script
Definition: cryptonote_basic.h:64
Definition: cryptonote_basic.h:73
crypto::hash hash
Definition: cryptonote_basic.h:74
Definition: cryptonote_basic.h:160
uint64_t expiration_date
Definition: cryptonote_basic.h:161
std::vector< uint8_t > validators
Definition: cryptonote_basic.h:162
Definition: debug_archive.h:38
a archive using the JSON standard
Definition: json_archive.h:112
uint8_t type
Definition: rctTypes.h:241
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:251
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:325
Definition: rctTypes.h:436
rctSigPrunable p
Definition: rctTypes.h:437
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition: cryptonote_basic.h:499
for dealing with variants