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;
218 void invalidate_hashes();
219 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
220 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
225 if (!typename Archive<W>::is_saving())
227 set_hash_valid(
false);
228 set_blob_size_valid(
false);
231 FIELDS(*static_cast<transaction_prefix *>(
this))
235 ar.tag(
"signatures");
238 bool signatures_not_expected = signatures.empty();
239 if (!signatures_not_expected && vin.size() != signatures.size())
242 for (
size_t i = 0; i < vin.size(); ++i)
244 size_t signature_size = get_signature_size(vin[i]);
245 if (signatures_not_expected)
247 if (0 == signature_size)
254 if (signature_size != signatures[i].size())
259 if (vin.size() - i > 1)
266 ar.tag(
"rct_signatures");
271 if (!r || !ar.stream().good())
return false;
275 ar.tag(
"rctsig_prunable");
278 vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
279 if (!r || !ar.stream().good())
return false;
286 template<
bool W, template <
bool> class Archive>
287 bool serialize_base(Archive<W> &ar)
289 FIELDS(*static_cast<transaction_prefix *>(
this))
296 ar.tag(
"rct_signatures");
301 if (!r || !ar.stream().good())
return false;
305 return ar.stream().good();
309 static size_t get_signature_size(
const txin_v& tx_in);
335 set_hash_valid(
false);
336 set_blob_size_valid(
false);
342 set_hash_valid(
false);
343 set_blob_size_valid(
false);
349 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
351 size_t operator()(
const txin_gen& txin)
const{
return 0;}
357 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
391 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; }
393 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
394 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
406 if (!typename Archive<W>::is_saving())
407 set_hash_valid(
false);
427 FIELD(m_spend_public_key)
428 FIELD(m_view_public_key)
431 BEGIN_KV_SERIALIZE_MAP()
432 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
433 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
434 END_KV_SERIALIZE_MAP()
crypto::public_key pub
Definition: cryptonote_basic.h:439
block & operator=(const block &b)
Definition: cryptonote_basic.h:391
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:397
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:347
transaction()
Definition: cryptonote_basic.h:314
txout_to_script script
Definition: cryptonote_basic.h:119
Definition: unordered_containers_boost_serialization.h:38
crypto::secret_key sec
Definition: cryptonote_basic.h:440
static const crypto::hash8 null_hash8
Definition: cryptonote_basic.h:59
Definition: cryptonote_basic.h:437
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:382
virtual ~transaction()
Definition: cryptonote_basic.h:320
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:221
uint64_t height
Definition: blockchain.cpp:87
static keypair generate()
Definition: cryptonote_basic.h:442
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:214
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:183
crypto::hash prev
Definition: cryptonote_basic.h:104
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:207
Definition: cryptonote_basic.h:172
std::vector< tx_out > vout
Definition: cryptonote_basic.h:181
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:225
bool is_hash_valid() const
Definition: cryptonote_basic.h:393
Definition: cryptonote_basic.h:162
Definition: cryptonote_basic.h:102
Simple DSL AAPI based on.
std::vector< txin_v > vin
Definition: cryptonote_basic.h:180
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:423
std::vector< uint8_t > script
Definition: cryptonote_basic.h:70
for dealing with variants
block()
Definition: cryptonote_basic.h:389
Definition: cryptonote_basic.h:78
uint64_t unlock_time
Definition: cryptonote_basic.h:178
void invalidate_hashes()
Definition: cryptonote_basic.h:392
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:424
void set_blob_size_valid(bool v) const
Definition: cryptonote_basic.h:222
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:207
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:386
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:394
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:247
rctSigPrunable p
Definition: rctTypes.h:324
void invalidate_hashes()
Definition: cryptonote_basic.h:340
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 for described the serialization of an object
Definition: serialization.h:188
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition: crypto.h:184
Definition: rctTypes.h:323
size_t version
Definition: cryptonote_basic.h:177
uint64_t expiration_date
Definition: cryptonote_basic.h:163
#define false
Definition: stdbool.h:38
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:203
transaction miner_tx
Definition: cryptonote_basic.h:396
crypto::hash hash
Definition: cryptonote_basic.h:80
POD_CLASS public_key
Definition: crypto.h:65
void set_null()
Definition: cryptonote_basic.h:326
std::string signature
Definition: cryptonote_basic.h:399
bool is_hash_valid() const
Definition: cryptonote_basic.h:219
BLOB_SERIALIZER(cryptonote::txout_to_key)
uint8_t version
Definition: blockchain.cpp:86
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:206
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:106
POD_CLASS signature
Definition: crypto.h:99
Definition: cryptonote_basic.h:421
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:215
std::string signatory
Definition: cryptonote_basic.h:400
std::string validators
Definition: cryptonote_basic.h:164
POD_CLASS key_image
Definition: crypto.h:93
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:256
POD_CLASS secret_key
Definition: crypto.h:69
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:210
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:220
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:202
block(const block &b)
Definition: cryptonote_basic.h:390
txout_to_key()
Definition: cryptonote_basic.h:85
#define BEGIN_SERIALIZE()
Begins the environment of the DSL for describing how to serialize an of an archive type...
Definition: serialization.h:179
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:46
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:201
crypto::hash hash
Definition: cryptonote_basic.h:403
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:236
size_t blob_size
Definition: cryptonote_basic.h:211
size_t height
Definition: cryptonote_basic.h:95
Definition: binary_archive.h:95
Definition: debug_archive.h:38
Definition: cryptonote_basic.h:198
a archive using the JSON standard
Definition: json_archive.h:112