33#include <boost/variant.hpp>
34#include <boost/functional/hash/hash.hpp>
67 std::vector<crypto::public_key>
keys;
191 if (typename Archive<W>::is_saving())
233 template<
template <
bool>
class Archive>
252 size_t total_key_offsets = 0;
253 for (
size_t i = 0; i < cnt; ++i) {
263 const auto &in = v.back();
264 const bool coinbase = i == 0 && in.type() ==
typeid(
txin_gen);
275 const std::size_t next_toal_key_offsets = total_key_offsets + boost::get<cryptonote::txin_to_key>(in).key_offsets.size();
276 if (next_toal_key_offsets < total_key_offsets)
280 total_key_offsets = next_toal_key_offsets;
288 template<
template <
bool>
class Archive>
291 throw std::runtime_error(
"unexpected writer called deserialize_vin");
345 if (!typename Archive<W>::is_saving())
364 ar.
tag(
"signatures");
367 bool signatures_not_expected =
signatures.empty();
371 if (!
pruned)
for (
size_t i = 0; i <
vin.size(); ++i)
374 if (signatures_not_expected)
376 if (0 == signature_size)
388 if (
vin.size() - i > 1)
395 ar.
tag(
"rct_signatures");
400 if (!r || !
ar.
good())
return false;
408 ar.
tag(
"rctsig_prunable");
411 vin.size() > 0 &&
vin[0].type() ==
typeid(
txin_to_key) ? boost::get<txin_to_key>(
vin[0]).key_offsets.size() - 1 : 0);
412 if (!r || !
ar.
good())
return false;
417 if (!
typename Archive<W>::is_saving())
421 template<
bool W, template <
bool> class Archive>
431 ar.
tag(
"rct_signatures");
436 if (!r || !
ar.
good())
return false;
440 if (!
typename Archive<W>::is_saving())
446 static size_t get_signature_size(
const txin_v& tx_in);
460 if (t.is_hash_valid())
463 set_hash_valid(true);
465 if (t.is_blob_size_valid())
467 blob_size = t.blob_size;
468 set_blob_size_valid(true);
470 if (t.is_prunable_hash_valid())
472 prunable_hash = t.prunable_hash;
473 set_prunable_hash_valid(true);
479 transaction_prefix::operator=(t);
486 if (t.is_hash_valid())
491 if (t.is_prunable_hash_valid())
496 if (t.is_blob_size_valid())
543 struct txin_signature_size_visitor :
public boost::static_visitor<size_t>
545 size_t operator()(
const txin_gen& txin)
const{
return 0;}
551 return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
598 if (!typename Archive<W>::is_saving())
636 return !(*
this == rhs);
cryptonote::block b
Definition block.cpp:40
std::vector< uint8_t > extra
Definition cryptonote_basic.h:185
bool is_coinbase() const
Definition cryptonote_basic.h:215
if(version==0||CURRENT_TRANSACTION_VERSION< version) return false
std::vector< txin_v > vin
Definition cryptonote_basic.h:182
size_t version
Definition cryptonote_basic.h:179
transaction_prefix()
Definition cryptonote_basic.h:295
bool deserialize_vin(Archive< false > &ar)
Definition cryptonote_basic.h:234
void set_null()
Definition cryptonote_basic.h:296
std::vector< tx_out > vout
Definition cryptonote_basic.h:183
bool deserialize_vin(Archive< true > &ar)
Definition cryptonote_basic.h:289
uint64_t unlock_time
Definition cryptonote_basic.h:180
Definition cryptonote_basic.h:307
const auto start_pos
Definition cryptonote_basic.h:352
bool is_hash_valid() const
Definition cryptonote_basic.h:334
bool is_prunable_hash_valid() const
Definition cryptonote_basic.h:336
rct::rctSig rct_signatures
Definition cryptonote_basic.h:316
std::atomic< bool > blob_size_valid
Definition cryptonote_basic.h:312
void set_null()
Definition cryptonote_basic.h:519
transaction()
Definition cryptonote_basic.h:508
void set_blob_size(size_t sz) const
Definition cryptonote_basic.h:342
std::atomic< unsigned int > unprunable_size
Definition cryptonote_basic.h:325
void set_prunable_hash(const crypto::hash &h) const
Definition cryptonote_basic.h:341
std::atomic< unsigned int > prefix_size
Definition cryptonote_basic.h:326
bool pruned
Definition cryptonote_basic.h:323
void set_hash(const crypto::hash &h) const
Definition cryptonote_basic.h:340
void set_hash_valid(bool v) const
Definition cryptonote_basic.h:335
bool serialize_base(Archive< W > &ar)
Definition cryptonote_basic.h:422
static size_t get_signature_size(const txin_v &tx_in)
Definition cryptonote_basic.h:541
if(!typename Archive< W >::is_saving())
Definition cryptonote_basic.h:345
void set_prunable_hash_valid(bool v) const
Definition cryptonote_basic.h:337
transaction & operator=(const transaction &t)
Definition cryptonote_basic.h:477
std::atomic< bool > prunable_hash_valid
Definition cryptonote_basic.h:311
crypto::hash prunable_hash
Definition cryptonote_basic.h:320
std::vector< std::vector< crypto::signature > > signatures
Definition cryptonote_basic.h:315
void invalidate_hashes()
Definition cryptonote_basic.h:533
virtual ~transaction()
Definition cryptonote_basic.h:514
size_t blob_size
Definition cryptonote_basic.h:321
void set_blob_size_valid(bool v) const
Definition cryptonote_basic.h:339
crypto::hash hash
Definition cryptonote_basic.h:319
bool is_blob_size_valid() const
Definition cryptonote_basic.h:338
std::atomic< bool > hash_valid
Definition cryptonote_basic.h:310
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
binary_archive< false > ar
Definition cold-outputs.cpp:54
#define CRYPTONOTE_MAX_TX_PER_BLOCK
Definition cryptonote_config.h:42
#define CURRENT_TRANSACTION_VERSION
Definition cryptonote_config.h:45
#define CRYPTONOTE_MAX_TX_SIZE
Definition cryptonote_config.h:41
#define BEGIN_SERIALIZE()
#define BEGIN_SERIALIZE_OBJECT()
#define BLOB_SERIALIZER(T)
#define CONTAINER_FIELD_CAPPED(f, c)
#define VARIANT_TAG(Archive, Type, Tag)
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec, min_wire)
#define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(varialble)
Definition keyvalue_serialization.h:123
#define END_KV_SERIALIZE_MAP()
Definition keyvalue_serialization.h:118
#define BEGIN_KV_SERIALIZE_MAP()
Definition keyvalue_serialization.h:43
Definition portable_binary_archive.hpp:29
POD_CLASS signature
Definition crypto.h:98
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:72
POD_CLASS view_tag
Definition crypto.h:103
POD_CLASS public_key
Definition crypto.h:64
POD_CLASS key_image
Definition crypto.h:95
POD_CLASS hash
Definition hash.h:49
Holds cryptonote related classes and helpers.
Definition blockchain_db.cpp:45
constexpr size_t COINBASE_VIN_COUNT
Definition cryptonote_basic.h:57
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key > txout_target_v
Definition cryptonote_basic.h:158
constexpr size_t MAX_COINBASE_VOUT_COUNT
Definition cryptonote_basic.h:60
constexpr size_t MAX_TOTAL_KEY_OFFSETS
Definition cryptonote_basic.h:61
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key > txin_v
Definition cryptonote_basic.h:156
constexpr size_t MAX_NON_COINBASE_VOUT_COUNT
Definition cryptonote_basic.h:59
constexpr size_t MAX_VIN_COUNT
Definition cryptonote_basic.h:58
@ RCTTypeNull
Definition rctTypes.h:299
void do_reserve(const C &...)
Reserve space for N elements if applicable for container.
Definition container.h:68
std::enable_if<!use_container_varint< T >(), bool >::type serialize_container_element(Archive &ar, T &e)
Definition container.h:49
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
bool good() const noexcept
Definition binary_archive.h:99
void begin_array(size_t &s)
Definition binary_archive.h:153
void delimit_array()
Definition binary_archive.h:159
size_t remaining_bytes() const noexcept
Definition binary_archive.h:169
void end_array()
Definition binary_archive.h:160
std::size_t getpos() const noexcept
Definition binary_archive.h:104
void set_fail() noexcept
Definition binary_archive.h:100
void begin_object()
Definition binary_archive.h:72
void end_object()
Definition binary_archive.h:73
void tag(const char *)
Definition binary_archive.h:71
Definition binary_archive.h:89
Definition cryptonote_basic.h:614
crypto::public_key m_view_public_key
Definition cryptonote_basic.h:616
bool operator!=(const account_public_address &rhs) const
Definition cryptonote_basic.h:634
crypto::public_key m_spend_public_key
Definition cryptonote_basic.h:615
Definition cryptonote_basic.h:577
transaction miner_tx
Definition cryptonote_basic.h:591
void set_hash(const crypto::hash &h) const
Definition cryptonote_basic.h:589
void invalidate_hashes()
Definition cryptonote_basic.h:586
block()
Definition cryptonote_basic.h:583
crypto::hash hash
Definition cryptonote_basic.h:595
block & operator=(const block &b)
Definition cryptonote_basic.h:585
bool is_hash_valid() const
Definition cryptonote_basic.h:587
void set_hash_valid(bool v) const
Definition cryptonote_basic.h:588
block(const block &b)
Definition cryptonote_basic.h:584
std::vector< crypto::hash > tx_hashes
Definition cryptonote_basic.h:592
if(!typename Archive< W >::is_saving()) set_hash_valid(false)
std::atomic< bool > hash_valid
Definition cryptonote_basic.h:580
Definition cryptonote_basic.h:641
crypto::secret_key sec
Definition cryptonote_basic.h:643
static keypair generate(hw::device &hwdev)
Definition cryptonote_basic.h:645
crypto::public_key pub
Definition cryptonote_basic.h:642
Definition cryptonote_basic.h:162
txout_target_v target
Definition cryptonote_basic.h:164
uint64_t amount
Definition cryptonote_basic.h:163
Definition cryptonote_basic.h:106
size_t height
Definition cryptonote_basic.h:107
Definition cryptonote_basic.h:143
crypto::key_image k_image
Definition cryptonote_basic.h:146
std::vector< uint64_t > key_offsets
Definition cryptonote_basic.h:145
uint64_t amount
Definition cryptonote_basic.h:144
Definition cryptonote_basic.h:115
crypto::hash prev
Definition cryptonote_basic.h:116
std::vector< uint8_t > sigset
Definition cryptonote_basic.h:118
size_t prevout
Definition cryptonote_basic.h:117
Definition cryptonote_basic.h:128
size_t prevout
Definition cryptonote_basic.h:130
std::vector< uint8_t > sigset
Definition cryptonote_basic.h:132
txout_to_script script
Definition cryptonote_basic.h:131
crypto::hash prev
Definition cryptonote_basic.h:129
Definition cryptonote_basic.h:83
crypto::public_key key
Definition cryptonote_basic.h:86
txout_to_key()
Definition cryptonote_basic.h:84
txout_to_key(const crypto::public_key &_key)
Definition cryptonote_basic.h:85
Definition cryptonote_basic.h:66
std::vector< crypto::public_key > keys
Definition cryptonote_basic.h:67
std::vector< uint8_t > script
Definition cryptonote_basic.h:68
Definition cryptonote_basic.h:77
crypto::hash hash
Definition cryptonote_basic.h:78
Definition cryptonote_basic.h:91
txout_to_tagged_key(const crypto::public_key &_key, const crypto::view_tag &_view_tag)
Definition cryptonote_basic.h:93
txout_to_tagged_key()
Definition cryptonote_basic.h:92
crypto::public_key key
Definition cryptonote_basic.h:94
crypto::view_tag view_tag
Definition cryptonote_basic.h:95
Definition debug_archive.h:37
a archive using the JSON standard
Definition json_archive.h:116
uint8_t type
Definition rctTypes.h:319
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition rctTypes.h:333
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition rctTypes.h:432
Definition rctTypes.h:625
rctSigPrunable p
Definition rctTypes.h:626
std::size_t operator()(const cryptonote::account_public_address &addr) const
Definition cryptonote_basic.h:660
for dealing with variants