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);
241 FIELDS(*static_cast<transaction_prefix *>(
this))
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)
311 FIELDS(*static_cast<transaction_prefix *>(
this))
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);
crypto::public_key pub
Definition: cryptonote_basic.h:529
block & operator=(const block &b)
Definition: cryptonote_basic.h:472
const uint32_t T[512]
Definition: groestl_tables.h:36
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:479
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key > txout_target_v
Definition: cryptonote_basic.h:139
Definition: cryptonote_basic.h:108
static size_t get_signature_size(const txin_v &tx_in)
Definition: cryptonote_basic.h:428
transaction()
Definition: cryptonote_basic.h:395
txout_to_script script
Definition: cryptonote_basic.h:112
Definition: unordered_containers_boost_serialization.h:37
crypto::secret_key sec
Definition: cryptonote_basic.h:530
Definition: rctTypes.h:254
Definition: cryptonote_basic.h:527
stream_type & stream()
Definition: binary_archive.h:77
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:369
Definition: cryptonote_basic.h:463
virtual ~transaction()
Definition: cryptonote_basic.h:401
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:225
size_t prevout
Definition: cryptonote_basic.h:111
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:67
Definition: blockchain_ancestry.cpp:71
Definition: binary_archive.h:186
size_t prevout
Definition: cryptonote_basic.h:98
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:126
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:364
Definition: cryptonote_basic.h:76
Definition: cryptonote_basic.h:60
const
Definition: build_protob.py:9
Definition: cryptonote_basic.h:86
std::vector< crypto::signature > ring_signature
Definition: cryptonote_basic.h:55
std::vector< uint8_t > extra
Definition: cryptonote_basic.h:170
crypto::hash prev
Definition: cryptonote_basic.h:97
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:215
Definition: cryptonote_basic.h:159
std::vector< tx_out > vout
Definition: cryptonote_basic.h:168
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
bool is_hash_valid() const
Definition: cryptonote_basic.h:474
static unsigned int getpos(T &ar)
Definition: cryptonote_basic.h:155
Definition: cryptonote_basic.h:95
std::vector< txin_v > vin
Definition: cryptonote_basic.h:167
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:502
std::vector< uint8_t > script
Definition: cryptonote_basic.h:63
for dealing with variants
block()
Definition: cryptonote_basic.h:470
Definition: cryptonote_basic.h:71
uint64_t unlock_time
Definition: cryptonote_basic.h:165
void invalidate_hashes()
Definition: cryptonote_basic.h:473
bool pruned
Definition: cryptonote_basic.h:210
Definition: binary_archive.h:98
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:503
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:226
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:203
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:467
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:475
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:255
void set_blob_size(size_t sz) const
Definition: cryptonote_basic.h:229
rctSigPrunable p
Definition: rctTypes.h:537
void invalidate_hashes()
Definition: cryptonote_basic.h:420
uint64_t amount
Definition: cryptonote_basic.h:125
crypto::hash prunable_hash
Definition: cryptonote_basic.h:207
int b
Definition: base.py:1
Definition: cryptonote_basic.h:123
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL for described the serialization of an object
Definition: serialization.h:191
Definition: rctTypes.h:536
void load(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:54
size_t version
Definition: cryptonote_basic.h:164
Definition: device.hpp:87
#define false
Definition: stdbool.h:37
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:199
void set_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:227
transaction miner_tx
Definition: cryptonote_basic.h:478
static keypair generate(hw::device &hwdev)
Definition: cryptonote_basic.h:532
crypto::hash hash
Definition: cryptonote_basic.h:73
POD_CLASS public_key
Definition: crypto.h:61
void set_null()
Definition: cryptonote_basic.h:406
version
Supported socks variants.
Definition: socks.h:57
void set_prunable_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:228
bool is_hash_valid() const
Definition: cryptonote_basic.h:221
BLOB_SERIALIZER(cryptonote::txout_to_key)
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:202
std::atomic< unsigned int > prefix_size
Definition: cryptonote_basic.h:213
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:99
void set_null()
Definition: cryptonote_basic.h:183
Definition: cryptonote_basic.h:500
crypto::hash prev
Definition: cryptonote_basic.h:110
crypto::public_key key
Definition: cryptonote_basic.h:80
#define CRYPTONOTE_MAX_TX_PER_BLOCK
Definition: cryptonote_config.h:41
POD_CLASS key_image
Definition: crypto.h:87
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:264
VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff)
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:113
uint64_t amount
Definition: cryptonote_basic.h:144
uint8_t type
Definition: rctTypes.h:273
txout_target_v target
Definition: cryptonote_basic.h:145
crypto::key_image k_image
Definition: cryptonote_basic.h:127
crypto::hash hash
Definition: cryptonote_basic.h:206
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:222
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:197
block(const block &b)
Definition: cryptonote_basic.h:471
txout_to_key()
Definition: cryptonote_basic.h:78
#define BEGIN_SERIALIZE()
Begins the environment of the DSL for describing how to serialize an of an archive type...
Definition: serialization.h:182
std::vector< crypto::public_key > keys
Definition: cryptonote_basic.h:62
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:137
bool is_prunable_hash_valid() const
Definition: cryptonote_basic.h:223
POD_CLASS hash
Definition: hash.h:48
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:79
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:44
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:204
crypto::hash hash
Definition: cryptonote_basic.h:482
Definition: cryptonote_basic.h:142
bool operator!=(const account_public_address &rhs) const
Definition: cryptonote_basic.h:521
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:283
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:244
size_t blob_size
Definition: cryptonote_basic.h:208
size_t height
Definition: cryptonote_basic.h:88
Definition: binary_archive.h:94
void set_prunable_hash_valid(bool v) const
Definition: cryptonote_basic.h:224
Definition: debug_archive.h:37
void set_hash(const crypto::hash &h) const
Definition: cryptonote_basic.h:476
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition: cryptonote_basic.h:547
Definition: cryptonote_basic.h:193
std::atomic< unsigned int > unprunable_size
Definition: cryptonote_basic.h:212
a archive using the JSON standard
Definition: json_archive.h:113
#define inline
Definition: inline_c.h:34
std::atomic< bool > prunable_hash_valid
Definition: cryptonote_basic.h:198