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);
246 FIELDS(*static_cast<transaction_prefix *>(
this))
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)
316 FIELDS(*static_cast<transaction_prefix *>(
this))
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);
crypto::public_key pub
Definition: cryptonote_basic.h:481
block & operator=(const block &b)
Definition: cryptonote_basic.h:418
const uint32_t T[512]
Definition: groestl_tables.h:37
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:424
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key > txout_target_v
Definition: cryptonote_basic.h:140
Definition: cryptonote_basic.h:109
static size_t get_signature_size(const txin_v &tx_in)
Definition: cryptonote_basic.h:374
transaction()
Definition: cryptonote_basic.h:343
txout_to_script script
Definition: cryptonote_basic.h:113
Definition: unordered_containers_boost_serialization.h:38
crypto::secret_key sec
Definition: cryptonote_basic.h:482
Definition: cryptonote_basic.h:479
stream_type & stream()
Definition: binary_archive.h:77
void set_blob_size(size_t sz)
Definition: cryptonote_basic.h:235
void set_hash(const crypto::hash &h)
Definition: cryptonote_basic.h:234
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:325
Definition: cryptonote_basic.h:409
virtual ~transaction()
Definition: cryptonote_basic.h:349
std::vector< uint8_t > signatory
Definition: cryptonote_basic.h:427
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:232
uint64_t height
Definition: blockchain.cpp:91
size_t prevout
Definition: cryptonote_basic.h:112
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
Definition: blockchain_ancestry.cpp:72
Definition: binary_archive.h:181
size_t prevout
Definition: cryptonote_basic.h:99
transaction(const transaction &t)
Definition: cryptonote_basic.h:225
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:127
Definition: cryptonote_basic.h:77
std::vector< uint8_t > validators
Definition: cryptonote_basic.h:162
Definition: cryptonote_basic.h:61
const
Definition: build_protob.py:9
Definition: cryptonote_basic.h:87
std::vector< crypto::signature > ring_signature
Definition: cryptonote_basic.h:56
std::vector< uint8_t > extra
Definition: cryptonote_basic.h:181
crypto::hash prev
Definition: cryptonote_basic.h:98
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
Definition: cryptonote_basic.h:170
std::vector< tx_out > vout
Definition: cryptonote_basic.h:179
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:225
bool is_hash_valid() const
Definition: cryptonote_basic.h:420
Definition: cryptonote_basic.h:160
static unsigned int getpos(T &ar)
Definition: cryptonote_basic.h:156
Definition: cryptonote_basic.h:96
std::vector< txin_v > vin
Definition: cryptonote_basic.h:178
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:454
std::vector< uint8_t > script
Definition: cryptonote_basic.h:64
for dealing with variants
block()
Definition: cryptonote_basic.h:416
Definition: cryptonote_basic.h:72
uint64_t unlock_time
Definition: cryptonote_basic.h:176
void invalidate_hashes()
Definition: cryptonote_basic.h:419
bool pruned
Definition: cryptonote_basic.h:219
Definition: binary_archive.h:98
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:455
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
void set_blob_size_valid(bool v) const
Definition: cryptonote_basic.h:233
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:213
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:413
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:421
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:254
rctSigPrunable p
Definition: rctTypes.h:437
void invalidate_hashes()
Definition: cryptonote_basic.h:367
uint64_t amount
Definition: cryptonote_basic.h:126
int b
Definition: base.py:1
Definition: cryptonote_basic.h:124
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL for described the serialization of an object
Definition: serialization.h:190
Definition: rctTypes.h:436
void load(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:55
size_t version
Definition: cryptonote_basic.h:175
uint64_t expiration_date
Definition: cryptonote_basic.h:161
Definition: device.hpp:87
#define false
Definition: stdbool.h:38
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:209
transaction miner_tx
Definition: cryptonote_basic.h:423
static keypair generate(hw::device &hwdev)
Definition: cryptonote_basic.h:484
crypto::hash hash
Definition: cryptonote_basic.h:74
POD_CLASS public_key
Definition: crypto.h:76
void set_null()
Definition: cryptonote_basic.h:354
bool is_hash_valid() const
Definition: cryptonote_basic.h:230
BLOB_SERIALIZER(cryptonote::txout_to_key)
uint8_t version
Definition: blockchain.cpp:90
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:212
std::atomic< unsigned int > prefix_size
Definition: cryptonote_basic.h:222
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:100
void set_null()
Definition: cryptonote_basic.h:194
POD_CLASS signature
Definition: crypto.h:108
Definition: cryptonote_basic.h:452
crypto::hash prev
Definition: cryptonote_basic.h:111
std::vector< uint8_t > signature
Definition: cryptonote_basic.h:426
crypto::public_key key
Definition: cryptonote_basic.h:81
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:226
#define CRYPTONOTE_MAX_TX_PER_BLOCK
Definition: cryptonote_config.h:43
Definition: rctTypes.h:229
POD_CLASS key_image
Definition: crypto.h:102
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:263
VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff)
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:114
uint64_t amount
Definition: cryptonote_basic.h:145
uint8_t type
Definition: rctTypes.h:241
txout_target_v target
Definition: cryptonote_basic.h:146
crypto::key_image k_image
Definition: cryptonote_basic.h:128
crypto::hash hash
Definition: cryptonote_basic.h:216
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:231
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:208
block(const block &b)
Definition: cryptonote_basic.h:417
txout_to_key()
Definition: cryptonote_basic.h:79
#define BEGIN_SERIALIZE()
Begins the environment of the DSL for describing how to serialize an of an archive type...
Definition: serialization.h:181
std::vector< crypto::public_key > keys
Definition: cryptonote_basic.h:63
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:138
POD_CLASS hash
Definition: hash.h:50
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:80
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:47
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:203
crypto::hash hash
Definition: cryptonote_basic.h:430
Definition: cryptonote_basic.h:143
bool operator!=(const account_public_address &rhs) const
Definition: cryptonote_basic.h:473
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:251
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
size_t blob_size
Definition: cryptonote_basic.h:217
size_t height
Definition: cryptonote_basic.h:89
Definition: binary_archive.h:94
Definition: debug_archive.h:38
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition: cryptonote_basic.h:499
Definition: cryptonote_basic.h:204
std::atomic< unsigned int > unprunable_size
Definition: cryptonote_basic.h:221
a archive using the JSON standard
Definition: json_archive.h:112
#define inline
Definition: inline_c.h:35