34 #include <boost/variant.hpp> 35 #include <boost/functional/hash/hash.hpp> 47 #include "serialization/keyvalue_serialization.h" 51 #include "misc_language.h" 69 std::vector<crypto::public_key>
keys;
208 void invalidate_hashes();
209 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
210 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
215 if (!typename Archive<W>::is_saving())
217 set_hash_valid(
false);
218 set_blob_size_valid(
false);
221 FIELDS(*static_cast<transaction_prefix *>(
this))
225 ar.tag(
"signatures");
228 bool signatures_not_expected = signatures.empty();
229 if (!signatures_not_expected && vin.size() != signatures.size())
232 for (
size_t i = 0; i < vin.size(); ++i)
234 size_t signature_size = get_signature_size(vin[i]);
235 if (signatures_not_expected)
237 if (0 == signature_size)
244 if (signature_size != signatures[i].size())
249 if (vin.size() - i > 1)
256 ar.tag(
"rct_signatures");
261 if (!r || !ar.stream().good())
return false;
265 ar.tag(
"rctsig_prunable");
268 vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
269 if (!r || !ar.stream().good())
return false;
276 template<
bool W, template <
bool> class Archive>
277 bool serialize_base(Archive<W> &ar)
279 FIELDS(*static_cast<transaction_prefix *>(
this))
286 ar.tag(
"rct_signatures");
291 if (!r || !ar.stream().good())
return false;
299 static size_t get_signature_size(
const txin_v& tx_in);
325 set_hash_valid(
false);
326 set_blob_size_valid(
false);
332 set_hash_valid(
false);
333 set_blob_size_valid(
false);
339 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
341 size_t operator()(
const txin_gen& txin)
const{
return 0;}
347 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
381 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; }
383 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
384 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
393 if (!typename Archive<W>::is_saving())
394 set_hash_valid(
false);
412 FIELD(m_spend_public_key)
413 FIELD(m_view_public_key)
416 BEGIN_KV_SERIALIZE_MAP()
417 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
418 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
419 END_KV_SERIALIZE_MAP()
crypto::public_key pub
Definition: cryptonote_basic.h:424
block & operator=(const block &b)
Definition: cryptonote_basic.h:381
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:387
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key > txout_target_v
Definition: cryptonote_basic.h:146
Definition: cryptonote_basic.h:115
static size_t get_signature_size(const txin_v &tx_in)
Definition: cryptonote_basic.h:337
transaction()
Definition: cryptonote_basic.h:304
txout_to_script script
Definition: cryptonote_basic.h:119
Definition: unordered_containers_boost_serialization.h:38
crypto::secret_key sec
Definition: cryptonote_basic.h:425
static const crypto::hash8 null_hash8
Definition: cryptonote_basic.h:59
Definition: cryptonote_basic.h:422
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:252
Definition: cryptonote_basic.h:372
virtual ~transaction()
Definition: cryptonote_basic.h:310
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:211
uint64_t height
Definition: blockchain.cpp:87
static keypair generate()
Definition: cryptonote_basic.h:427
size_t prevout
Definition: cryptonote_basic.h:118
Definition: rctTypes.h:177
static const crypto::hash null_hash
Definition: cryptonote_basic.h:58
size_t prevout
Definition: cryptonote_basic.h:105
transaction(const transaction &t)
Definition: cryptonote_basic.h:204
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:133
Definition: cryptonote_basic.h:83
Definition: cryptonote_basic.h:67
Definition: cryptonote_basic.h:93
std::vector< crypto::signature > ring_signature
Definition: cryptonote_basic.h:62
std::vector< uint8_t > extra
Definition: cryptonote_basic.h:173
crypto::hash prev
Definition: cryptonote_basic.h:104
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:205
Definition: cryptonote_basic.h:162
std::vector< tx_out > vout
Definition: cryptonote_basic.h:171
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:225
bool is_hash_valid() const
Definition: cryptonote_basic.h:383
Definition: cryptonote_basic.h:102
Simple DSL AAPI based on.
std::vector< txin_v > vin
Definition: cryptonote_basic.h:170
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:408
std::vector< uint8_t > script
Definition: cryptonote_basic.h:70
for dealing with variants
block()
Definition: cryptonote_basic.h:379
Definition: cryptonote_basic.h:78
uint64_t unlock_time
Definition: cryptonote_basic.h:168
void invalidate_hashes()
Definition: cryptonote_basic.h:382
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:409
void set_blob_size_valid(bool v) const
Definition: cryptonote_basic.h:212
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:197
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:376
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:384
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:245
rctSigPrunable p
Definition: rctTypes.h:324
void invalidate_hashes()
Definition: cryptonote_basic.h:330
static const crypto::public_key null_pkey
Definition: cryptonote_basic.h:60
uint64_t amount
Definition: cryptonote_basic.h:132
int b
Definition: base.py:1
Definition: cryptonote_basic.h:130
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:186
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition: crypto.h:162
Definition: rctTypes.h:323
size_t version
Definition: cryptonote_basic.h:167
#define false
Definition: stdbool.h:38
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:193
transaction miner_tx
Definition: cryptonote_basic.h:386
crypto::hash hash
Definition: cryptonote_basic.h:80
POD_CLASS public_key
Definition: crypto.h:58
void set_null()
Definition: cryptonote_basic.h:316
bool is_hash_valid() const
Definition: cryptonote_basic.h:209
BLOB_SERIALIZER(cryptonote::txout_to_key)
uint8_t version
Definition: blockchain.cpp:86
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:196
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:106
Definition: cryptonote_basic.h:406
crypto::hash prev
Definition: cryptonote_basic.h:117
POD_CLASS hash8
Definition: hash.h:49
crypto::public_key key
Definition: cryptonote_basic.h:87
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:205
POD_CLASS key_image
Definition: crypto.h:86
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:254
POD_CLASS secret_key
Definition: crypto.h:62
VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff)
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:120
uint64_t amount
Definition: cryptonote_basic.h:151
uint8_t type
Definition: rctTypes.h:182
txout_target_v target
Definition: cryptonote_basic.h:152
crypto::key_image k_image
Definition: cryptonote_basic.h:134
crypto::hash hash
Definition: cryptonote_basic.h:200
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:210
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:192
block(const block &b)
Definition: cryptonote_basic.h:380
txout_to_key()
Definition: cryptonote_basic.h:85
#define BEGIN_SERIALIZE()
Begins the environment of the DSL \detailed for describing how to serialize an of an archive type.
Definition: serialization.h:177
std::vector< crypto::public_key > keys
Definition: cryptonote_basic.h:69
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition: cryptonote_basic.h:144
POD_CLASS hash
Definition: hash.h:46
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:86
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:45
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:199
crypto::hash hash
Definition: cryptonote_basic.h:390
Definition: cryptonote_basic.h:149
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:192
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:234
size_t blob_size
Definition: cryptonote_basic.h:201
size_t height
Definition: cryptonote_basic.h:95
Definition: binary_archive.h:95
Definition: debug_archive.h:38
Definition: cryptonote_basic.h:188
a archive using the JSON standard
Definition: json_archive.h:112