36 #include "include_base_utils.h" 54 auto it = std::find_if(tx_extra_fields.begin(), tx_extra_fields.end(), [&index](
const tx_extra_field& f) {
return typeid(
T) == f.type() && !index--; });
55 if(tx_extra_fields.end() == it)
58 field = boost::get<T>(*it);
62 bool parse_tx_extra(
const std::vector<uint8_t>& tx_extra, std::vector<tx_extra_field>& tx_extra_fields);
75 bool lookup_acc_outs(
const account_keys& acc,
const transaction& tx,
const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered);
76 bool lookup_acc_outs(
const account_keys& acc,
const transaction& tx, std::vector<size_t>& outs, uint64_t& money_transfered);
77 bool get_tx_fee(
const transaction& tx, uint64_t & fee);
100 bool parse_amount(uint64_t& amount,
const std::string& str_amount);
110 std::string
get_unit(
unsigned int decimal_point = -1);
111 std::string
print_money(uint64_t amount,
unsigned int decimal_point = -1);
113 template<
class t_
object>
116 std::stringstream ss;
123 template<
class t_
object>
131 template<
class t_
object>
138 template<
class t_
object>
145 template<
class t_
object>
149 blob_size = bl.size();
154 template <
typename T>
157 std::stringstream ss;
160 CHECK_AND_ASSERT_MES(r,
"",
"obj_to_json_str failed: serialization::serialize returned false");
165 template<
typename chunk_handler_t,
typename dust_handler_t>
173 bool is_dust_handled =
false;
178 uint64_t chunk = (amount % 10) * order;
182 if (dust + chunk <= dust_threshold)
188 if (!is_dust_handled && 0 != dust)
191 is_dust_handled =
true;
195 chunk_handler(chunk);
200 if (!is_dust_handled && 0 != dust)
214 void get_hash_stats(uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t & block_hashes_cached);
216 #define CHECKED_GET_SPECIFIC_VARIANT(variant_var, specific_type, variable_name, fail_return_val) \ 217 CHECK_AND_ASSERT_MES(variant_var.type() == typeid(specific_type), fail_return_val, "wrong variant type: " << variant_var.type().name() << ", expected " << typeid(specific_type).name()); \ 218 specific_type& variable_name = boost::get<specific_type>(variant_var); bool parse_tx_extra(const std::vector< uint8_t > &tx_extra, std::vector< tx_extra_field > &tx_extra_fields)
Definition: cryptonote_format_utils.cpp:218
bool check_outs_overflow(const transaction &tx)
Definition: cryptonote_format_utils.cpp:447
uint64_t get_outs_money_amount(const transaction &tx)
Definition: cryptonote_format_utils.cpp:459
const uint32_t T[512]
Definition: groestl_tables.h:34
bool get_tx_fee(const transaction &tx, uint64_t &fee)
Definition: cryptonote_format_utils.cpp:193
bool check_outs_valid(const transaction &tx)
Definition: cryptonote_format_utils.cpp:413
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT
Definition: cryptonote_config.h:67
POD_CLASS key_derivation
Definition: crypto.h:89
void serialize(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:127
size_t get_object_blobsize(const t_object &o)
Definition: cryptonote_format_utils.h:139
void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
Definition: cryptonote_format_utils.h:166
uint64_t height
Definition: blockchain.cpp:87
bool calculate_block_hash(const block &b, crypto::hash &res)
Definition: cryptonote_format_utils.cpp:691
Definition: binary_archive.h:182
bool find_tx_extra_field_by_type(const std::vector< tx_extra_field > &tx_extra_fields, T &field, size_t index=0)
Definition: cryptonote_format_utils.h:52
std::vector< uint64_t > relative_output_offsets_to_absolute(const std::vector< uint64_t > &off)
Definition: cryptonote_format_utils.cpp:731
bool encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key)
Definition: cryptonote_format_utils.cpp:359
std::string get_unit(unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:539
bool get_object_hash(const t_object &o, crypto::hash &res)
Definition: cryptonote_format_utils.h:132
bool calculate_transaction_hash(const transaction &t, crypto::hash &res, size_t *blob_size)
Definition: cryptonote_format_utils.cpp:588
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:225
bool parse_amount(uint64_t &amount, const std::string &str_amount_)
Definition: cryptonote_format_utils.cpp:158
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
Definition: cryptonote_format_utils.cpp:723
blobdata tx_to_blob(const transaction &tx)
Definition: cryptonote_format_utils.cpp:780
bool is_out_to_acc_precomp(const crypto::public_key &spend_public_key, const txout_to_key &out_key, const crypto::key_derivation &derivation, size_t output_index)
Definition: cryptonote_format_utils.cpp:485
bool is_valid_decomposed_amount(uint64_t amount)
Definition: cryptonote_format_utils.cpp:814
bool add_tx_pub_key_to_extra(transaction &tx, const crypto::public_key &tx_pub_key)
Definition: cryptonote_format_utils.cpp:268
unsigned int get_default_decimal_point()
Definition: cryptonote_format_utils.cpp:534
Definition: json_archive.h:115
bool get_inputs_money_amount(const transaction &tx, uint64_t &money)
Definition: cryptonote_format_utils.cpp:383
bool check_inputs_types_supported(const transaction &tx)
Definition: cryptonote_format_utils.cpp:401
bool get_block_hash(const block &b, crypto::hash &res)
Definition: cryptonote_format_utils.cpp:696
bool check_money_overflow(const transaction &tx)
Definition: cryptonote_format_utils.cpp:429
std::vector< uint64_t > absolute_output_offsets_to_relative(const std::vector< uint64_t > &off)
Definition: cryptonote_format_utils.cpp:739
blobdata get_block_hashing_blob(const block &b)
Definition: cryptonote_format_utils.cpp:682
std::string obj_to_json_str(T &obj)
Definition: cryptonote_format_utils.h:155
int b
Definition: base.py:1
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
Definition: cryptonote_format_utils.h:114
bool get_payment_id_from_tx_extra_nonce(const blobdata &extra_nonce, crypto::hash &payment_id)
Definition: cryptonote_format_utils.cpp:339
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
Definition: cryptonote_format_utils.cpp:246
bool is_out_to_acc(const account_keys &acc, const txout_to_key &out_key, const crypto::public_key &tx_pub_key, size_t output_index)
Definition: cryptonote_format_utils.cpp:476
type
Definition: json.h:74
boost::variant< tx_extra_padding, tx_extra_pub_key, tx_extra_nonce, tx_extra_merge_mining_tag, tx_extra_mysterious_minergate > tx_extra_field
Definition: tx_extra.h:176
bool parse_and_validate_tx_base_from_blob(const blobdata &tx_blob, transaction &tx)
Definition: cryptonote_format_utils.cpp:108
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
Definition: cryptonote_format_utils.cpp:97
POD_CLASS public_key
Definition: crypto.h:65
void set_default_decimal_point(unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:522
bool get_encrypted_payment_id_from_tx_extra_nonce(const blobdata &extra_nonce, crypto::hash8 &payment_id)
Definition: cryptonote_format_utils.cpp:349
bool check_inputs_overflow(const transaction &tx)
Definition: cryptonote_format_utils.cpp:434
std::string blobdata
Definition: blobdatatype.h:36
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h)
Definition: cryptonote_format_utils.cpp:82
POD_CLASS hash8
Definition: hash.h:49
POD_CLASS key_image
Definition: crypto.h:93
bool decrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key)
Definition: cryptonote_format_utils.cpp:377
POD_CLASS secret_key
Definition: crypto.h:69
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:575
bool remove_field_from_tx_extra(std::vector< uint8_t > &tx_extra, const std::type_info &type)
Definition: cryptonote_format_utils.cpp:292
bool add_extra_nonce_to_tx_extra(std::vector< uint8_t > &tx_extra, const blobdata &extra_nonce)
Definition: cryptonote_format_utils.cpp:276
POD_CLASS hash
Definition: hash.h:46
void get_tx_tree_hash(const std::vector< crypto::hash > &tx_hashes, crypto::hash &h)
Definition: cryptonote_format_utils.cpp:790
void set_encrypted_payment_id_to_tx_extra_nonce(blobdata &extra_nonce, const crypto::hash8 &payment_id)
Definition: cryptonote_format_utils.cpp:331
void get_hash_stats(uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t &block_hashes_cached)
Definition: cryptonote_format_utils.cpp:821
void set_payment_id_to_tx_extra_nonce(blobdata &extra_nonce, const crypto::hash &payment_id)
Definition: cryptonote_format_utils.cpp:323
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:554
bool lookup_acc_outs(const account_keys &acc, const transaction &tx, std::vector< size_t > &outs, uint64_t &money_transfered)
Definition: cryptonote_format_utils.cpp:492
blobdata block_to_blob(const block &b)
Definition: cryptonote_format_utils.cpp:770
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b)
Definition: cryptonote_format_utils.cpp:758
uint64_t get_block_height(const block &b)
Definition: cryptonote_format_utils.cpp:394
bool generate_key_image_helper(const account_keys &ack, const crypto::public_key &tx_public_key, size_t real_output_index, keypair &in_ephemeral, crypto::key_image &ki)
Definition: cryptonote_format_utils.cpp:133
std::string short_hash_str(const crypto::hash &h)
Definition: cryptonote_format_utils.cpp:467
void get_blob_hash(const blobdata &blob, crypto::hash &res)
Definition: cryptonote_format_utils.cpp:517