33 #include <boost/variant.hpp>
34 #include <boost/functional/hash/hash.hpp>
45 #include "serialization/keyvalue_serialization.h"
49 #include "misc_language.h"
62 std::vector<crypto::public_key>
keys;
220 void invalidate_hashes();
221 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
222 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
229 void set_blob_size(
size_t sz)
const { blob_size = sz; set_blob_size_valid(
true); }
232 if (!typename Archive<W>::is_saving())
234 set_hash_valid(
false);
235 set_prunable_hash_valid(
false);
236 set_blob_size_valid(
false);
239 const unsigned int start_pos =
getpos(ar);
244 prefix_size =
getpos(ar) - start_pos;
249 unprunable_size =
getpos(ar) - start_pos;
251 ar.tag(
"signatures");
254 bool signatures_not_expected = signatures.empty();
255 if (!signatures_not_expected && vin.size() != signatures.size())
258 if (!pruned)
for (
size_t i = 0; i < vin.size(); ++i)
260 size_t signature_size = get_signature_size(vin[i]);
261 if (signatures_not_expected)
263 if (0 == signature_size)
270 if (signature_size != signatures[i].size())
275 if (vin.size() - i > 1)
282 ar.tag(
"rct_signatures");
287 if (!r || !ar.stream().good())
return false;
291 unprunable_size =
getpos(ar) - start_pos;
295 ar.tag(
"rctsig_prunable");
298 vin.size() > 0 && vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
299 if (!r || !ar.stream().good())
return false;
304 if (!
typename Archive<W>::is_saving())
308 template<
bool W, template <
bool> class Archive>
309 bool serialize_base(Archive<W> &ar)
318 ar.tag(
"rct_signatures");
323 if (!r || !ar.stream().good())
return false;
327 if (!
typename Archive<W>::is_saving())
329 return ar.stream().good();
333 static size_t get_signature_size(
const txin_v& tx_in);
339 prunable_hash_valid(
false),
340 blob_size_valid(
false),
341 signatures(t.signatures),
342 rct_signatures(t.rct_signatures),
344 unprunable_size(t.unprunable_size.
load()),
345 prefix_size(t.prefix_size.
load())
366 transaction_prefix::operator=(t);
430 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
432 size_t operator()(
const txin_gen& txin)
const{
return 0;}
438 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
472 block &
operator=(
const block &
b) { block_header::operator=(
b); hash_valid =
false; miner_tx =
b.miner_tx; tx_hashes =
b.tx_hashes;
if (
b.is_hash_valid()) {
hash =
b.hash; set_hash_valid(
true); }
return *
this; }
474 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
475 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
485 if (!typename Archive<W>::is_saving())
486 set_hash_valid(
false);
506 FIELD(m_spend_public_key)
507 FIELD(m_view_public_key)
510 BEGIN_KV_SERIALIZE_MAP()
511 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
512 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
513 END_KV_SERIALIZE_MAP()
517 return m_spend_public_key == rhs.m_spend_public_key &&
518 m_view_public_key == rhs.m_view_public_key;
523 return !(*
this == rhs);
Definition: cryptonote_basic.h:160
std::vector< uint8_t > extra
Definition: cryptonote_basic.h:170
std::vector< txin_v > vin
Definition: cryptonote_basic.h:167
size_t version
Definition: cryptonote_basic.h:164
void set_null()
Definition: cryptonote_basic.h:183
std::vector< tx_out > vout
Definition: cryptonote_basic.h:168
uint64_t unlock_time
Definition: cryptonote_basic.h:165
Definition: cryptonote_basic.h:194
bool is_hash_valid() const
Definition: cryptonote_basic.h:221
bool is_prunable_hash_valid() const
Definition: cryptonote_basic.h:223
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:203
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:199
void set_null()
Definition: cryptonote_basic.h:406
transaction()
Definition: cryptonote_basic.h:395
void set_blob_size(size_t sz) const
Definition: cryptonote_basic.h:229
std::atomic< unsigned int > unprunable_size
Definition: cryptonote_basic.h:212
void set_prunable_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:228
std::atomic< unsigned int > prefix_size
Definition: cryptonote_basic.h:213
bool pruned
Definition: cryptonote_basic.h:210
void set_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:227
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:222
static size_t get_signature_size(const txin_v &tx_in)
Definition: cryptonote_basic.h:428
void set_prunable_hash_valid(bool v) const
Definition: cryptonote_basic.h:224
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:364
std::atomic< bool > prunable_hash_valid
Definition: cryptonote_basic.h:198
crypto::hash prunable_hash
Definition: cryptonote_basic.h:207
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:202
void invalidate_hashes()
Definition: cryptonote_basic.h:420
virtual ~transaction()
Definition: cryptonote_basic.h:401
size_t blob_size
Definition: cryptonote_basic.h:208
void set_blob_size_valid(bool v) const
Definition: cryptonote_basic.h:226
crypto::hash hash
Definition: cryptonote_basic.h:206
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:225
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:197
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:41
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:44
const uint32_t T[512]
Definition: groestl_tables.h:36
#define inline
Definition: inline_c.h:34
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:54
Definition: unordered_containers_boost_serialization.h:38
const
Definition: build_protob.py:9
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:67
POD_CLASS public_key
Definition: crypto.h:61
POD_CLASS key_image
Definition: crypto.h:87
POD_CLASS hash
Definition: hash.h:48
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key > txout_target_v
Definition: cryptonote_basic.h:139
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:137
std::vector< crypto::signature > ring_signature
Definition: cryptonote_basic.h:55
static unsigned int getpos(T &ar)
Definition: cryptonote_basic.h:155
version
Supported socks variants.
Definition: socks.h:58
@ RCTTypeNull
Definition: rctTypes.h:254
Definition: blockchain_ancestry.cpp:72
#define BEGIN_SERIALIZE()
Begins the environment of the DSL \detailed for describing how to serialize an of an archive type.
Definition: serialization.h:182
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:191
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:244
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:204
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:255
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:215
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:264
#define false
Definition: stdbool.h:37
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:501
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:503
bool operator!=(const account_public_address &rhs) const
Definition: cryptonote_basic.h:521
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:502
Definition: cryptonote_basic.h:464
transaction miner_tx
Definition: cryptonote_basic.h:478
void set_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:476
void invalidate_hashes()
Definition: cryptonote_basic.h:473
block()
Definition: cryptonote_basic.h:470
crypto::hash hash
Definition: cryptonote_basic.h:482
bool is_hash_valid() const
Definition: cryptonote_basic.h:474
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:475
block(const block &b)
Definition: cryptonote_basic.h:471
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:479
block & operator=(const block &b)
Definition: cryptonote_basic.h:472
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:467
Definition: cryptonote_basic.h:528
crypto::secret_key sec
Definition: cryptonote_basic.h:530
static keypair generate(hw::device &hwdev)
Definition: cryptonote_basic.h:532
crypto::public_key pub
Definition: cryptonote_basic.h:529
Definition: cryptonote_basic.h:143
txout_target_v target
Definition: cryptonote_basic.h:145
uint64_t amount
Definition: cryptonote_basic.h:144
Definition: cryptonote_basic.h:87
size_t height
Definition: cryptonote_basic.h:88
Definition: cryptonote_basic.h:124
crypto::key_image k_image
Definition: cryptonote_basic.h:127
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:126
uint64_t amount
Definition: cryptonote_basic.h:125
Definition: cryptonote_basic.h:96
crypto::hash prev
Definition: cryptonote_basic.h:97
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:99
size_t prevout
Definition: cryptonote_basic.h:98
Definition: cryptonote_basic.h:109
size_t prevout
Definition: cryptonote_basic.h:111
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:113
txout_to_script script
Definition: cryptonote_basic.h:112
crypto::hash prev
Definition: cryptonote_basic.h:110
Definition: cryptonote_basic.h:77
crypto::public_key key
Definition: cryptonote_basic.h:80
txout_to_key()
Definition: cryptonote_basic.h:78
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:79
Definition: cryptonote_basic.h:61
std::vector< crypto::public_key > keys
Definition: cryptonote_basic.h:62
std::vector< uint8_t > script
Definition: cryptonote_basic.h:63
Definition: cryptonote_basic.h:72
crypto::hash hash
Definition: cryptonote_basic.h:73
Definition: debug_archive.h:37
a archive using the JSON standard
Definition: json_archive.h:111
uint8_t type
Definition: rctTypes.h:273
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:283
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:369
Definition: rctTypes.h:536
rctSigPrunable p
Definition: rctTypes.h:537
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition: cryptonote_basic.h:547
for dealing with variants