33 #include <boost/variant.hpp> 34 #include <boost/functional/hash/hash.hpp> 45 #include "serialization/keyvalue_serialization.h" 49 #include "misc_language.h" 63 std::vector<crypto::public_key>
keys;
202 void invalidate_hashes();
203 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
204 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
209 if (!typename Archive<W>::is_saving())
211 set_hash_valid(
false);
212 set_blob_size_valid(
false);
215 FIELDS(*static_cast<transaction_prefix *>(
this))
219 ar.tag(
"signatures");
222 bool signatures_not_expected = signatures.empty();
223 if (!signatures_not_expected && vin.size() != signatures.size())
226 for (
size_t i = 0; i < vin.size(); ++i)
228 size_t signature_size = get_signature_size(vin[i]);
229 if (signatures_not_expected)
231 if (0 == signature_size)
238 if (signature_size != signatures[i].size())
243 if (vin.size() - i > 1)
250 ar.tag(
"rct_signatures");
255 if (!r || !ar.stream().good())
return false;
259 ar.tag(
"rctsig_prunable");
262 vin.size() > 0 && vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
263 if (!r || !ar.stream().good())
return false;
270 template<
bool W, template <
bool> class Archive>
271 bool serialize_base(Archive<W> &ar)
273 FIELDS(*static_cast<transaction_prefix *>(
this))
280 ar.tag(
"rct_signatures");
285 if (!r || !ar.stream().good())
return false;
293 static size_t get_signature_size(
const txin_v& tx_in);
319 set_hash_valid(
false);
320 set_blob_size_valid(
false);
326 set_hash_valid(
false);
327 set_blob_size_valid(
false);
333 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
335 size_t operator()(
const txin_gen& txin)
const{
return 0;}
341 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
375 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; }
377 bool is_hash_valid()
const {
return hash_valid.load(std::memory_order_acquire); }
378 void set_hash_valid(
bool v)
const { hash_valid.store(v,std::memory_order_release); }
387 if (!typename Archive<W>::is_saving())
388 set_hash_valid(
false);
406 FIELD(m_spend_public_key)
407 FIELD(m_view_public_key)
410 BEGIN_KV_SERIALIZE_MAP()
411 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_public_key)
412 KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_public_key)
413 END_KV_SERIALIZE_MAP()
417 return m_spend_public_key == rhs.m_spend_public_key &&
418 m_view_public_key == rhs.m_view_public_key;
423 return !(*
this == rhs);
crypto::public_key pub
Definition: cryptonote_basic.h:429
block & operator=(const block &b)
Definition: cryptonote_basic.h:375
std::vector< crypto::hash > tx_hashes
Definition: cryptonote_basic.h:381
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:331
transaction()
Definition: cryptonote_basic.h:298
txout_to_script script
Definition: cryptonote_basic.h:113
Definition: unordered_containers_boost_serialization.h:37
crypto::secret_key sec
Definition: cryptonote_basic.h:430
Definition: cryptonote_basic.h:427
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:308
Definition: cryptonote_basic.h:366
virtual ~transaction()
Definition: cryptonote_basic.h:304
bool is_blob_size_valid() const
Definition: cryptonote_basic.h:205
uint64_t height
Definition: blockchain.cpp:88
size_t prevout
Definition: cryptonote_basic.h:112
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:69
Definition: blockchain_ancestry.cpp:70
size_t prevout
Definition: cryptonote_basic.h:99
transaction(const transaction &t)
Definition: cryptonote_basic.h:198
std::vector< uint64_t > key_offsets
Definition: cryptonote_basic.h:127
Definition: cryptonote_basic.h:77
Definition: cryptonote_basic.h:61
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:167
crypto::hash prev
Definition: cryptonote_basic.h:98
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
Definition: cryptonote_basic.h:156
std::vector< tx_out > vout
Definition: cryptonote_basic.h:165
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:224
bool is_hash_valid() const
Definition: cryptonote_basic.h:377
Definition: cryptonote_basic.h:96
std::vector< txin_v > vin
Definition: cryptonote_basic.h:164
crypto::public_key m_spend_public_key
Definition: cryptonote_basic.h:402
std::vector< uint8_t > script
Definition: cryptonote_basic.h:64
for dealing with variants
block()
Definition: cryptonote_basic.h:373
Definition: cryptonote_basic.h:72
uint64_t unlock_time
Definition: cryptonote_basic.h:162
void invalidate_hashes()
Definition: cryptonote_basic.h:376
crypto::public_key m_view_public_key
Definition: cryptonote_basic.h:403
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:206
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:191
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:370
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:378
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:254
rctSigPrunable p
Definition: rctTypes.h:417
void invalidate_hashes()
Definition: cryptonote_basic.h:324
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:416
size_t version
Definition: cryptonote_basic.h:161
Definition: device.hpp:82
#define false
Definition: stdbool.h:37
std::atomic< bool > blob_size_valid
Definition: cryptonote_basic.h:187
transaction miner_tx
Definition: cryptonote_basic.h:380
static keypair generate(hw::device &hwdev)
Definition: cryptonote_basic.h:432
crypto::hash hash
Definition: cryptonote_basic.h:74
POD_CLASS public_key
Definition: crypto.h:63
void set_null()
Definition: cryptonote_basic.h:310
bool is_hash_valid() const
Definition: cryptonote_basic.h:203
BLOB_SERIALIZER(cryptonote::txout_to_key)
uint8_t version
Definition: blockchain.cpp:87
std::vector< std::vector< crypto::signature > > signatures
Definition: cryptonote_basic.h:190
std::vector< uint8_t > sigset
Definition: cryptonote_basic.h:100
Definition: cryptonote_basic.h:400
crypto::hash prev
Definition: cryptonote_basic.h:111
crypto::public_key key
Definition: cryptonote_basic.h:81
transaction & operator=(const transaction &t)
Definition: cryptonote_basic.h:199
POD_CLASS key_image
Definition: crypto.h:89
#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:236
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:194
void set_hash_valid(bool v) const
Definition: cryptonote_basic.h:204
std::atomic< bool > hash_valid
Definition: cryptonote_basic.h:186
block(const block &b)
Definition: cryptonote_basic.h:374
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:49
Definition: rctTypes.h:229
txout_to_key(const crypto::public_key &_key)
Definition: cryptonote_basic.h:80
#define CURRENT_TRANSACTION_VERSION
Definition: cryptonote_config.h:44
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:203
crypto::hash hash
Definition: cryptonote_basic.h:384
Definition: cryptonote_basic.h:143
bool operator!=(const account_public_address &rhs) const
Definition: cryptonote_basic.h:421
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:246
#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:195
size_t height
Definition: cryptonote_basic.h:89
Definition: binary_archive.h:94
Definition: debug_archive.h:37
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition: cryptonote_basic.h:447
Definition: cryptonote_basic.h:182
a archive using the JSON standard
Definition: json_archive.h:111