Electroneum
Loading...
Searching...
No Matches
cryptonote Namespace Reference

Holds cryptonote related classes and helpers. More...

Namespaces

namespace  bootstrap
namespace  rpc
namespace  json

Classes

struct  output_data_t
 a struct containing output metadata More...
struct  tx_data_t
struct  txpool_tx_meta_t
 a struct containing txpool per transaction metadata More...
struct  chainstate_key_t
struct  chainstate_value_t
struct  tx_input_t
class  DB_EXCEPTION
 A base class for BlockchainDB exceptions. More...
class  DB_ERROR
 A generic BlockchainDB exception. More...
class  DB_ERROR_TXN_START
 thrown when there is an error starting a DB transaction More...
class  DB_OPEN_FAILURE
 thrown when opening the BlockchainDB fails More...
class  DB_CREATE_FAILURE
 thrown when creating the BlockchainDB fails More...
class  DB_SYNC_FAILURE
 thrown when synchronizing the BlockchainDB to disk fails More...
class  BLOCK_DNE
 thrown when a requested block does not exist More...
class  BLOCK_PARENT_DNE
 thrown when a block's parent does not exist (and it needed to) More...
class  BLOCK_EXISTS
 thrown when a block exists, but shouldn't, namely when adding a block More...
class  BLOCK_INVALID
 thrown when something is wrong with the block to be added More...
class  TX_DNE
 thrown when a requested transaction does not exist More...
class  TX_EXISTS
 thrown when a transaction exists, but shouldn't, namely when adding a block More...
class  OUTPUT_DNE
 thrown when a requested output does not exist More...
class  OUTPUT_EXISTS
 thrown when an output exists, but shouldn't, namely when adding a block More...
class  KEY_IMAGE_EXISTS
 thrown when a spent key image exists, but shouldn't, namely when adding a block More...
class  UTXO_EXISTS
 thrown when a utxo already exists, but shouldn't, namely when adding a block More...
class  ADDR_OUTPUT_EXISTS
 thrown when an output record for an address already exists, but shouldn't, namely when adding a block More...
class  ADDR_TX_EXISTS
class  BlockchainDB
 The BlockchainDB backing store interface declaration/contract. More...
class  db_txn_guard
class  db_rtxn_guard
class  db_wtxn_guard
struct  mdb_block_info_1
struct  mdb_block_info_2
struct  mdb_block_info_3
struct  mdb_block_info_4
struct  blk_height
struct  pre_rct_outkey
struct  outkey
struct  outtx
struct  acc_outs_t
struct  acc_addr_tx_t
struct  txindex
struct  mdb_txn_cursors
struct  mdb_rflags
struct  mdb_threadinfo
struct  mdb_txn_safe
class  BlockchainLMDB
struct  t_hashline
 struct for loading a checkpoint from json More...
struct  t_hash_json
 struct for loading many checkpoints from json More...
class  checkpoints
 A container for blockchain checkpoints. More...
struct  account_keys
class  account_base
struct  cryptonote_connection_context
struct  address_outputs
struct  address_txs
struct  account_public_address
struct  txout_to_script
struct  txout_to_scripthash
struct  txout_to_key
struct  txout_to_key_public
struct  txin_gen
struct  txin_to_script
struct  txin_to_scripthash
struct  txin_to_key
struct  txin_to_key_public
struct  tx_out
struct  validator_db
class  transaction_prefix
class  transaction
struct  block_header
struct  block
struct  keypair
struct  integrated_address
struct  array_hasher
struct  public_address_outer_blob
struct  public_integrated_address_outer_blob
struct  address_parse_info
struct  subaddress_receive_info
struct  core_stat_info_t
class  HardFork
struct  i_miner_handler
class  miner
struct  subaddress_index
struct  tx_extra_padding
struct  tx_extra_pub_key
struct  tx_extra_nonce
struct  tx_extra_merge_mining_tag
struct  tx_extra_additional_pub_keys
struct  tx_extra_bridge_source_address
struct  tx_extra_bridge_smartchain_address
struct  tx_extra_bridge_ownership_sig
struct  tx_extra_mysterious_minergate
struct  tx_verification_context
struct  block_verification_context
struct  config_t
class  Blockchain
struct  test_options
class  core
 handles core cryptonote functionality More...
struct  tx_source_entry
struct  tx_destination_entry
class  txCompare
class  tx_memory_pool
 Transaction pool, handles transactions which are not part of a block. More...
class  block_queue
struct  connection_info
struct  block_complete_entry
struct  NOTIFY_NEW_BLOCK
struct  NOTIFY_NEW_TRANSACTIONS
struct  NOTIFY_REQUEST_GET_OBJECTS
struct  NOTIFY_RESPONSE_GET_OBJECTS
struct  CORE_SYNC_DATA
struct  NOTIFY_REQUEST_CHAIN
struct  NOTIFY_RESPONSE_CHAIN_ENTRY
struct  NOTIFY_NEW_FLUFFY_BLOCK
struct  NOTIFY_REQUEST_FLUFFY_MISSING_TX
struct  NOTIFY_REQUEST_VALIDATORS_LIST
struct  NOTIFY_EMERGENCY_VALIDATORS_LIST
class  cryptonote_protocol_handler_base_pimpl
class  cryptonote_protocol_handler_base
class  t_cryptonote_protocol_handler
struct  i_cryptonote_protocol
struct  cryptonote_protocol_stub
class  pruned_transaction
class  core_rpc_server
struct  COMMAND_RPC_GET_HEIGHT
struct  COMMAND_RPC_GET_BLOCKS_FAST
struct  COMMAND_RPC_GET_BLOCKS_BY_HEIGHT
struct  COMMAND_RPC_GET_ALT_BLOCKS_HASHES
struct  COMMAND_RPC_GET_HASHES_FAST
struct  COMMAND_RPC_GET_RANDOM_OUTS
struct  COMMAND_RPC_SUBMIT_RAW_TX
struct  COMMAND_RPC_GET_TRANSACTIONS
struct  COMMAND_RPC_IS_KEY_IMAGE_SPENT
struct  public_output
struct  COMMAND_RPC_IS_PUBLIC_OUTPUT_SPENT
struct  COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES
struct  get_outputs_out
struct  COMMAND_RPC_GET_OUTPUTS_BIN
struct  COMMAND_RPC_GET_OUTPUTS
struct  COMMAND_RPC_SEND_RAW_TX
struct  COMMAND_RPC_START_MINING
struct  COMMAND_RPC_GET_INFO
struct  COMMAND_RPC_GET_NET_STATS
struct  COMMAND_RPC_STOP_MINING
struct  COMMAND_RPC_MINING_STATUS
struct  COMMAND_RPC_SAVE_BC
struct  COMMAND_RPC_GETBLOCKCOUNT
struct  COMMAND_RPC_GETBLOCKHASH
struct  COMMAND_RPC_GETBLOCKTEMPLATE
struct  COMMAND_RPC_SUBMITBLOCK
struct  COMMAND_RPC_GENERATEBLOCKS
struct  block_header_response
struct  COMMAND_RPC_GET_LAST_BLOCK_HEADER
struct  COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH
struct  COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT
struct  COMMAND_RPC_GET_BLOCK
struct  peer
struct  COMMAND_RPC_GET_PEER_LIST
struct  COMMAND_RPC_SET_LOG_HASH_RATE
struct  COMMAND_RPC_SET_LOG_LEVEL
struct  COMMAND_RPC_SET_LOG_CATEGORIES
struct  tx_info
struct  spent_key_image_info
struct  COMMAND_RPC_GET_TRANSACTION_POOL
struct  COMMAND_RPC_GET_TRANSACTION_POOL_HASHES_BIN
struct  COMMAND_RPC_GET_TRANSACTION_POOL_HASHES
struct  tx_backlog_entry
struct  COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG
struct  txpool_histo
struct  txpool_stats
struct  COMMAND_RPC_GET_TRANSACTION_POOL_STATS
struct  COMMAND_RPC_GET_BALANCE
struct  COMMAND_RPC_GET_ADDRESS_BATCH_HISTORY
struct  COMMAND_RPC_GET_ADDR_TX_BATCH_HISTORY
struct  COMMAND_RPC_GET_CONNECTIONS
struct  COMMAND_RPC_GET_BLOCK_HEADERS_RANGE
struct  COMMAND_RPC_STOP_DAEMON
struct  COMMAND_RPC_FAST_EXIT
struct  COMMAND_RPC_GET_LIMIT
struct  COMMAND_RPC_SET_LIMIT
struct  COMMAND_RPC_OUT_PEERS
struct  COMMAND_RPC_IN_PEERS
struct  COMMAND_RPC_START_SAVE_GRAPH
struct  COMMAND_RPC_STOP_SAVE_GRAPH
struct  COMMAND_RPC_HARD_FORK_INFO
struct  COMMAND_RPC_GETBANS
struct  COMMAND_RPC_SETBANS
struct  COMMAND_RPC_FLUSH_TRANSACTION_POOL
struct  COMMAND_RPC_GET_OUTPUT_HISTOGRAM
struct  COMMAND_RPC_GET_VERSION
struct  COMMAND_RPC_GET_COINBASE_TX_SUM
struct  COMMAND_RPC_GET_BASE_FEE_ESTIMATE
struct  COMMAND_RPC_GET_ALTERNATE_CHAINS
struct  COMMAND_RPC_UPDATE
struct  COMMAND_RPC_RELAY_TX
struct  COMMAND_RPC_SYNC_INFO
struct  COMMAND_RPC_GET_OUTPUT_DISTRIBUTION
struct  COMMAND_RPC_POP_BLOCKS
struct  COMMAND_RPC_GET_TAX_DATA
struct  COMMAND_RPC_PRUNE_BLOCKCHAIN
struct  COMMAND_RPC_SET_VALIDATOR_KEY
struct  COMMAND_RPC_GENERATE_ED25519_KEYPAIR
struct  COMMAND_RPC_SIGN_MESSAGE
struct  COMMAND_RPC_INJECT_EMERGENCY_VLIST
struct  rpc_args
 Processes command line arguments related to server-side RPC. More...
class  simple_wallet
 Manages wallet operations. This is the most abstracted wallet class. More...
class  vector
 STL class. More...

Typedefs

typedef std::pair< crypto::hash, uint64_ttx_out_index
typedef struct cryptonote::mdb_block_info_1 mdb_block_info_1
typedef struct cryptonote::mdb_block_info_2 mdb_block_info_2
typedef struct cryptonote::mdb_block_info_3 mdb_block_info_3
typedef struct cryptonote::mdb_block_info_4 mdb_block_info_4
typedef mdb_block_info_4 mdb_block_info
typedef struct cryptonote::blk_height blk_height
typedef struct cryptonote::pre_rct_outkey pre_rct_outkey
typedef struct cryptonote::outkey outkey
typedef struct cryptonote::outtx outtx
typedef struct cryptonote::acc_outs_t acc_outs_t
typedef struct cryptonote::acc_addr_tx_t acc_addr_tx_t
typedef struct cryptonote::txindex txindex
typedef struct cryptonote::mdb_txn_cursors mdb_txn_cursors
typedef struct cryptonote::mdb_rflags mdb_rflags
typedef struct cryptonote::mdb_threadinfo mdb_threadinfo
typedef std::string blobdata
typedef epee::span< const char > blobdata_ref
typedef std::vector< crypto::signaturering_signature
typedef boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_to_key_publictxin_v
typedef boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_key_publictxout_target_v
typedef epee::misc_utils::struct_init< core_stat_info_t > core_stat_info
typedef boost::multiprecision::uint128_t difficulty_type
typedef boost::variant< tx_extra_padding, tx_extra_pub_key, tx_extra_nonce, tx_extra_merge_mining_tag, tx_extra_additional_pub_keys, tx_extra_bridge_source_address, tx_extra_bridge_smartchain_address, tx_extra_bridge_ownership_sig, tx_extra_mysterious_minergatetx_extra_field
typedef std::function< const epee::span< const unsigned char >(cryptonote::network_type network)> GetCheckpointsCallback
 Callback routine that returns checkpoints data for specific network type.
typedef std::pair< std::pair< double, std::time_t >, crypto::hashtx_by_fee_and_receive_time_entry
 pair of <transaction fee, transaction hash> for organization
typedef std::set< tx_by_fee_and_receive_time_entry, txComparesorted_tx_container
 container for sorting transactions by fee per unit size

Enumerations

enum  { prune_mode_prune , prune_mode_update , prune_mode_check }
enum  network_type : uint8_t {
  MAINNET = 0 , TESTNET , STAGENET , FAKECHAIN ,
  UNDEFINED = 255
}
enum  blockchain_db_sync_mode { db_defaultsync , db_sync , db_async , db_nosync }
enum  SPENT_STATUS { UNSPENT = 0 , SPENT_IN_BLOCKCHAIN = 1 , SPENT_IN_POOL = 2 }

Functions

size_t slow_memmem (const void *start_buff, size_t buflen, const void *pat, size_t patlen)
bool blockchain_valid_db_type (const std::string &db_type)
std::string blockchain_db_types (const std::string &sep)
BlockchainDBnew_db (const std::string &db_type)
void lmdb_resized (MDB_env *env)
int lmdb_txn_begin (MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
int lmdb_txn_renew (MDB_txn *txn)
std::string get_protocol_state_string (cryptonote_connection_context::state s)
char get_protocol_state_char (cryptonote_connection_context::state s)
template<>
unsigned int getpos (binary_archive< true > &ar)
template<>
unsigned int getpos (binary_archive< false > &ar)
size_t get_min_block_weight (uint8_t version)
size_t get_max_tx_size ()
bool get_block_reward (size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, uint64_t current_block_height, network_type nettype)
uint8_t get_account_address_checksum (const public_address_outer_blob &bl)
uint8_t get_account_integrated_address_checksum (const public_integrated_address_outer_blob &bl)
std::string get_account_address_as_str (network_type nettype, bool subaddress, account_public_address const &adr)
std::string get_account_integrated_address_as_str (network_type nettype, account_public_address const &adr, crypto::hash8 const &payment_id)
bool is_coinbase (const transaction &tx)
bool get_account_address_from_str (address_parse_info &info, network_type nettype, std::string const &str)
bool get_account_address_from_str_or_url (address_parse_info &info, network_type nettype, const std::string &str_or_url, std::function< std::string(const std::string &, const std::vector< std::string > &, bool)> dns_confirm)
bool operator== (const cryptonote::transaction &a, const cryptonote::transaction &b)
bool operator== (const cryptonote::block &a, const cryptonote::block &b)
void get_transaction_prefix_hash (const transaction_prefix &tx, crypto::hash &h)
crypto::hash get_transaction_prefix_hash (const transaction_prefix &tx)
bool expand_transaction_1 (transaction &tx, bool base_only)
bool parse_and_validate_tx_from_blob (const blobdata &tx_blob, transaction &tx)
bool parse_and_validate_tx_base_from_blob (const blobdata &tx_blob, transaction &tx)
bool parse_and_validate_tx_prefix_from_blob (const blobdata &tx_blob, transaction_prefix &tx)
bool parse_and_validate_tx_from_blob (const blobdata &tx_blob, transaction &tx, crypto::hash &tx_hash)
bool parse_and_validate_tx_from_blob (const blobdata &tx_blob, transaction &tx, crypto::hash &tx_hash, crypto::hash &tx_prefix_hash)
bool is_v1_tx (const blobdata_ref &tx_blob)
bool is_v1_tx (const blobdata &tx_blob)
bool generate_key_image_helper (const account_keys &ack, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::public_key &tx_public_key, const std::vector< crypto::public_key > &additional_tx_public_keys, size_t real_output_index, keypair &in_ephemeral, crypto::key_image &ki, hw::device &hwdev, const uint32_t account_major_offset)
bool generate_key_image_helper_precomp (const account_keys &ack, const crypto::public_key &out_key, const crypto::key_derivation &recv_derivation, size_t real_output_index, const subaddress_index &received_index, keypair &in_ephemeral, crypto::key_image &ki, hw::device &hwdev, const uint32_t account_major_offset)
uint64_t power_integral (uint64_t a, uint64_t b)
bool parse_amount (uint64_t &amount, const std::string &str_amount_)
uint64_t get_transaction_weight (const transaction &tx, size_t blob_size)
uint64_t get_transaction_weight (const transaction &tx)
bool get_tx_fee (const transaction &tx, uint64_t &fee)
uint64_t get_tx_fee (const transaction &tx)
bool parse_tx_extra (const std::vector< uint8_t > &tx_extra, std::vector< tx_extra_field > &tx_extra_fields)
bool sort_tx_extra (const std::vector< uint8_t > &tx_extra, std::vector< uint8_t > &sorted_tx_extra, bool allow_partial)
crypto::public_key get_tx_pub_key_from_extra (const std::vector< uint8_t > &tx_extra, size_t pk_index)
crypto::public_key get_tx_pub_key_from_extra (const transaction_prefix &tx_prefix, size_t pk_index)
crypto::public_key get_tx_pub_key_from_extra (const transaction &tx, size_t pk_index)
bool add_tx_pub_key_to_extra (transaction &tx, const crypto::public_key &tx_pub_key)
bool add_tx_pub_key_to_extra (transaction_prefix &tx, const crypto::public_key &tx_pub_key)
bool add_tx_pub_key_to_extra (std::vector< uint8_t > &tx_extra, const crypto::public_key &tx_pub_key)
std::vector< crypto::public_keyget_additional_tx_pub_keys_from_extra (const std::vector< uint8_t > &tx_extra)
std::vector< crypto::public_keyget_additional_tx_pub_keys_from_extra (const transaction_prefix &tx)
bool add_additional_tx_pub_keys_to_extra (std::vector< uint8_t > &tx_extra, const std::vector< crypto::public_key > &additional_pub_keys)
bool add_extra_nonce_to_tx_extra (std::vector< uint8_t > &tx_extra, const blobdata &extra_nonce)
bool add_bridge_source_address_to_tx_extra (std::vector< uint8_t > &tx_extra, const blobdata &bridge_source_address)
bool add_bridge_smartchain_address_to_tx_extra (std::vector< uint8_t > &tx_extra, const blobdata &bridge_smartchain_address)
bool add_bridge_ownership_sig_to_tx_extra (std::vector< uint8_t > &tx_extra, const crypto::signature &sig)
bool remove_field_from_tx_extra (std::vector< uint8_t > &tx_extra, const std::type_info &type)
void set_payment_id_to_tx_extra_nonce (blobdata &extra_nonce, const crypto::hash &payment_id)
void set_encrypted_payment_id_to_tx_extra_nonce (blobdata &extra_nonce, const crypto::hash8 &payment_id)
bool get_payment_id_from_tx_extra_nonce (const blobdata &extra_nonce, crypto::hash &payment_id)
bool get_encrypted_payment_id_from_tx_extra_nonce (const blobdata &extra_nonce, crypto::hash8 &payment_id)
bool get_inputs_etn_amount (const transaction &tx, uint64_t &etn)
uint64_t get_block_height (const block &b)
bool check_inputs_types_supported (const transaction &tx)
bool check_outs_valid (const transaction &tx)
bool check_etn_overflow (const transaction &tx)
bool check_inputs_overflow (const transaction &tx)
bool check_outs_overflow (const transaction &tx)
uint64_t get_outs_etn_amount (const transaction &tx)
std::string short_hash_str (const crypto::hash &h)
bool is_out_to_acc (const account_keys &acc, const txout_to_key &out_key, const crypto::public_key &tx_pub_key, const std::vector< crypto::public_key > &additional_tx_pub_keys, size_t output_index)
boost::optional< subaddress_receive_infois_out_to_acc_precomp (const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t output_index, hw::device &hwdev)
boost::optional< subaddress_receive_infois_out_to_acc_precomp_public (const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const cryptonote::account_public_address output_address)
bool lookup_acc_outs (const account_keys &acc, const transaction &tx, std::vector< size_t > &outs, uint64_t &etn_transfered)
bool lookup_acc_outs (const account_keys &acc, const transaction &tx, const crypto::public_key &tx_pub_key, const std::vector< crypto::public_key > &additional_tx_pub_keys, std::vector< size_t > &outs, uint64_t &etn_transfered)
void get_blob_hash (const epee::span< const char > &blob, crypto::hash &res)
void get_blob_hash (const blobdata &blob, crypto::hash &res)
void set_default_decimal_point (unsigned int decimal_point)
unsigned int get_default_decimal_point ()
std::string get_unit (unsigned int decimal_point)
std::string print_etn (uint64_t amount, unsigned int decimal_point)
crypto::hash get_blob_hash (const blobdata &blob)
crypto::hash get_blob_hash (const epee::span< const char > &blob)
crypto::hash get_transaction_hash (const transaction &t)
bool get_transaction_hash (const transaction &t, crypto::hash &res)
bool calculate_transaction_prunable_hash (const transaction &t, const cryptonote::blobdata *blob, crypto::hash &res)
crypto::hash get_transaction_prunable_hash (const transaction &t, const cryptonote::blobdata *blobdata)
crypto::hash get_pruned_transaction_hash (const transaction &t, const crypto::hash &pruned_data_hash)
bool calculate_transaction_hash (const transaction &t, crypto::hash &res, size_t *blob_size)
bool get_transaction_hash (const transaction &t, crypto::hash &res, size_t *blob_size)
bool get_transaction_hash (const transaction &t, crypto::hash &res, size_t &blob_size)
blobdata get_block_hashing_blob (const block &b)
bool calculate_block_hash (const block &b, crypto::hash &res, const blobdata *blob)
bool get_block_hash (const block &b, crypto::hash &res)
crypto::hash get_block_hash (const block &b)
bool get_block_longhash (const block &b, crypto::hash &res, uint64_t height)
std::vector< uint64_trelative_output_offsets_to_absolute (const std::vector< uint64_t > &off)
std::vector< uint64_tabsolute_output_offsets_to_relative (const std::vector< uint64_t > &off)
crypto::hash get_block_longhash (const block &b, uint64_t height)
bool parse_and_validate_block_from_blob (const blobdata &b_blob, block &b, crypto::hash *block_hash)
bool parse_and_validate_block_from_blob (const blobdata &b_blob, block &b)
bool parse_and_validate_block_from_blob (const blobdata &b_blob, block &b, crypto::hash &block_hash)
blobdata block_to_blob (const block &b)
bool block_to_blob (const block &b, blobdata &b_blob)
blobdata tx_to_blob (const transaction &tx)
bool tx_to_blob (const transaction &tx, blobdata &b_blob)
void get_tx_tree_hash (const std::vector< crypto::hash > &tx_hashes, crypto::hash &h)
crypto::hash get_tx_tree_hash (const std::vector< crypto::hash > &tx_hashes)
crypto::hash get_tx_tree_hash (const block &b)
bool is_valid_decomposed_amount (uint64_t amount)
void get_hash_stats (uint64_t &tx_hashes_calculated, uint64_t &tx_hashes_cached, uint64_t &block_hashes_calculated, uint64_t &block_hashes_cached)
crypto::secret_key encrypt_key (crypto::secret_key key, const epee::wipeable_string &passphrase)
crypto::secret_key decrypt_key (crypto::secret_key key, const epee::wipeable_string &passphrase)
template<typename T>
bool find_tx_extra_field_by_type (const std::vector< tx_extra_field > &tx_extra_fields, T &field, size_t index=0)
bool sort_tx_extra (const std::vector< uint8_t > &tx_extra, std::vector< uint8_t > &sorted_tx_extra, bool allow_partial=false)
template<class t_object>
bool t_serializable_object_from_blob (t_object &to, const blobdata &b_blob)
template<class t_object>
bool t_serializable_object_to_blob (const t_object &to, blobdata &b_blob)
template<class t_object>
blobdata t_serializable_object_to_blob (const t_object &to)
template<class t_object>
bool get_object_hash (const t_object &o, crypto::hash &res)
template<class t_object>
size_t get_object_blobsize (const t_object &o)
template<class t_object>
bool get_object_hash (const t_object &o, crypto::hash &res, size_t &blob_size)
template<typename T>
std::string obj_to_json_str (T &obj)
template<typename chunk_handler_t, typename dust_handler_t>
void decompose_amount_into_digits (uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
bool check_hash_64 (const crypto::hash &hash, uint64_t difficulty)
 checks if a hash fits the given difficulty
uint64_t next_difficulty_64 (std::vector< std::uint64_t > timestamps, std::vector< uint64_t > cumulative_difficulties, size_t target_seconds, uint8_t version)
const difficulty_type max64bit (std::numeric_limits< std::uint64_t >::max())
const boost::multiprecision::uint256_t max128bit (std::numeric_limits< boost::multiprecision::uint128_t >::max())
const boost::multiprecision::uint512_t max256bit (std::numeric_limits< boost::multiprecision::uint256_t >::max())
bool check_hash_128 (const crypto::hash &hash, difficulty_type difficulty)
bool check_hash (const crypto::hash &hash, difficulty_type difficulty)
difficulty_type next_difficulty (std::vector< uint64_t > timestamps, std::vector< difficulty_type > cumulative_difficulties, size_t target_seconds, uint8_t version)
std::string hex (difficulty_type v)
std::ostream & operator<< (std::ostream &out, const cryptonote::subaddress_index &subaddr_index)
const config_t & get_config (network_type nettype)
block_complete_entry get_block_complete_entry (block &b, tx_memory_pool &pool)
double factorial (unsigned int n)
void classify_addresses (const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, size_t &num_stdaddresses, size_t &num_subaddresses, account_public_address &single_dest_subaddress)
bool construct_miner_tx (size_t height, size_t median_weight, uint64_t already_generated_coins, size_t current_block_weight, uint64_t fee, const account_public_address &miner_address, transaction &tx, const blobdata &extra_nonce, size_t max_outs, uint8_t hard_fork_version, network_type nettype)
crypto::public_key get_destination_view_key_pub (const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr)
bool construct_tx_with_tx_key (const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, bool shuffle_outs, const uint32_t account_major_offset, const cryptonote::network_type nettype)
bool construct_tx_and_get_tx_key (const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
bool construct_tx (const account_keys &sender_account_keys, std::vector< tx_source_entry > &sources, const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time)
bool generate_genesis_block (block &bl, std::string const &genesis_tx, uint32_t nonce)
bool construct_tx_with_tx_key (const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, bool rct=false, const rct::RCTConfig &rct_config={ rct::RangeProofBorromean, 0 }, rct::multisig_out *msout=NULL, bool shuffle_outs=true, const uint32_t account_major_offset=0, const cryptonote::network_type=MAINNET)
bool construct_tx_and_get_tx_key (const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct=false, const rct::RCTConfig &rct_config={ rct::RangeProofBorromean, 0 }, rct::multisig_out *msout=NULL, uint32_t account_major_offset=0, const cryptonote::network_type=MAINNET)
bool generate_output_ephemeral_keys (const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional< cryptonote::account_public_address > &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector< crypto::secret_key > &additional_tx_keys, std::vector< crypto::public_key > &additional_tx_public_keys, std::vector< rct::key > &amount_keys, crypto::public_key &out_eph_public_key)
bool tx_sanity_check (Blockchain &blockchain, const cryptonote::blobdata &tx_blob)
crypto::secret_key get_multisig_blinded_secret_key (const crypto::secret_key &key)
void generate_multisig_N_N (const account_keys &keys, const std::vector< crypto::public_key > &spend_keys, std::vector< crypto::secret_key > &multisig_keys, rct::key &spend_skey, rct::key &spend_pkey)
void generate_multisig_N1_N (const account_keys &keys, const std::vector< crypto::public_key > &spend_keys, std::vector< crypto::secret_key > &multisig_keys, rct::key &spend_skey, rct::key &spend_pkey)
std::vector< crypto::public_keygenerate_multisig_derivations (const account_keys &keys, const std::vector< crypto::public_key > &derivations)
 generate_multisig_derivations performs common DH key derivation. Each middle round in M/N scheme is DH exchange of public multisig keys of other participants multiplied by secret spend key of current participant. this functions does the following: new multisig key = secret spend * public multisig key
crypto::secret_key calculate_multisig_signer_key (const std::vector< crypto::secret_key > &multisig_keys)
std::vector< crypto::secret_keycalculate_multisig_keys (const std::vector< crypto::public_key > &derivations)
 calculate_multisig_keys. Calculates secret multisig keys from others' participants ones as follows: mi = H(Mi)
crypto::secret_key generate_multisig_view_secret_key (const crypto::secret_key &skey, const std::vector< crypto::secret_key > &skeys)
crypto::public_key generate_multisig_M_N_spend_public_key (const std::vector< crypto::public_key > &pkeys)
 generate_multisig_M_N_spend_public_key calculates multisig wallet's spend public key by summing all of public multisig keys
bool generate_multisig_key_image (const account_keys &keys, size_t multisig_key_index, const crypto::public_key &out_key, crypto::key_image &ki)
void generate_multisig_LR (const crypto::public_key pkey, const crypto::secret_key &k, crypto::public_key &L, crypto::public_key &R)
bool generate_multisig_composite_key_image (const account_keys &keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::public_key &tx_public_key, const std::vector< crypto::public_key > &additional_tx_public_keys, size_t real_output_index, const std::vector< crypto::key_image > &pkis, crypto::key_image &ki)
uint32_t multisig_rounds_required (uint32_t participants, uint32_t threshold)

Variables

std::string arg_db_type_description = "Specify database type, available: " + cryptonote::blockchain_db_types(", ")
const command_line::arg_descriptor< std::string > arg_db_type
const command_line::arg_descriptor< std::string > arg_db_sync_mode
const command_line::arg_descriptor< bool > arg_db_salvage
const command_line::arg_descriptor< bool > arg_addr_db_salvage
const command_line::arg_descriptor< bool, falsearg_testnet_on
const command_line::arg_descriptor< bool, falsearg_stagenet_on
const command_line::arg_descriptor< bool > arg_regtest_on
const command_line::arg_descriptor< difficulty_typearg_fixed_difficulty
const command_line::arg_descriptor< bool > arg_skip_block_sig_verification
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
const command_line::arg_descriptor< bool > arg_offline
const command_line::arg_descriptor< bool > arg_disable_dns_checkpoints
const command_line::arg_descriptor< size_t > arg_block_download_max_size
const command_line::arg_descriptor< bool > arg_fallback_to_pow
const command_line::arg_descriptor< uint64_targ_fallback_to_pow_checkpoint_height
const command_line::arg_descriptor< std::string > arg_fallback_to_pow_checkpoint_hash

Detailed Description

Holds cryptonote related classes and helpers.

Typedef Documentation

◆ acc_addr_tx_t

typedef struct cryptonote::acc_addr_tx_t cryptonote::acc_addr_tx_t

◆ acc_outs_t

typedef struct cryptonote::acc_outs_t cryptonote::acc_outs_t

◆ blk_height

typedef struct cryptonote::blk_height cryptonote::blk_height

◆ blobdata

typedef std::string cryptonote::blobdata

Definition at line 39 of file blobdatatype.h.

◆ blobdata_ref

typedef epee::span<const char> cryptonote::blobdata_ref

Definition at line 40 of file blobdatatype.h.

◆ core_stat_info

Definition at line 54 of file cryptonote_stat_info.h.

◆ difficulty_type

typedef boost::multiprecision::uint128_t cryptonote::difficulty_type

Definition at line 43 of file difficulty.h.

◆ GetCheckpointsCallback

typedef std::function<const epee::span<const unsigned char>(cryptonote::network_type network)> cryptonote::GetCheckpointsCallback

Callback routine that returns checkpoints data for specific network type.

Parameters
networknetwork type
Returns
checkpoints data, empty span if there ain't any checkpoints for specific network type

Definition at line 92 of file blockchain.h.

◆ mdb_block_info

Definition at line 355 of file db_lmdb.cpp.

◆ mdb_block_info_1

typedef struct cryptonote::mdb_block_info_1 cryptonote::mdb_block_info_1

◆ mdb_block_info_2

typedef struct cryptonote::mdb_block_info_2 cryptonote::mdb_block_info_2

◆ mdb_block_info_3

typedef struct cryptonote::mdb_block_info_3 cryptonote::mdb_block_info_3

◆ mdb_block_info_4

typedef struct cryptonote::mdb_block_info_4 cryptonote::mdb_block_info_4

◆ mdb_rflags

typedef struct cryptonote::mdb_rflags cryptonote::mdb_rflags

◆ mdb_threadinfo

typedef struct cryptonote::mdb_threadinfo cryptonote::mdb_threadinfo

◆ mdb_txn_cursors

typedef struct cryptonote::mdb_txn_cursors cryptonote::mdb_txn_cursors

◆ outkey

typedef struct cryptonote::outkey cryptonote::outkey

◆ outtx

typedef struct cryptonote::outtx cryptonote::outtx

◆ pre_rct_outkey

typedef struct cryptonote::pre_rct_outkey cryptonote::pre_rct_outkey

◆ ring_signature

Definition at line 57 of file cryptonote_basic.h.

◆ sorted_tx_container

container for sorting transactions by fee per unit size

Definition at line 78 of file tx_pool.h.

◆ tx_by_fee_and_receive_time_entry

typedef std::pair<std::pair<double, std::time_t>, crypto::hash> cryptonote::tx_by_fee_and_receive_time_entry

pair of <transaction fee, transaction hash> for organization

Definition at line 60 of file tx_pool.h.

◆ tx_extra_field

◆ tx_out_index

a pair of <transaction hash, output index>, typedef for convenience

Definition at line 107 of file blockchain_db.h.

◆ txin_v

◆ txindex

typedef struct cryptonote::txindex cryptonote::txindex

◆ txout_target_v

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
prune_mode_prune 
prune_mode_update 
prune_mode_check 

Definition at line 2641 of file db_lmdb.cpp.

◆ blockchain_db_sync_mode

Declares ways in which the BlockchainDB backend should be told to sync

Enumerator
db_defaultsync 

user didn't specify, use db_async

db_sync 

handle syncing calls instead of the backing db, synchronously

db_async 

handle syncing calls instead of the backing db, asynchronously

db_nosync 

Leave syncing up to the backing db (safest, but slowest because of disk I/O).

Definition at line 77 of file blockchain.h.

78 {
80 db_sync,
81 db_async,
83 };
@ db_async
handle syncing calls instead of the backing db, asynchronously
Definition blockchain.h:81
@ db_nosync
Leave syncing up to the backing db (safest, but slowest because of disk I/O).
Definition blockchain.h:82
@ db_sync
handle syncing calls instead of the backing db, synchronously
Definition blockchain.h:80
@ db_defaultsync
user didn't specify, use db_async
Definition blockchain.h:79

◆ network_type

Enumerator
MAINNET 
TESTNET 
STAGENET 
FAKECHAIN 
UNDEFINED 

Definition at line 246 of file cryptonote_config.h.

◆ SPENT_STATUS

Enumerator
UNSPENT 
SPENT_IN_BLOCKCHAIN 
SPENT_IN_POOL 

Definition at line 403 of file core_rpc_server_commands_defs.h.

Function Documentation

◆ absolute_output_offsets_to_relative()

std::vector< uint64_t > cryptonote::absolute_output_offsets_to_relative ( const std::vector< uint64_t > & off)

Definition at line 1238 of file cryptonote_format_utils.cpp.

1239 {
1240 std::vector<uint64_t> res = off;
1241 if(!off.size())
1242 return res;
1243 std::sort(res.begin(), res.end());//just to be sure, actually it is already should be sorted
1244 for(size_t i = res.size()-1; i != 0; i--)
1245 res[i] -= res[i-1];
1246
1247 return res;
1248 }
const char * res
Here is the caller graph for this function:

◆ add_additional_tx_pub_keys_to_extra()

bool cryptonote::add_additional_tx_pub_keys_to_extra ( std::vector< uint8_t > & tx_extra,
const std::vector< crypto::public_key > & additional_pub_keys )

Definition at line 575 of file cryptonote_format_utils.cpp.

576 {
577 // convert to variant
578 tx_extra_field field = tx_extra_additional_pub_keys{ additional_pub_keys };
579 // serialize
580 std::ostringstream oss;
581 binary_archive<true> ar(oss);
582 bool r = ::do_serialize(ar, field);
583 CHECK_AND_NO_ASSERT_MES_L1(r, false, "failed to serialize tx extra additional tx pub keys");
584 // append
585 std::string tx_extra_str = oss.str();
586 size_t pos = tx_extra.size();
587 tx_extra.resize(tx_extra.size() + tx_extra_str.size());
588 memcpy(&tx_extra[pos], tx_extra_str.data(), tx_extra_str.size());
589 return true;
590 }
void * memcpy(void *a, const void *b, size_t c)
#define CHECK_AND_NO_ASSERT_MES_L1(expr, fail_ret_val, message)
bool do_serialize(Archive &ar, T &v)
just calls the serialize function defined for ar and v...
Definition hash.h:124
boost::variant< tx_extra_padding, tx_extra_pub_key, tx_extra_nonce, tx_extra_merge_mining_tag, tx_extra_additional_pub_keys, tx_extra_bridge_source_address, tx_extra_bridge_smartchain_address, tx_extra_bridge_ownership_sig, tx_extra_mysterious_minergate > tx_extra_field
Definition tx_extra.h:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_bridge_ownership_sig_to_tx_extra()

bool cryptonote::add_bridge_ownership_sig_to_tx_extra ( std::vector< uint8_t > & tx_extra,
const crypto::signature & sig )

Definition at line 640 of file cryptonote_format_utils.cpp.

641 {
642 size_t start_pos = tx_extra.size();
643 tx_extra.resize(tx_extra.size() + 2 + sizeof(crypto::signature));
644 //write tag
645 tx_extra[start_pos] = TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG;
646 //write len
647 ++start_pos;
648 tx_extra[start_pos] = static_cast<uint8_t>(sizeof(crypto::signature));
649 //write data
650 ++start_pos;
651 memcpy(&tx_extra[start_pos], &sig, sizeof(crypto::signature));
652 return true;
653 }
POD_CLASS signature
Definition crypto.h:108
unsigned char uint8_t
Definition stdint.h:124
#define TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG
Definition tx_extra.h:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_bridge_smartchain_address_to_tx_extra()

bool cryptonote::add_bridge_smartchain_address_to_tx_extra ( std::vector< uint8_t > & tx_extra,
const blobdata & bridge_smartchain_address )

Definition at line 624 of file cryptonote_format_utils.cpp.

625 {
626 //CHECK_AND_ASSERT_MES(bridge_smartchain_address.size() <= TX_EXTRA_NONCE_MAX_COUNT, false, "extra nonce could be 255 bytes max");
627 size_t start_pos = tx_extra.size();
628 tx_extra.resize(tx_extra.size() + 2 + bridge_smartchain_address.size());
629 //write tag
630 tx_extra[start_pos] = TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS;
631 //write len
632 ++start_pos;
633 tx_extra[start_pos] = static_cast<uint8_t>(bridge_smartchain_address.size());
634 //write data
635 ++start_pos;
636 memcpy(&tx_extra[start_pos], bridge_smartchain_address.data(), bridge_smartchain_address.size());
637 return true;
638 }
#define TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS
Definition tx_extra.h:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_bridge_source_address_to_tx_extra()

bool cryptonote::add_bridge_source_address_to_tx_extra ( std::vector< uint8_t > & tx_extra,
const blobdata & bridge_source_address )

Definition at line 608 of file cryptonote_format_utils.cpp.

609 {
610 //CHECK_AND_ASSERT_MES(bridge_source_address.size() <= TX_EXTRA_NONCE_MAX_COUNT, false, "extra nonce could be 255 bytes max");
611 size_t start_pos = tx_extra.size();
612 tx_extra.resize(tx_extra.size() + 2 + bridge_source_address.size());
613 //write tag
614 tx_extra[start_pos] = TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS;
615 //write len
616 ++start_pos;
617 tx_extra[start_pos] = static_cast<uint8_t>(bridge_source_address.size());
618 //write data
619 ++start_pos;
620 memcpy(&tx_extra[start_pos], bridge_source_address.data(), bridge_source_address.size());
621 return true;
622 }
#define TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS
Definition tx_extra.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_extra_nonce_to_tx_extra()

bool cryptonote::add_extra_nonce_to_tx_extra ( std::vector< uint8_t > & tx_extra,
const blobdata & extra_nonce )

Definition at line 592 of file cryptonote_format_utils.cpp.

593 {
594 CHECK_AND_ASSERT_MES(extra_nonce.size() <= TX_EXTRA_NONCE_MAX_COUNT, false, "extra nonce could be 255 bytes max");
595 size_t start_pos = tx_extra.size();
596 tx_extra.resize(tx_extra.size() + 2 + extra_nonce.size());
597 //write tag
598 tx_extra[start_pos] = TX_EXTRA_NONCE;
599 //write len
600 ++start_pos;
601 tx_extra[start_pos] = static_cast<uint8_t>(extra_nonce.size());
602 //write data
603 ++start_pos;
604 memcpy(&tx_extra[start_pos], extra_nonce.data(), extra_nonce.size());
605 return true;
606 }
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
#define TX_EXTRA_NONCE_MAX_COUNT
Definition tx_extra.h:36
#define TX_EXTRA_NONCE
Definition tx_extra.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_tx_pub_key_to_extra() [1/3]

bool cryptonote::add_tx_pub_key_to_extra ( std::vector< uint8_t > & tx_extra,
const crypto::public_key & tx_pub_key )

Definition at line 550 of file cryptonote_format_utils.cpp.

551 {
552 tx_extra.resize(tx_extra.size() + 1 + sizeof(crypto::public_key));
553 tx_extra[tx_extra.size() - 1 - sizeof(crypto::public_key)] = TX_EXTRA_TAG_PUBKEY;
554 *reinterpret_cast<crypto::public_key*>(&tx_extra[tx_extra.size() - sizeof(crypto::public_key)]) = tx_pub_key;
555 return true;
556 }
POD_CLASS public_key
Definition crypto.h:79
#define TX_EXTRA_TAG_PUBKEY
Definition tx_extra.h:39

◆ add_tx_pub_key_to_extra() [2/3]

bool cryptonote::add_tx_pub_key_to_extra ( transaction & tx,
const crypto::public_key & tx_pub_key )

Definition at line 540 of file cryptonote_format_utils.cpp.

541 {
542 return add_tx_pub_key_to_extra(tx.extra, tx_pub_key);
543 }
bool add_tx_pub_key_to_extra(transaction &tx, const crypto::public_key &tx_pub_key)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_tx_pub_key_to_extra() [3/3]

bool cryptonote::add_tx_pub_key_to_extra ( transaction_prefix & tx,
const crypto::public_key & tx_pub_key )

Definition at line 545 of file cryptonote_format_utils.cpp.

546 {
547 return add_tx_pub_key_to_extra(tx.extra, tx_pub_key);
548 }
Here is the call graph for this function:

◆ block_to_blob() [1/2]

blobdata cryptonote::block_to_blob ( const block & b)

Definition at line 1286 of file cryptonote_format_utils.cpp.

1287 {
1289 }
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ block_to_blob() [2/2]

bool cryptonote::block_to_blob ( const block & b,
blobdata & b_blob )

Definition at line 1291 of file cryptonote_format_utils.cpp.

1292 {
1293 return t_serializable_object_to_blob(b, b_blob);
1294 }
Here is the call graph for this function:

◆ blockchain_db_types()

std::string cryptonote::blockchain_db_types ( const std::string & sep)

Definition at line 71 of file blockchain_db.cpp.

72{
73 int i;
74 std::string ret = "";
75 for (i=0; db_types[i]; i++)
76 {
77 if (i)
78 ret += sep;
79 ret += db_types[i];
80 }
81 return ret;
82}
Here is the caller graph for this function:

◆ blockchain_valid_db_type()

bool cryptonote::blockchain_valid_db_type ( const std::string & db_type)

Definition at line 60 of file blockchain_db.cpp.

61{
62 int i;
63 for (i=0; db_types[i]; i++)
64 {
65 if (db_types[i] == db_type)
66 return true;
67 }
68 return false;
69}
Here is the caller graph for this function:

◆ calculate_block_hash()

bool cryptonote::calculate_block_hash ( const block & b,
crypto::hash & res,
const blobdata * blob )

Definition at line 1190 of file cryptonote_format_utils.cpp.

1191 {
1193 }
bool get_object_hash(const t_object &o, crypto::hash &res)
blobdata get_block_hashing_blob(const block &b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_multisig_keys()

std::vector< crypto::secret_key > cryptonote::calculate_multisig_keys ( const std::vector< crypto::public_key > & derivations)

calculate_multisig_keys. Calculates secret multisig keys from others' participants ones as follows: mi = H(Mi)

Parameters
derivations- others' participants public multisig keys.
Returns
vector of current wallet's multisig secret keys

Definition at line 111 of file multisig.cpp.

112 {
113 std::vector<crypto::secret_key> multisig_keys;
114 multisig_keys.reserve(derivations.size());
115
116 for (const auto &k: derivations)
117 {
118 multisig_keys.emplace_back(get_multisig_blinded_secret_key(rct::rct2sk(rct::pk2rct(k))));
119 }
120
121 return multisig_keys;
122 }
crypto::secret_key get_multisig_blinded_secret_key(const crypto::secret_key &key)
Definition multisig.cpp:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_multisig_signer_key()

crypto::secret_key cryptonote::calculate_multisig_signer_key ( const std::vector< crypto::secret_key > & multisig_keys)

Definition at line 100 of file multisig.cpp.

101 {
102 rct::key secret_key = rct::zero();
103 for (const auto &k: multisig_keys)
104 {
105 sc_add(secret_key.bytes, secret_key.bytes, (const unsigned char*)k.data);
106 }
107
108 return rct::rct2sk(secret_key);
109 }
void sc_add(unsigned char *, const unsigned char *, const unsigned char *)
key zero()
Definition rctOps.h:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_transaction_hash()

bool cryptonote::calculate_transaction_hash ( const transaction & t,
crypto::hash & res,
size_t * blob_size )

Definition at line 1092 of file cryptonote_format_utils.cpp.

1093 {
1094 // v1 transactions hash the entire blob
1095 if (t.version == 1)
1096 {
1097 size_t ignored_blob_size, &blob_size_ref = blob_size ? *blob_size : ignored_blob_size;
1098 return get_object_hash(t, res, blob_size_ref);
1099 }
1100
1101 // v2 transactions hash different parts together, than hash the set of those hashes
1103
1104 // prefix
1106
1107 const blobdata blob = tx_to_blob(t);
1108 const unsigned int unprunable_size = t.unprunable_size;
1109 const unsigned int prefix_size = t.prefix_size;
1110
1111 // base rct
1112 CHECK_AND_ASSERT_MES(prefix_size <= unprunable_size && unprunable_size <= blob.size(), false, "Inconsistent transaction prefix, unprunable and blob sizes");
1113 cryptonote::get_blob_hash(epee::span<const char>(blob.data() + prefix_size, unprunable_size - prefix_size), hashes[1]);
1114
1115 // prunable rct
1117 {
1118 hashes[2] = crypto::null_hash;
1119 }
1120 else
1121 {
1122 CHECK_AND_ASSERT_MES(calculate_transaction_prunable_hash(t, &blob, hashes[2]), false, "Failed to get tx prunable hash");
1123 }
1124
1125 // the tx hash is the hash of the 3 hashes
1126 res = cn_fast_hash(hashes, sizeof(hashes));
1127
1128 // we still need the size
1129 if (blob_size)
1130 {
1131 if (!t.is_blob_size_valid())
1132 {
1133 t.blob_size = blob.size();
1134 t.set_blob_size_valid(true);
1135 }
1136 *blob_size = t.blob_size;
1137 }
1138
1139 return true;
1140 }
std::atomic< unsigned int > unprunable_size
std::atomic< unsigned int > prefix_size
void set_blob_size_valid(bool v) const
Non-owning sequence of data. Does not deep copy.
Definition span.h:57
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS hash
Definition hash.h:50
void get_blob_hash(const epee::span< const char > &blob, crypto::hash &res)
bool calculate_transaction_prunable_hash(const transaction &t, const cryptonote::blobdata *blob, crypto::hash &res)
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h)
blobdata tx_to_blob(const transaction &tx)
std::string blobdata
@ RCTTypeNull
Definition rctTypes.h:229
struct hash_func hashes[]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_transaction_prunable_hash()

bool cryptonote::calculate_transaction_prunable_hash ( const transaction & t,
const cryptonote::blobdata * blob,
crypto::hash & res )

Definition at line 1025 of file cryptonote_format_utils.cpp.

1026 {
1027 if (t.version == 1)
1028 return false;
1029 const unsigned int unprunable_size = t.unprunable_size;
1030 if (blob && unprunable_size)
1031 {
1032 CHECK_AND_ASSERT_MES(unprunable_size <= blob->size(), false, "Inconsistent transaction unprunable and blob sizes");
1033 cryptonote::get_blob_hash(epee::span<const char>(blob->data() + unprunable_size, blob->size() - unprunable_size), res);
1034 }
1035 else
1036 {
1037 transaction &tt = const_cast<transaction&>(t);
1038 std::stringstream ss;
1039 binary_archive<true> ba(ss);
1040 const size_t inputs = t.vin.size();
1041 const size_t outputs = t.vout.size();
1042 const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(t.vin[0]).key_offsets.size() - 1 : 0;
1043 bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin);
1044 CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable");
1045 cryptonote::get_blob_hash(ss.str(), res);
1046 }
1047 return true;
1048 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_etn_overflow()

bool cryptonote::check_etn_overflow ( const transaction & tx)

Definition at line 803 of file cryptonote_format_utils.cpp.

804 {
806 }
bool check_inputs_overflow(const transaction &tx)
bool check_outs_overflow(const transaction &tx)
Here is the call graph for this function:

◆ check_hash()

bool cryptonote::check_hash ( const crypto::hash & hash,
difficulty_type difficulty )

Definition at line 203 of file difficulty.cpp.

203 {
204 if (difficulty <= max64bit) // if can convert to small difficulty - do it
205 return check_hash_64(hash, difficulty.convert_to<std::uint64_t>());
206 else
207 return check_hash_128(hash, difficulty);
208 }
bool check_hash_64(const crypto::hash &hash, uint64_t difficulty)
checks if a hash fits the given difficulty
const difficulty_type max64bit(std::numeric_limits< std::uint64_t >::max())
bool check_hash_128(const crypto::hash &hash, difficulty_type difficulty)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_hash_128()

bool cryptonote::check_hash_128 ( const crypto::hash & hash,
difficulty_type difficulty )

Definition at line 184 of file difficulty.cpp.

184 {
185#ifndef FORCE_FULL_128_BITS
186 // fast check
187 if (difficulty >= max64bit && ((const uint64_t *) &hash)[3] > 0)
188 return false;
189#endif
190 // usual slow check
191 boost::multiprecision::uint512_t hashVal = 0;
192#ifdef FORCE_FULL_128_BITS
193 for(int i = 0; i < 4; i++) { // highest word is zero
194#else
195 for(int i = 1; i < 4; i++) { // highest word is zero
196#endif
197 hashVal <<= 64;
198 hashVal |= swap64le(((const uint64_t *) &hash)[3 - i]);
199 }
200 return hashVal * difficulty <= max256bit;
201 }
#define swap64le
Definition int-util.h:234
const boost::multiprecision::uint512_t max256bit(std::numeric_limits< boost::multiprecision::uint256_t >::max())
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_hash_64()

bool cryptonote::check_hash_64 ( const crypto::hash & hash,
uint64_t difficulty )

checks if a hash fits the given difficulty

The hash passes if (hash * difficulty) < 2^256. Phrased differently, if (hash * difficulty) fits without overflow into the least significant 256 bits of the 320 bit multiplication result.

Parameters
hashthe hash to check
difficultythe difficulty to check against
Returns
true if valid, else false

Definition at line 106 of file difficulty.cpp.

106 {
107 uint64_t low, high, top, cur;
108 // First check the highest word, this will most likely fail for a random hash.
109 mul(swap64le(((const uint64_t *) &hash)[3]), difficulty, top, high);
110 if (high != 0) {
111 return false;
112 }
113 mul(swap64le(((const uint64_t *) &hash)[0]), difficulty, low, cur);
114 mul(swap64le(((const uint64_t *) &hash)[1]), difficulty, low, high);
115 bool carry = cadd(cur, low);
116 cur = high;
117 mul(swap64le(((const uint64_t *) &hash)[2]), difficulty, low, high);
118 carry = cadc(cur, low, carry);
119 carry = cadc(high, top, carry);
120 return !carry;
121 }
Here is the caller graph for this function:

◆ check_inputs_overflow()

bool cryptonote::check_inputs_overflow ( const transaction & tx)

Definition at line 808 of file cryptonote_format_utils.cpp.

809 {
810 uint64_t etn = 0;
811 if(tx.version >= 3)
812 {
813 for(const auto& in: tx.vin)
814 {
815 CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key_public, tokey_in, false);
816 if(etn > tokey_in.amount + etn)
817 return false;
818 etn += tokey_in.amount;
819 }
820 return true;
821 }
822
823 for(const auto& in: tx.vin)
824 {
825 CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
826 if(etn > tokey_in.amount + etn)
827 return false;
828 etn += tokey_in.amount;
829 }
830 return true;
831 }
#define CHECKED_GET_SPECIFIC_VARIANT(variant_var, specific_type, variable_name, fail_return_val)
Here is the caller graph for this function:

◆ check_inputs_types_supported()

bool cryptonote::check_inputs_types_supported ( const transaction & tx)

Definition at line 751 of file cryptonote_format_utils.cpp.

752 {
753 for(const auto& in: tx.vin)
754 {
755 if (tx.version == 1 || tx.version == 2)
756 {
757 CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), false, "wrong variant type: "
758 << in.type().name() << ", expected " << typeid(txin_to_key).name()
759 << ", in transaction id=" << get_transaction_hash(tx));
760 }
761 else //tx.version >= 3 (public transactions: can spend only new inputs)
762 {
763 CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key_public), false, "wrong variant type: "
764 << in.type().name() << ", expected " << typeid(txin_to_key_public).name()
765 << ", in transaction id=" << get_transaction_hash(tx));
766 }
767 }
768 return true;
769 }
crypto::hash get_transaction_hash(const transaction &t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_outs_overflow()

bool cryptonote::check_outs_overflow ( const transaction & tx)

Definition at line 833 of file cryptonote_format_utils.cpp.

834 {
835 uint64_t etn = 0;
836 for(const auto& o: tx.vout)
837 {
838 if(etn > o.amount + etn)
839 return false;
840 etn += o.amount;
841 }
842 return true;
843 }
Here is the caller graph for this function:

◆ check_outs_valid()

bool cryptonote::check_outs_valid ( const transaction & tx)

Definition at line 771 of file cryptonote_format_utils.cpp.

772 {
773 for(const tx_out& out: tx.vout)
774 {
775 if (tx.version == 1)
776 {
777 CHECK_AND_ASSERT_MES(out.target.type() == typeid(txout_to_key), false, "wrong variant type: "
778 << out.target.type().name() << ", expected " << typeid(txout_to_key).name()
779 << ", in transaction id=" << get_transaction_hash(tx));
780
781 CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
782
783 if(!check_key(boost::get<txout_to_key>(out.target).key))
784 return false;
785 }
786 else //tx.version >= 2 (public transactions: only new public outputs are allowed)
787 {
788 CHECK_AND_ASSERT_MES(out.target.type() == typeid(txout_to_key_public), false, "wrong variant type: "
789 << out.target.type().name() << ", expected " << typeid(txout_to_key_public).name()
790 << ", in transaction id=" << get_transaction_hash(tx));
791
792 CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
793
794 if(!check_key(boost::get<txout_to_key_public>(out.target).address.m_spend_public_key) ||
795 !check_key(boost::get<txout_to_key_public>(out.target).address.m_view_public_key))
796 return false;
797 }
798
799 }
800 return true;
801 }
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
bool check_key(const public_key &key)
Definition crypto.h:256
Here is the call graph for this function:
Here is the caller graph for this function:

◆ classify_addresses()

void cryptonote::classify_addresses ( const std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
size_t & num_stdaddresses,
size_t & num_subaddresses,
account_public_address & single_dest_subaddress )

Definition at line 55 of file cryptonote_tx_utils.cpp.

56 {
57 num_stdaddresses = 0;
58 num_subaddresses = 0;
59 std::unordered_set<cryptonote::account_public_address> unique_dst_addresses;
60 for(const tx_destination_entry& dst_entr: destinations)
61 {
62 if (change_addr && dst_entr.addr == change_addr)
63 continue;
64 if (unique_dst_addresses.count(dst_entr.addr) == 0)
65 {
66 unique_dst_addresses.insert(dst_entr.addr);
67 if (dst_entr.is_subaddress)
68 {
69 ++num_subaddresses;
70 single_dest_subaddress = dst_entr.addr;
71 }
72 else
73 {
74 ++num_stdaddresses;
75 }
76 }
77 }
78 LOG_PRINT_L2("destinations include " << num_stdaddresses << " standard addresses and " << num_subaddresses << " subaddresses");
79 }
#define LOG_PRINT_L2(x)
Here is the caller graph for this function:

◆ construct_miner_tx()

bool cryptonote::construct_miner_tx ( size_t height,
size_t median_weight,
uint64_t already_generated_coins,
size_t current_block_weight,
uint64_t fee,
const account_public_address & miner_address,
transaction & tx,
const blobdata & extra_nonce,
size_t max_outs,
uint8_t hard_fork_version,
network_type nettype )

Definition at line 81 of file cryptonote_tx_utils.cpp.

81 {
82 tx.vin.clear();
83 tx.vout.clear();
84 tx.extra.clear();
85
86 txin_gen in;
87 in.height = height;
88
89 uint64_t block_reward;
90 if(!get_block_reward(median_weight, current_block_weight, already_generated_coins, block_reward, hard_fork_version, height, nettype))
91 {
92 LOG_PRINT_L0("Block is too big");
93 return false;
94 }
95
96#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
97 LOG_PRINT_L1("Creating block template: reward " << block_reward <<
98 ", fee " << fee);
99#endif
100 block_reward += fee;
101
102 // from hard fork 2, we cut out the low significant digits. This makes the tx smaller, and
103 // keeps the paid amount almost the same. The unpaid remainder gets pushed back to the
104 // emission schedule
105 // from hard fork 4, we use a single "dusty" output. This makes the tx even smaller,
106 // and avoids the quantization. These outputs will be added as rct outputs with identity
107 // masks, to they can be used as rct inputs.
108 if (hard_fork_version >= 2 && hard_fork_version < 4) {
109 block_reward = block_reward - block_reward % ::config::BASE_REWARD_CLAMP_THRESHOLD;
110 }
111
112 std::vector<uint64_t> out_amounts;
113 decompose_amount_into_digits(block_reward, hard_fork_version >= 2 ? 0 : ::config::DEFAULT_DUST_THRESHOLD,
114 [&out_amounts](uint64_t a_chunk) { out_amounts.push_back(a_chunk); },
115 [&out_amounts](uint64_t a_dust) { out_amounts.push_back(a_dust); });
116
117 CHECK_AND_ASSERT_MES(1 <= max_outs, false, "max_out must be non-zero");
118 if (height == 0 || hard_fork_version >= 4)
119 {
120 // the genesis block was not decomposed, for unknown reasons
121 while (max_outs < out_amounts.size())
122 {
123 //out_amounts[out_amounts.size() - 2] += out_amounts.back();
124 //out_amounts.resize(out_amounts.size() - 1);
125 out_amounts[1] += out_amounts[0];
126 for (size_t n = 1; n < out_amounts.size(); ++n)
127 out_amounts[n - 1] = out_amounts[n];
128 out_amounts.pop_back();
129 }
130 }
131 else
132 {
133 CHECK_AND_ASSERT_MES(max_outs >= out_amounts.size(), false, "max_out exceeded");
134 }
135
136 uint64_t summary_amounts = 0;
137 if (hard_fork_version >= HF_VERSION_PUBLIC_TX)
138 {
139 for (const auto out_amount : out_amounts)
140 {
143 tk.address.m_spend_public_key = miner_address.m_spend_public_key;
144 tk.m_address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
145
146 tx_out out;
147 summary_amounts += out.amount = out_amount;
148 out.target = tk;
149 tx.vout.push_back(out);
150 }
151
152 tx.version = 3;
153 }
154 else
155 {
156 keypair txkey = keypair::generate(hw::get_device("default"));
157 add_tx_pub_key_to_extra(tx, txkey.pub);
158 if(!extra_nonce.empty())
159 if(!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
160 return false;
161 if (!sort_tx_extra(tx.extra, tx.extra))
162 return false;
163
164 for (size_t no = 0; no < out_amounts.size(); no++)
165 {
166 crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);;
167 crypto::public_key out_eph_public_key = AUTO_VAL_INIT(out_eph_public_key);
168 bool r = crypto::generate_key_derivation(miner_address.m_view_public_key, txkey.sec, derivation);
169 CHECK_AND_ASSERT_MES(r, false, "while creating outs: failed to generate_key_derivation(" << miner_address.m_view_public_key << ", " << txkey.sec << ")");
170
171 r = crypto::derive_public_key(derivation, no, miner_address.m_spend_public_key, out_eph_public_key);
172 CHECK_AND_ASSERT_MES(r, false, "while creating outs: failed to derive_public_key(" << derivation << ", " << no << ", "<< miner_address.m_spend_public_key << ")");
173
174 txout_to_key tk;
175 tk.key = out_eph_public_key;
176
177 tx_out out;
178 summary_amounts += out.amount = out_amounts[no];
179 out.target = tk;
180 tx.vout.push_back(out);
181 }
182
183 tx.version = 1;
184 }
185
186
187 CHECK_AND_ASSERT_MES(summary_amounts == block_reward, false, "Failed to construct miner tx, summary_amounts = " << summary_amounts << " not equal block_reward = " << block_reward);
188
189 //lock
191 tx.vin.push_back(in);
192
194
195 //LOG_PRINT("MINER_TX generated ok, block_reward=" << print_etn(block_reward) << "(" << print_etn(block_reward - fee) << "+" << print_etn(fee)
196 // << "), current_block_size=" << current_block_size << ", already_generated_coins=" << already_generated_coins << ", tx_id=" << get_transaction_hash(tx), LOG_LEVEL_2);
197 return true;
198 }
uint64_t height
#define HF_VERSION_PUBLIC_TX
#define ETN_MINED_ETN_UNLOCK_WINDOW_V8
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
#define AUTO_VAL_INIT(v)
#define LOG_PRINT_L1(x)
#define LOG_PRINT_L0(x)
Definition misc_log_ex.h:99
uint64_t const DEFAULT_DUST_THRESHOLD
uint64_t const BASE_REWARD_CLAMP_THRESHOLD
POD_CLASS key_derivation
Definition crypto.h:101
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition crypto.h:272
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition crypto.h:275
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, uint64_t current_block_height, network_type nettype)
bool sort_tx_extra(const std::vector< uint8_t > &tx_extra, std::vector< uint8_t > &sorted_tx_extra, bool allow_partial)
void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
const config_t & get_config(network_type nettype)
bool add_extra_nonce_to_tx_extra(std::vector< uint8_t > &tx_extra, const blobdata &extra_nonce)
device & get_device(const std::string &device_descriptor)
Definition device.cpp:95
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
static keypair generate(hw::device &hwdev)
cryptonote::account_public_address address
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx()

bool cryptonote::construct_tx ( const account_keys & sender_account_keys,
std::vector< tx_source_entry > & sources,
const std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
const std::vector< uint8_t > & extra,
transaction & tx,
uint64_t unlock_time )

Definition at line 694 of file cryptonote_tx_utils.cpp.

695 {
696 std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
697 subaddresses[sender_account_keys.m_account_address.m_spend_public_key] = {0,0};
698 crypto::secret_key tx_key;
699 std::vector<crypto::secret_key> additional_tx_keys;
700 std::vector<tx_destination_entry> destinations_copy = destinations;
701 return construct_tx_and_get_tx_key(sender_account_keys, subaddresses, sources, destinations_copy, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys, false, { rct::RangeProofBorromean, 0}, NULL);
702 }
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
bool construct_tx_and_get_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
@ RangeProofBorromean
Definition rctTypes.h:235
account_public_address m_account_address
Definition account.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_and_get_tx_key() [1/2]

bool cryptonote::construct_tx_and_get_tx_key ( const account_keys & sender_account_keys,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
std::vector< tx_source_entry > & sources,
std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
const std::vector< uint8_t > & extra,
transaction & tx,
uint64_t unlock_time,
crypto::secret_key & tx_key,
std::vector< crypto::secret_key > & additional_tx_keys,
bool rct,
const rct::RCTConfig & rct_config,
rct::multisig_out * msout,
const uint32_t account_major_offset,
const cryptonote::network_type nettype )

Definition at line 666 of file cryptonote_tx_utils.cpp.

667 {
668 hw::device &hwdev = sender_account_keys.get_device();
669 hwdev.open_tx(tx_key);
670 try {
671 // figure out if we need to make additional tx pubkeys
672 size_t num_stdaddresses = 0;
673 size_t num_subaddresses = 0;
674 account_public_address single_dest_subaddress;
675 classify_addresses(destinations, change_addr, num_stdaddresses, num_subaddresses, single_dest_subaddress);
676 bool need_additional_txkeys = num_subaddresses > 0 && (num_stdaddresses > 0 || num_subaddresses > 1);
677 if (need_additional_txkeys)
678 {
679 additional_tx_keys.clear();
680 for (const auto &d: destinations)
681 additional_tx_keys.push_back(keypair::generate(sender_account_keys.get_device()).sec);
682 }
683
684 bool r = construct_tx_with_tx_key(sender_account_keys, subaddresses, sources, destinations, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys, rct, rct_config, msout, true, account_major_offset, nettype);
685 hwdev.close_tx();
686 return r;
687 } catch(...) {
688 hwdev.close_tx();
689 throw;
690 }
691 }
virtual bool open_tx(crypto::secret_key &tx_key)=0
virtual bool close_tx(void)=0
void classify_addresses(const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, size_t &num_stdaddresses, size_t &num_subaddresses, account_public_address &single_dest_subaddress)
bool construct_tx_with_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, bool shuffle_outs, const uint32_t account_major_offset, const cryptonote::network_type nettype)
hw::device & get_device() const
Definition account.cpp:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_and_get_tx_key() [2/2]

bool cryptonote::construct_tx_and_get_tx_key ( const account_keys & sender_account_keys,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
std::vector< tx_source_entry > & sources,
std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
const std::vector< uint8_t > & extra,
transaction & tx,
uint64_t unlock_time,
crypto::secret_key & tx_key,
std::vector< crypto::secret_key > & additional_tx_keys,
bool rct = false,
const rct::RCTConfig & rct_config = rct::RangeProofBorromean, 0 },
rct::multisig_out * msout = NULL,
uint32_t account_major_offset = 0,
const cryptonote::network_type = MAINNET )

◆ construct_tx_with_tx_key() [1/2]

bool cryptonote::construct_tx_with_tx_key ( const account_keys & sender_account_keys,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
std::vector< tx_source_entry > & sources,
std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
const std::vector< uint8_t > & extra,
transaction & tx,
uint64_t unlock_time,
const crypto::secret_key & tx_key,
const std::vector< crypto::secret_key > & additional_tx_keys,
bool rct,
const rct::RCTConfig & rct_config,
rct::multisig_out * msout,
bool shuffle_outs,
const uint32_t account_major_offset,
const cryptonote::network_type nettype )

Definition at line 222 of file cryptonote_tx_utils.cpp.

223 {
224 hw::device &hwdev = sender_account_keys.get_device();
225
226 if (sources.empty())
227 {
228 LOG_ERROR("Empty sources");
229 return false;
230 }
231
232 std::vector<rct::key> amount_keys;
233 //test tx is sent through this scope TWICE, once as a test and once for real... therefore we set null before each run.
235
236 amount_keys.clear();
237 if (msout)
238 {
239 msout->c.clear();
240 }
241
242 tx.unlock_time = unlock_time;
243
244 tx.extra = extra;
245 crypto::public_key txkey_pub;
246
247 // if we have a stealth payment id, find it and encrypt it with the tx key now
248 std::vector<tx_extra_field> tx_extra_fields;
249 if (parse_tx_extra(tx.extra, tx_extra_fields))
250 {
251 // IS TX GOING TO THE SMARTCHAIN BRIDGE? IF SO ADD THE ETN ADDRESS AND NEW SMARTCHAIN ADDRESS TO TX EXTRA:
252 // Portal address is derived from the genesis block hash of the mainnet so nobody knows the private key.
253 cryptonote::account_public_address portal_address;
254 crypto::hash h;
255 crypto::ec_point point;
256 if(nettype == MAINNET){
257 epee::string_tools::hex_to_pod("a2050dacd6a36b6fc71cd6447ee498fb2c42801b74e8fe921213f4fcbd95ddcc", h); // v9 fork
258 }else{
259 epee::string_tools::hex_to_pod("1c5da5c1e1420653825260b8ffc85499fdfb6457153a7df9720e659075b3ce76", h); // genesis hash hex ---> hash type --
260 }
261 crypto::hash_to_point(h, point); // generate curve point (burn address spendkey) deterministically in such a way that we can't recover the private key
262 crypto::public_key portal_address_spendkey;
263 std::copy(std::begin(point.data), std::end(point.data), std::begin(portal_address_spendkey.data)); // serialise point to pubkey type
264 std::string portal_address_spendkey_hex_str = epee::string_tools::pod_to_hex(portal_address_spendkey); // for testing only. pub spend =
265 std::string portal_address_viewkey_hex_str;
266 if(nettype == MAINNET){
267 portal_address_viewkey_hex_str = "2b95a2eb2c62253c57e82b082b850bbf22a1a7829aaea09c7c1511c1cced4375"; //private view is just e5c8af002654f38ec39ac80edbbcd0c03c9b483379d297af0c3ca15568c7300e -
268 }else{
269 portal_address_viewkey_hex_str = "5866666666666666666666666666666666666666666666666666666666666666"; //private view is just 0100000000000000000000000000000000000000000000000000000000000000 -
270 }
271 portal_address.m_spend_public_key = portal_address_spendkey;
272 epee::string_tools::hex_to_pod(portal_address_viewkey_hex_str, portal_address.m_view_public_key);
273 cryptonote::account_public_address dest_address = destinations[0].addr;
274
275 // Grab the full etnk.... address as a string, which we serialise to the extra as bytestring
276 // Also use secp256k1 library to take their electroneum private key (which will become their smartchain private key)
277 // and use it to create a secp256k1 public key... Then use the public key to
278 // generate their smartchain address 0xABC1D........ and put this in the tx extra in the same fashion
279 // NB the curve private key domain of ed25519 is a subset of that of secp256k1, and therefore no extra modulo
280 // operation is needed before generating the smartchain public key.
281 // This code uses generates an Ethereum address by taking the last 20 bytes of the Keccak-256 hash of the public key
282 // and adding the prefix "0x".
283 if(dest_address == portal_address){
284 LOG_PRINT_L1("Sending a migration transaction:");
285 crypto::secret_key k = sender_account_keys.m_spend_secret_key; // example private key (can hardcode): 5810ba5a47a45a256458dffe9be21b341a7d74c0b9a8b6a232c60474acbed203
286 std::string seckeystring = epee::string_tools::pod_to_hex(sender_account_keys.m_spend_secret_key); //debug purposes
287
288 // SOURCE ADDRESS
289 std::string bridge_source_address = cryptonote::get_account_address_as_str(nettype, false, sender_account_keys.m_account_address); //OK
290 add_bridge_source_address_to_tx_extra(tx.extra, bridge_source_address); //OK
291 LOG_PRINT_L1("Source address: " << bridge_source_address);
292
293 // SMARTCHAIN ADDRESS
294 unsigned char seckey1[32];
295 unsigned char public_key64[65];
296 size_t pk_len = 65;
297 secp256k1_pubkey pubkey1;
299 memcpy(seckey1, sender_account_keys.m_spend_secret_key.data, 32);
300 if(secp256k1_ec_seckey_verify(ctx, seckey1) == 0) { // sec key has an unrealistic chance of being invalid (10^-128) https://en.bitcoin.it/wiki/Private_key
301 LOG_ERROR("Invalid private key");
302 return false;
303 }
304
305 // create the pubkey and serialise it
306 if(secp256k1_ec_pubkey_create(ctx, &pubkey1, seckey1) == 0) { // this format is not sufficient for hashing, hence serialisation
307 LOG_ERROR("Failed to create secp256k1 public key");
308 return false;
309 }
310 secp256k1_ec_pubkey_serialize(ctx, public_key64, &pk_len, &pubkey1, SECP256K1_EC_UNCOMPRESSED); // serialise pubkey1 into publickey_64
311 std::string long_public_key2 = epee::string_tools::pod_to_hex(public_key64); // debug purposes - can check against https://lab.miguelmota.com/ethereum-private-key-to-public-key/example/
312
313 // Ethereum address generation: Take the last 20 bytes of the Keccak-256 hash of the public key
314 // keccak-1600() is not suitable, but keccak() with 24 rounds and mdlen (=size) of 32 is the same
315 // as keccak-256 with a 32 byte output. 24 rounds is the default in Monero for keccak()
316 // the first byte is the compression type so hash the 64 bytes after the first byte only
317 // I have put the 32 byte hash inside pubkey1.data just to save time
318 keccak(public_key64 + 1, 64, pubkey1.data, 32);
319 unsigned char address[20]; //smartchain address
320 memcpy(address, pubkey1.data + 12, 20); // take the last 20 bytes of the 32 byte array for the address
321 std::string hex_address = epee::string_tools::pod_to_hex(address); // should be 0x12ed7467c3852e6b2Bd3C22AF694be8DF7637B10.
322 std::string bridge_smartchain_address = "0x" + hex_address; //prefix address with 0x
323 LOG_PRINT_L1("Smartchain address: " << bridge_smartchain_address);
324
326 add_bridge_smartchain_address_to_tx_extra(tx.extra, bridge_smartchain_address);
327
328 // OWNERSHIP SIGNATURE: prove the sender owns the source address by signing
329 // (bridge_source_address + bridge_smartchain_address) with the spend secret key
330 std::string sig_message = bridge_source_address + bridge_smartchain_address;
331 crypto::hash sig_hash;
332 crypto::cn_fast_hash(sig_message.data(), sig_message.size(), sig_hash);
333 crypto::signature ownership_sig;
334 crypto::generate_signature(sig_hash, sender_account_keys.m_account_address.m_spend_public_key, sender_account_keys.m_spend_secret_key, ownership_sig);
336 LOG_PRINT_L1("Bridge ownership signature added to tx_extra");
337 }
338
339 bool add_dummy_payment_id = true;
340 tx_extra_nonce extra_nonce;
341 if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
342 {
343 crypto::hash payment_id = null_hash;
344 crypto::hash8 payment_id8 = null_hash8;
345 if (get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8))
346 {
347 LOG_PRINT_L2("Adding cleartext payment ID to extra nonce. Encrypted PIDs are now deprecated." << payment_id8);
348
349 std::string extra_nonce;
350
351 memcpy(payment_id.data, payment_id8.data, 8); // convert short pid to regular
352 memset(payment_id.data + 8, 0, 24); // merely a sanity check
353
354 set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
356 if (!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
357 {
358 LOG_ERROR("Failed to add payment id to tx extra");
359 return false;
360 }
361 LOG_PRINT_L1("Encrypted payment ID: " << payment_id8);
362 add_dummy_payment_id = false;
363 }
364 else if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id))
365 {
366 add_dummy_payment_id = false;
367 }
368 }
369
370 // we don't add one if we've got more than the usual 1 destination plus change
371 if (destinations.size() > 2)
372 add_dummy_payment_id = false;
373
374 if (add_dummy_payment_id)
375 {
376 std::string extra_nonce;
377 crypto::hash payment_id = null_hash;
378
379 set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
380 if (!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
381 {
382 LOG_ERROR("Failed to add dummy payment id to tx extra");
383 // continue anyway
384 }
385 }
386 }
387 else
388 {
389 MWARNING("Failed to parse tx extra");
390 tx_extra_fields.clear();
391 }
392
393 struct input_generation_context_data
394 {
395 keypair in_ephemeral;
396 };
397 std::vector<input_generation_context_data> in_contexts;
398
399 uint64_t summary_inputs_etn = 0;
400 //fill inputs
401 int idx = -1;
402
403 if(tx.version < 3) {
404 for (const tx_source_entry &src_entr : sources) {
405 ++idx;
406 if (src_entr.real_output >= src_entr.outputs.size()) {//
407 LOG_ERROR("real_output index (" << src_entr.real_output << ")bigger than output_keys.size()="
408 << src_entr.outputs.size());
409 return false;
410 }
411 summary_inputs_etn += src_entr.amount;
412
413 //key_derivation recv_derivation;
414 in_contexts.push_back(input_generation_context_data());
415 // Tx output private key which gets its value assigned inside generate_key_image_helper
416 keypair &in_ephemeral = in_contexts.back().in_ephemeral;
417 crypto::key_image img;//
418 const auto &out_key = reinterpret_cast<const crypto::public_key &>(src_entr.outputs[src_entr.real_output].second.dest);
419 if (!generate_key_image_helper(sender_account_keys, subaddresses, out_key, src_entr.real_out_tx_key,
420 src_entr.real_out_additional_tx_keys, src_entr.real_output_in_tx_index,
421 in_ephemeral, img, hwdev, account_major_offset)) {
422 LOG_ERROR("Key image generation failed!");
423 return false;
424 }
425
426 //check that derivated key is equal with real output key (if non multisig)
427 if (!msout && !(in_ephemeral.pub == src_entr.outputs[src_entr.real_output].second.dest)) {
428 LOG_ERROR("derived public key mismatch with output public key at index "
429 << idx << ", real out "
430 << src_entr.real_output << "! "
431 << ENDL << "derived_key:"
432 << string_tools::pod_to_hex(in_ephemeral.pub)
433 << ENDL
434 << "real output_public_key:"
435 << string_tools::pod_to_hex(src_entr.outputs[src_entr.real_output].second.dest));
436
437 LOG_ERROR("amount " << src_entr.amount << ", rct " << src_entr.rct);
438 LOG_ERROR("tx pubkey " << src_entr.real_out_tx_key << ", real_output_in_tx_index "
439 << src_entr.real_output_in_tx_index);
440 return false;
441 }
442
443 //put key image into tx input
444 txin_to_key input_to_key;
445 input_to_key.amount = src_entr.amount;
446 input_to_key.k_image = msout ? rct::rct2ki(src_entr.multisig_kLRki.ki) : img;
447
448 //fill outputs array and use relative offsets
449 for (const tx_source_entry::output_entry &out_entry: src_entr.outputs)
450 input_to_key.key_offsets.push_back(out_entry.first);
451
452 input_to_key.key_offsets = absolute_output_offsets_to_relative(input_to_key.key_offsets);
453 tx.vin.push_back(input_to_key);
454 }
455
456 // sort ins by their key image
457 std::vector<size_t> ins_order(sources.size());
458 for (size_t n = 0; n < sources.size(); ++n)
459 ins_order[n] = n;
460 std::sort(ins_order.begin(), ins_order.end(), [&](const size_t i0, const size_t i1) {
461 const txin_to_key &tk0 = boost::get<txin_to_key>(tx.vin[i0]);
462 const txin_to_key &tk1 = boost::get<txin_to_key>(tx.vin[i1]);
463 return memcmp(&tk0.k_image, &tk1.k_image, sizeof(tk0.k_image)) > 0;
464 });
465 tools::apply_permutation(ins_order, [&] (size_t i0, size_t i1) {
466 std::swap(tx.vin[i0], tx.vin[i1]);
467 std::swap(in_contexts[i0], in_contexts[i1]);
468 std::swap(sources[i0], sources[i1]);
469 });
470
471 if (shuffle_outs)
472 {
473 std::shuffle(destinations.begin(), destinations.end(), std::default_random_engine(crypto::rand<unsigned int>()));
474 }
475 } else{ // tx v3 onwards
476 for (const tx_source_entry &src_entr : sources) {
477 ++idx;
478 summary_inputs_etn += src_entr.amount;
479
480 txin_to_key_public input;
481 input.amount = src_entr.amount;
482 input.tx_hash = src_entr.tx_hash;
483 input.relative_offset = src_entr.real_output_in_tx_index;
484
485 tx.vin.push_back(input);
486 }
487 } //END OF WORK WITH INPUTS
488
489 // figure out if we need to make additional tx pubkeys
490 size_t num_stdaddresses = 0;
491 size_t num_subaddresses = 0;
492 account_public_address single_dest_subaddress;
493 classify_addresses(destinations, change_addr, num_stdaddresses, num_subaddresses, single_dest_subaddress);
494
495 // if this is a single-destination transfer to a subaddress, we set the tx pubkey to R=s*D
496 //todo: 4.0.0.0
497 if (num_stdaddresses == 0 && num_subaddresses == 1)
498 {
499 txkey_pub = rct::rct2pk(hwdev.scalarmultKey(rct::pk2rct(single_dest_subaddress.m_spend_public_key), rct::sk2rct(tx_key)));
500 }
501 else
502 {
503 txkey_pub = rct::rct2pk(hwdev.scalarmultBase(rct::sk2rct(tx_key)));
504 }
506 add_tx_pub_key_to_extra(tx, txkey_pub);
507
508 std::vector<crypto::public_key> additional_tx_public_keys;
509
510 // we don't need to include additional tx keys if:
511 // - all the destinations are standard addresses
512 // - there's only one destination which is a subaddress
513 bool need_additional_txkeys = num_subaddresses > 0 && (num_stdaddresses > 0 || num_subaddresses > 1);
514 if (need_additional_txkeys)
515 CHECK_AND_ASSERT_MES(destinations.size() == additional_tx_keys.size(), false, "Wrong amount of additional tx keys");
516
517 uint64_t summary_outs_etn = 0;
518 //fill outputs
519 size_t output_index = 0;
520 for (const tx_destination_entry &dst_entr: destinations) {
521 if(tx.version == 1) {
522 crypto::public_key out_eph_public_key;
523
524 hwdev.generate_output_ephemeral_keys(tx.version, sender_account_keys, txkey_pub, tx_key,
525 dst_entr, change_addr, output_index,
526 need_additional_txkeys, additional_tx_keys,
527 additional_tx_public_keys, amount_keys, out_eph_public_key);
528
529 tx_out out;
530 out.amount = dst_entr.amount;
531 txout_to_key tk;
532 tk.key = out_eph_public_key;
533 out.target = tk;
534 tx.vout.push_back(out);
535 output_index++;
536 summary_outs_etn += dst_entr.amount;
537 }else{
538 tx_out out;
539 out.amount = dst_entr.amount;
541 tkp.address.m_view_public_key = dst_entr.addr.m_view_public_key;
542 tkp.address.m_spend_public_key = dst_entr.addr.m_spend_public_key;
543 tkp.m_address_prefix = dst_entr.is_subaddress ?
546 out.target = tkp;
547 tx.vout.push_back(out);
548 output_index++;
549 summary_outs_etn += dst_entr.amount;
550 }
551 }
552
553 CHECK_AND_ASSERT_MES(additional_tx_public_keys.size() == additional_tx_keys.size(), false, "Internal error creating additional public keys");
554
556
557 LOG_PRINT_L2("tx pubkey: " << txkey_pub);
558 if (need_additional_txkeys)
559 {
560 LOG_PRINT_L2("additional tx pubkeys: ");
561 for (size_t i = 0; i < additional_tx_public_keys.size(); ++i)
562 LOG_PRINT_L2(additional_tx_public_keys[i]);
563 add_additional_tx_pub_keys_to_extra(tx.extra, additional_tx_public_keys);
564 }
565
566 if (!sort_tx_extra(tx.extra, tx.extra))
567 return false;
568
569 //check etn
570 if(summary_outs_etn > summary_inputs_etn )
571 {
572 LOG_ERROR("Transaction inputs ETN ("<< summary_inputs_etn << ") less than outputs ETN (" << summary_outs_etn << ")");
573 return false;
574 }
575
576 // check for watch only wallet
577 bool zero_secret_key = true;
578 for (size_t i = 0; i < sizeof(sender_account_keys.m_spend_secret_key); ++i)
579 zero_secret_key &= (sender_account_keys.m_spend_secret_key.data[i] == 0);
580 if (zero_secret_key)
581 {
582 MDEBUG("Null secret key, skipping signatures");
583 }
584
585 //generate ring signatures
586 crypto::hash tx_prefix_hash;
587 hwdev.get_transaction_prefix_hash(tx, tx_prefix_hash);
588
589 std::stringstream ss_ring_s;
590 size_t i = 0;
591
592 if(tx.version < 3)
593 {
594 for(const tx_source_entry& src_entr: sources)
595 {
596 ss_ring_s << "pub_keys:" << ENDL;
597 std::vector<const crypto::public_key *> keys_ptrs;
598 std::vector<crypto::public_key> keys(src_entr.outputs.size());
599 size_t ii = 0;
600 for (const tx_source_entry::output_entry &o: src_entr.outputs) {
601 keys[ii] = rct2pk(o.second.dest);
602 keys_ptrs.push_back(&keys[ii]);
603 ss_ring_s << o.second.dest << ENDL;
604 ++ii;
605 }
606
607 tx.signatures.push_back(std::vector<crypto::signature>());
608 std::vector<crypto::signature> &sigs = tx.signatures.back();
609 sigs.resize(src_entr.outputs.size());
610 if (!zero_secret_key)
611 hwdev.generate_ring_signature(tx_prefix_hash, boost::get<txin_to_key>(tx.vin[i]).k_image, keys_ptrs,
612 in_contexts[i].in_ephemeral.sec, src_entr.real_output, sigs.data());
613 ss_ring_s << "signatures:" << ENDL;
614 std::for_each(sigs.begin(), sigs.end(), [&](const crypto::signature &s) { ss_ring_s << s << ENDL; });
615 ss_ring_s << "prefix_hash:" << tx_prefix_hash << ENDL << "in_ephemeral_key: "
616 << in_contexts[i].in_ephemeral.sec << ENDL << "real_output: " << src_entr.real_output << ENDL;
617 i++;
618
619 MCINFO("construct_tx",
620 "transaction_created: " << get_transaction_hash(tx) << ENDL << obj_to_json_str(tx) << ENDL
621 << ss_ring_s.str());
622 }
623 }
624 else
625 { //new public signatures for v3 onwards
626 for(uint64_t i = 0; i< tx.vin.size(); i++) {
628 std::vector<crypto::signature> signature_vec;
629 if (!zero_secret_key) {
630
631 subaddress_index input_subaddress_index = sources[i].subaddr_index;
632 crypto::secret_key private_view_for_sig;
633 crypto::secret_key private_spend_for_sig;
634
635 if (input_subaddress_index.major == 0 && input_subaddress_index.minor == 0) {
636 private_view_for_sig = sender_account_keys.m_view_secret_key;
637 private_spend_for_sig = sender_account_keys.m_spend_secret_key;
638 } else {
639 private_spend_for_sig = hwdev.get_subaddress_private_spendkey(sender_account_keys,
640 input_subaddress_index);
641 private_view_for_sig = hwdev.get_subaddress_private_viewkey(sender_account_keys.m_view_secret_key,
642 private_spend_for_sig);
643 }
644
646 tx_prefix_hash,
647 i,
648 private_view_for_sig,
649 private_spend_for_sig,
651 );
652 }
653 signature_vec.push_back(signature);
654 tx.signatures.push_back(signature_vec);
655 }
656
657 MCINFO("construct_tx",
658 "transaction_created (v3): " << get_transaction_hash(tx) << ENDL << obj_to_json_str(tx));
659 }
660
662
663 return true;
664 }
std::vector< std::vector< crypto::signature > > signatures
virtual crypto::secret_key get_subaddress_private_viewkey(const crypto::secret_key &main_wallet_sec_view, crypto::secret_key &subaddress_sec_spend)=0
virtual bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional< cryptonote::account_public_address > &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector< crypto::secret_key > &additional_tx_keys, std::vector< crypto::public_key > &additional_tx_public_keys, std::vector< rct::key > &amount_keys, crypto::public_key &out_eph_public_key)=0
virtual bool get_transaction_prefix_hash(const cryptonote::transaction_prefix &tx, crypto::hash &tx_prefix_hash)=0
virtual bool scalarmultBase(rct::key &aG, const rct::key &a)=0
virtual bool generate_ring_signature(const crypto::hash &prefix_hash, const crypto::key_image &image, const std::vector< const crypto::public_key * > &pubs, const crypto::secret_key &sec, std::size_t sec_index, crypto::signature *sig)=0
virtual crypto::secret_key get_subaddress_private_spendkey(const cryptonote::account_keys &keys, const cryptonote::subaddress_index &subaddr_index)=0
virtual bool generate_input_signature(const crypto::hash &prefix_hash, const uint32_t input_index, const crypto::secret_key sec_view, const crypto::secret_key sec_spend, crypto::signature &signature)=0
virtual bool scalarmultKey(rct::key &aP, const rct::key &P, const rct::key &a)=0
std::vector< std::string > keypair
void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
#define MWARNING(x)
Definition misc_log_ex.h:74
#define MDEBUG(x)
Definition misc_log_ex.h:76
#define MCINFO(cat, x)
Definition misc_log_ex.h:53
#define ENDL
#define LOG_ERROR(x)
Definition misc_log_ex.h:98
void generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig)
Definition crypto.h:292
std::enable_if< std::is_pod< T >::value, T >::type rand()
Definition crypto.h:216
POD_CLASS ec_point
Definition crypto.h:70
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS hash8
Definition hash.h:53
void hash_to_point(const crypto::hash &h, crypto::ec_point &res)
Definition crypto.cpp:496
POD_CLASS key_image
Definition crypto.h:105
std::string obj_to_json_str(T &obj)
bool generate_key_image_helper(const account_keys &ack, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::public_key &tx_public_key, const std::vector< crypto::public_key > &additional_tx_public_keys, size_t real_output_index, keypair &in_ephemeral, crypto::key_image &ki, hw::device &hwdev, const uint32_t account_major_offset)
bool add_bridge_ownership_sig_to_tx_extra(std::vector< uint8_t > &tx_extra, const crypto::signature &sig)
bool get_encrypted_payment_id_from_tx_extra_nonce(const blobdata &extra_nonce, crypto::hash8 &payment_id)
bool get_payment_id_from_tx_extra_nonce(const blobdata &extra_nonce, crypto::hash &payment_id)
void set_payment_id_to_tx_extra_nonce(blobdata &extra_nonce, const crypto::hash &payment_id)
std::vector< uint64_t > absolute_output_offsets_to_relative(const std::vector< uint64_t > &off)
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
bool add_bridge_smartchain_address_to_tx_extra(std::vector< uint8_t > &tx_extra, const blobdata &bridge_smartchain_address)
bool find_tx_extra_field_by_type(const std::vector< tx_extra_field > &tx_extra_fields, T &field, size_t index=0)
bool parse_tx_extra(const std::vector< uint8_t > &tx_extra, std::vector< tx_extra_field > &tx_extra_fields)
bool add_additional_tx_pub_keys_to_extra(std::vector< uint8_t > &tx_extra, const std::vector< crypto::public_key > &additional_pub_keys)
bool remove_field_from_tx_extra(std::vector< uint8_t > &tx_extra, const std::type_info &type)
bool add_bridge_source_address_to_tx_extra(std::vector< uint8_t > &tx_extra, const blobdata &bridge_source_address)
std::string pod_to_hex(const t_pod_type &s)
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
void apply_permutation(std::vector< size_t > permutation, const F &swap)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
Definition secp256k1.h:207
struct secp256k1_context_struct secp256k1_context
Definition secp256k1.h:50
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(const secp256k1_context *ctx, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
#define SECP256K1_EC_UNCOMPRESSED
Definition secp256k1.h:214
crypto::secret_key m_view_secret_key
Definition account.h:45
crypto::secret_key m_spend_secret_key
Definition account.h:44
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
std::pair< uint64_t, rct::ctkey > output_entry
std::vector< key > c
Definition rctTypes.h:112
unsigned char data[64]
Definition secp256k1.h:75
const char * address
Definition multisig.cpp:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_with_tx_key() [2/2]

bool cryptonote::construct_tx_with_tx_key ( const account_keys & sender_account_keys,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
std::vector< tx_source_entry > & sources,
std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
const std::vector< uint8_t > & extra,
transaction & tx,
uint64_t unlock_time,
const crypto::secret_key & tx_key,
const std::vector< crypto::secret_key > & additional_tx_keys,
bool rct = false,
const rct::RCTConfig & rct_config = rct::RangeProofBorromean, 0 },
rct::multisig_out * msout = NULL,
bool shuffle_outs = true,
const uint32_t account_major_offset = 0,
const cryptonote::network_type = MAINNET )
Here is the call graph for this function:

◆ decompose_amount_into_digits()

template<typename chunk_handler_t, typename dust_handler_t>
void cryptonote::decompose_amount_into_digits ( uint64_t amount,
uint64_t dust_threshold,
const chunk_handler_t & chunk_handler,
const dust_handler_t & dust_handler )

Definition at line 212 of file cryptonote_format_utils.h.

213 {
214 if (0 == amount)
215 {
216 return;
217 }
218
219 bool is_dust_handled = false;
220 uint64_t dust = 0;
221 uint64_t order = 1;
222 while (0 != amount)
223 {
224 uint64_t chunk = (amount % 10) * order;
225 amount /= 10;
226 order *= 10;
227
228 if (dust + chunk <= dust_threshold)
229 {
230 dust += chunk;
231 }
232 else
233 {
234 if (!is_dust_handled && 0 != dust)
235 {
236 dust_handler(dust);
237 is_dust_handled = true;
238 }
239 if (0 != chunk)
240 {
241 chunk_handler(chunk);
242 }
243 }
244 }
245
246 if (!is_dust_handled && 0 != dust)
247 {
248 dust_handler(dust);
249 }
250 }
Here is the caller graph for this function:

◆ decrypt_key()

crypto::secret_key cryptonote::decrypt_key ( crypto::secret_key key,
const epee::wipeable_string & passphrase )

Definition at line 1354 of file cryptonote_format_utils.cpp.

1355 {
1357 crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
1358 sc_sub((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
1359 return key;
1360 }
const char * data() const noexcept
size_t size() const noexcept
void sc_sub(unsigned char *, const unsigned char *, const unsigned char *)
const char * key
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encrypt_key()

crypto::secret_key cryptonote::encrypt_key ( crypto::secret_key key,
const epee::wipeable_string & passphrase )

Definition at line 1346 of file cryptonote_format_utils.cpp.

1347 {
1349 crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
1350 sc_add((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
1351 return key;
1352 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand_transaction_1()

bool cryptonote::expand_transaction_1 ( transaction & tx,
bool base_only )

Definition at line 128 of file cryptonote_format_utils.cpp.

129 {
130 return true;
131 }
Here is the caller graph for this function:

◆ factorial()

double cryptonote::factorial ( unsigned int n)

Definition at line 1927 of file cryptonote_core.cpp.

1928 {
1929 if (n <= 1)
1930 return 1.0;
1931 double f = n;
1932 while (n-- > 1)
1933 f *= n;
1934 return f;
1935 }

◆ find_tx_extra_field_by_type()

template<typename T>
bool cryptonote::find_tx_extra_field_by_type ( const std::vector< tx_extra_field > & tx_extra_fields,
T & field,
size_t index = 0 )

Definition at line 62 of file cryptonote_format_utils.h.

63 {
64 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--; }); // ie index only decremented IF we fiind the right type
65 if(tx_extra_fields.end() == it)
66 return false;
67
68 field = boost::get<T>(*it);
69 return true;
70 }
Here is the caller graph for this function:

◆ generate_genesis_block()

bool cryptonote::generate_genesis_block ( block & bl,
std::string const & genesis_tx,
uint32_t nonce )

Definition at line 704 of file cryptonote_tx_utils.cpp.

709 {
710 //genesis block
711 bl = boost::value_initialized<block>();
712
713
714 account_public_address ac = boost::value_initialized<account_public_address>();
715 std::vector<size_t> sz;
716 construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
717 blobdata txb = tx_to_blob(bl.miner_tx);
718 std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
719
720 std::string genesis_coinbase_tx_hex = genesis_tx;
721
722 blobdata tx_bl;
723 bool r = string_tools::parse_hexstr_to_binbuff(genesis_tx, tx_bl);
724 CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
726 CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
729 bl.timestamp = 0;
730 bl.nonce = nonce;
733 return true;
734 }
static bool find_nonce_for_given_block(block &bl, const difficulty_type &diffic, uint64_t height)
Definition miner.cpp:478
#define CURRENT_BLOCK_MINOR_VERSION
#define CURRENT_BLOCK_MAJOR_VERSION
bool construct_miner_tx(size_t height, size_t median_weight, uint64_t already_generated_coins, size_t current_block_weight, uint64_t fee, const account_public_address &miner_address, transaction &tx, const blobdata &extra_nonce, size_t max_outs, uint8_t hard_fork_version, network_type nettype)
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
std::string buff_to_hex_nodelimer(const std::string &src)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_key_image_helper()

bool cryptonote::generate_key_image_helper ( const account_keys & ack,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
const crypto::public_key & out_key,
const crypto::public_key & tx_public_key,
const std::vector< crypto::public_key > & additional_tx_public_keys,
size_t real_output_index,
keypair & in_ephemeral,
crypto::key_image & ki,
hw::device & hwdev,
const uint32_t account_major_offset )

Definition at line 208 of file cryptonote_format_utils.cpp.

209 {
210 crypto::key_derivation recv_derivation = AUTO_VAL_INIT(recv_derivation);
211 bool r = hwdev.generate_key_derivation(tx_public_key, ack.m_view_secret_key, recv_derivation);
212 if (!r)
213 {
214 MWARNING("key image helper: failed to generate_key_derivation(" << tx_public_key << ", " << ack.m_view_secret_key << ")");
215 memcpy(&recv_derivation, rct::identity().bytes, sizeof(recv_derivation));
216 }
217
218 std::vector<crypto::key_derivation> additional_recv_derivations;
219 for (size_t i = 0; i < additional_tx_public_keys.size(); ++i)
220 {
221 crypto::key_derivation additional_recv_derivation = AUTO_VAL_INIT(additional_recv_derivation);
222 r = hwdev.generate_key_derivation(additional_tx_public_keys[i], ack.m_view_secret_key, additional_recv_derivation);
223 if (!r)
224 {
225 MWARNING("key image helper: failed to generate_key_derivation(" << additional_tx_public_keys[i] << ", " << ack.m_view_secret_key << ")");
226 }
227 else
228 {
229 additional_recv_derivations.push_back(additional_recv_derivation);
230 }
231 }
232
233 boost::optional<subaddress_receive_info> subaddr_recv_info = is_out_to_acc_precomp(subaddresses, out_key, recv_derivation, additional_recv_derivations, real_output_index,hwdev);
234 CHECK_AND_ASSERT_MES(subaddr_recv_info, false, "key image helper: given output pubkey doesn't seem to belong to this address");
235
236 return generate_key_image_helper_precomp(ack, out_key, subaddr_recv_info->derivation, real_output_index, subaddr_recv_info->index, in_ephemeral, ki, hwdev, account_major_offset);
237 }
virtual bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation)=0
boost::optional< subaddress_receive_info > is_out_to_acc_precomp(const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t output_index, hw::device &hwdev)
bool generate_key_image_helper_precomp(const account_keys &ack, const crypto::public_key &out_key, const crypto::key_derivation &recv_derivation, size_t real_output_index, const subaddress_index &received_index, keypair &in_ephemeral, crypto::key_image &ki, hw::device &hwdev, const uint32_t account_major_offset)
key identity()
Definition rctOps.h:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_key_image_helper_precomp()

bool cryptonote::generate_key_image_helper_precomp ( const account_keys & ack,
const crypto::public_key & out_key,
const crypto::key_derivation & recv_derivation,
size_t real_output_index,
const subaddress_index & received_index,
keypair & in_ephemeral,
crypto::key_image & ki,
hw::device & hwdev,
const uint32_t account_major_offset )

Definition at line 239 of file cryptonote_format_utils.cpp.

240 {
241 uint32_t major_index_offset_based = received_index.major + (received_index.major != 0 ? account_major_offset : 0);
242 cryptonote::subaddress_index recv_index = {major_index_offset_based, received_index.minor};
243
244 if (hwdev.compute_key_image(ack, out_key, recv_derivation, real_output_index, recv_index, in_ephemeral, ki))
245 {
246 return true;
247 }
248
250 {
251 // for watch-only wallet, simply copy the known output pubkey
252 in_ephemeral.pub = out_key;
253 in_ephemeral.sec = crypto::null_skey;
254 }
255 else
256 {
257 // derive secret key with subaddress - step 1: original CN derivation
258 crypto::secret_key scalar_step1;
259 hwdev.derive_secret_key(recv_derivation, real_output_index, ack.m_spend_secret_key, scalar_step1); // computes Hs(a*R || idx) + b
260
261 // step 2: add Hs(a || index_major || index_minor)
262 crypto::secret_key subaddr_sk;
263 crypto::secret_key scalar_step2;
264 if (recv_index.is_zero())
265 {
266 scalar_step2 = scalar_step1; // treat index=(0,0) as a special case representing the main address
267 }
268 else
269 {
270 subaddr_sk = hwdev.get_subaddress_secret_key(ack.m_view_secret_key, recv_index);
271 hwdev.sc_secret_add(scalar_step2, scalar_step1,subaddr_sk);
272 }
273
274 in_ephemeral.sec = scalar_step2;
275
276 if (ack.m_multisig_keys.empty())
277 {
278 // when not in multisig, we know the full spend secret key, so the output pubkey can be obtained by scalarmultBase
279 CHECK_AND_ASSERT_MES(hwdev.secret_key_to_public_key(in_ephemeral.sec, in_ephemeral.pub), false, "Failed to derive public key");
280 }
281 else
282 {
283 // when in multisig, we only know the partial spend secret key. but we do know the full spend public key, so the output pubkey can be obtained by using the standard CN key derivation
284 CHECK_AND_ASSERT_MES(hwdev.derive_public_key(recv_derivation, real_output_index, ack.m_account_address.m_spend_public_key, in_ephemeral.pub), false, "Failed to derive public key");
285 // and don't forget to add the contribution from the subaddress part
286 if (!recv_index.is_zero())
287 {
288 crypto::public_key subaddr_pk;
289 CHECK_AND_ASSERT_MES(hwdev.secret_key_to_public_key(subaddr_sk, subaddr_pk), false, "Failed to derive public key");
290 add_public_key(in_ephemeral.pub, in_ephemeral.pub, subaddr_pk);
291 }
292 }
293
294 CHECK_AND_ASSERT_MES(in_ephemeral.pub == out_key,
295 false, "key image helper precomp: given output pubkey doesn't match the derived one");
296 }
297
298 hwdev.generate_key_image(in_ephemeral.pub, in_ephemeral.sec, ki);
299 return true;
300 }
virtual bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b)=0
virtual bool generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image)=0
virtual bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub)=0
virtual crypto::secret_key get_subaddress_secret_key(const crypto::secret_key &sec, const cryptonote::subaddress_index &index)=0
virtual bool secret_key_to_public_key(const crypto::secret_key &sec, crypto::public_key &pub)=0
virtual bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec)=0
virtual bool compute_key_image(const cryptonote::account_keys &ack, const crypto::public_key &out_key, const crypto::key_derivation &recv_derivation, size_t real_output_index, const cryptonote::subaddress_index &received_index, cryptonote::keypair &in_ephemeral, crypto::key_image &ki)
Definition device.hpp:246
const crypto::secret_key null_skey
Definition crypto.cpp:73
unsigned int uint32_t
Definition stdint.h:126
std::vector< crypto::secret_key > m_multisig_keys
Definition account.h:46
crypto::secret_key sec
crypto::public_key pub
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_composite_key_image()

bool cryptonote::generate_multisig_composite_key_image ( const account_keys & keys,
const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
const crypto::public_key & out_key,
const crypto::public_key & tx_public_key,
const std::vector< crypto::public_key > & additional_tx_public_keys,
size_t real_output_index,
const std::vector< crypto::key_image > & pkis,
crypto::key_image & ki )

Definition at line 156 of file multisig.cpp.

157 {
158 cryptonote::keypair in_ephemeral;
159 if (!cryptonote::generate_key_image_helper(keys, subaddresses, out_key, tx_public_key, additional_tx_public_keys, real_output_index, in_ephemeral, ki, keys.get_device()))
160 return false;
161 std::unordered_set<crypto::key_image> used;
162 for (size_t m = 0; m < keys.m_multisig_keys.size(); ++m)
163 {
165 bool r = cryptonote::generate_multisig_key_image(keys, m, out_key, pki);
166 if (!r)
167 return false;
168 used.insert(pki);
169 }
170 for (const auto &pki: pkis)
171 {
172 if (used.find(pki) == used.end())
173 {
174 used.insert(pki);
175 rct::addKeys((rct::key&)ki, rct::ki2rct(ki), rct::ki2rct(pki));
176 }
177 }
178 return true;
179 }
bool generate_multisig_key_image(const account_keys &keys, size_t multisig_key_index, const crypto::public_key &out_key, crypto::key_image &ki)
Definition multisig.cpp:142
void addKeys(key &AB, const key &A, const key &B)
Definition rctOps.cpp:420
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_derivations()

std::vector< crypto::public_key > cryptonote::generate_multisig_derivations ( const account_keys & keys,
const std::vector< crypto::public_key > & derivations )

generate_multisig_derivations performs common DH key derivation. Each middle round in M/N scheme is DH exchange of public multisig keys of other participants multiplied by secret spend key of current participant. this functions does the following: new multisig key = secret spend * public multisig key

Parameters
keys- current wallet's keys
derivations- public multisig keys of other participants
Returns
new public multisig keys derived from previous round. This data needs to be exchange with other participants

Definition at line 87 of file multisig.cpp.

88 {
89 std::vector<crypto::public_key> multisig_keys;
91 for (const auto &k: derivations)
92 {
93 rct::key d = rct::scalarmultKey(rct::pk2rct(k), rct::sk2rct(blinded_skey));
94 multisig_keys.push_back(rct::rct2pk(d));
95 }
96
97 return multisig_keys;
98 }
void scalarmultKey(key &aP, const key &P, const key &a)
Definition rctOps.cpp:368
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_key_image()

bool cryptonote::generate_multisig_key_image ( const account_keys & keys,
size_t multisig_key_index,
const crypto::public_key & out_key,
crypto::key_image & ki )

Definition at line 142 of file multisig.cpp.

143 {
144 if (multisig_key_index >= keys.m_multisig_keys.size())
145 return false;
146 crypto::generate_key_image(out_key, keys.m_multisig_keys[multisig_key_index], ki);
147 return true;
148 }
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
Definition crypto.h:324
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_LR()

void cryptonote::generate_multisig_LR ( const crypto::public_key pkey,
const crypto::secret_key & k,
crypto::public_key & L,
crypto::public_key & R )

Definition at line 150 of file multisig.cpp.

151 {
152 rct::scalarmultBase((rct::key&)L, rct::sk2rct(k));
154 }
void scalarmultBase(key &aG, const key &a)
Definition rctOps.cpp:350
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_M_N_spend_public_key()

crypto::public_key cryptonote::generate_multisig_M_N_spend_public_key ( const std::vector< crypto::public_key > & pkeys)

generate_multisig_M_N_spend_public_key calculates multisig wallet's spend public key by summing all of public multisig keys

Parameters
pkeysunique public multisig keys
Returns
multisig wallet's spend public key

Definition at line 132 of file multisig.cpp.

133 {
134 rct::key spend_public_key = rct::identity();
135 for (const auto &pk: pkeys)
136 {
137 rct::addKeys(spend_public_key, spend_public_key, rct::pk2rct(pk));
138 }
139 return rct::rct2pk(spend_public_key);
140 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_N1_N()

void cryptonote::generate_multisig_N1_N ( const account_keys & keys,
const std::vector< crypto::public_key > & spend_keys,
std::vector< crypto::secret_key > & multisig_keys,
rct::key & spend_skey,
rct::key & spend_pkey )

Definition at line 70 of file multisig.cpp.

71 {
72 multisig_keys.clear();
73 spend_pkey = rct::identity();
74 spend_skey = rct::zero();
75
76 // create all our composite private keys
78 for (const auto &k: spend_keys)
79 {
80 rct::key sk = rct::scalarmultKey(rct::pk2rct(k), rct::sk2rct(blinded_skey));
82 multisig_keys.push_back(msk);
83 sc_add(spend_skey.bytes, spend_skey.bytes, (const unsigned char*)msk.data);
84 }
85 }
unsigned char bytes[32]
Definition rctTypes.h:86
Here is the call graph for this function:

◆ generate_multisig_N_N()

void cryptonote::generate_multisig_N_N ( const account_keys & keys,
const std::vector< crypto::public_key > & spend_keys,
std::vector< crypto::secret_key > & multisig_keys,
rct::key & spend_skey,
rct::key & spend_pkey )

Definition at line 58 of file multisig.cpp.

59 {
60 // the multisig spend public key is the sum of all spend public keys
61 multisig_keys.clear();
63 CHECK_AND_ASSERT_THROW_MES(crypto::secret_key_to_public_key(spend_secret_key, (crypto::public_key&)spend_pkey), "Failed to derive public key");
64 for (const auto &k: spend_keys)
65 rct::addKeys(spend_pkey, spend_pkey, rct::pk2rct(k));
66 multisig_keys.push_back(spend_secret_key);
67 spend_skey = rct::sk2rct(spend_secret_key);
68 }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition crypto.h:262
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_multisig_view_secret_key()

crypto::secret_key cryptonote::generate_multisig_view_secret_key ( const crypto::secret_key & skey,
const std::vector< crypto::secret_key > & skeys )

Definition at line 124 of file multisig.cpp.

125 {
126 rct::key view_skey = rct::sk2rct(get_multisig_blinded_secret_key(skey));
127 for (const auto &k: skeys)
128 sc_add(view_skey.bytes, view_skey.bytes, rct::sk2rct(k).bytes);
129 return rct::rct2sk(view_skey);
130 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_output_ephemeral_keys()

bool cryptonote::generate_output_ephemeral_keys ( const size_t tx_version,
const cryptonote::account_keys & sender_account_keys,
const crypto::public_key & txkey_pub,
const crypto::secret_key & tx_key,
const cryptonote::tx_destination_entry & dst_entr,
const boost::optional< cryptonote::account_public_address > & change_addr,
const size_t output_index,
const bool & need_additional_txkeys,
const std::vector< crypto::secret_key > & additional_tx_keys,
std::vector< crypto::public_key > & additional_tx_public_keys,
std::vector< rct::key > & amount_keys,
crypto::public_key & out_eph_public_key )

◆ get_account_address_as_str()

std::string cryptonote::get_account_address_as_str ( network_type nettype,
bool subaddress,
account_public_address const & adr )

Definition at line 207 of file cryptonote_basic_impl.cpp.

212 {
214
216 }
std::string encode_addr(uint64_t tag, const std::string &data)
Definition base58.cpp:228
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_account_address_checksum()

uint8_t cryptonote::get_account_address_checksum ( const public_address_outer_blob & bl)

Definition at line 187 of file cryptonote_basic_impl.cpp.

188 {
189 const unsigned char* pbuf = reinterpret_cast<const unsigned char*>(&bl);
190 uint8_t summ = 0;
191 for(size_t i = 0; i!= sizeof(public_address_outer_blob)-1; i++)
192 summ += pbuf[i];
193
194 return summ;
195 }
Here is the caller graph for this function:

◆ get_account_address_from_str()

bool cryptonote::get_account_address_from_str ( address_parse_info & info,
network_type nettype,
std::string const & str )

Definition at line 243 of file cryptonote_basic_impl.cpp.

248 {
252
253 if (2 * sizeof(public_address_outer_blob) != str.size())
254 {
255 blobdata data;
256 uint64_t prefix;
257 if (!tools::base58::decode_addr(str, prefix, data))
258 {
259 LOG_PRINT_L2("Invalid address format");
260 return false;
261 }
262
263 if (integrated_address_prefix == prefix)
264 {
265 info.is_subaddress = false;
266 info.has_payment_id = true;
267 }
268 else if (address_prefix == prefix)
269 {
270 info.is_subaddress = false;
271 info.has_payment_id = false;
272 }
273 else if (subaddress_prefix == prefix)
274 {
275 info.is_subaddress = true;
276 info.has_payment_id = false;
277 }
278 else {
279 LOG_PRINT_L1("Wrong address prefix: " << prefix << ", expected " << address_prefix
280 << " or " << integrated_address_prefix
281 << " or " << subaddress_prefix);
282 return false;
283 }
284
285 if (info.has_payment_id)
286 {
288 if (!::serialization::parse_binary(data, iadr))
289 {
290 LOG_PRINT_L1("Account public address keys can't be parsed");
291 return false;
292 }
293 info.address = iadr.adr;
294 info.payment_id = iadr.payment_id;
295 }
296 else
297 {
298 if (!::serialization::parse_binary(data, info.address))
299 {
300 LOG_PRINT_L1("Account public address keys can't be parsed");
301 return false;
302 }
303 }
304
305 if (!crypto::check_key(info.address.m_spend_public_key) || !crypto::check_key(info.address.m_view_public_key))
306 {
307 LOG_PRINT_L1("Failed to validate address keys");
308 return false;
309 }
310 }
311 else
312 {
313 // Old address format
314 std::string buff;
316 return false;
317
318 if(buff.size()!=sizeof(public_address_outer_blob))
319 {
320 LOG_PRINT_L1("Wrong public address size: " << buff.size() << ", expected size: " << sizeof(public_address_outer_blob));
321 return false;
322 }
323
324 public_address_outer_blob blob = *reinterpret_cast<const public_address_outer_blob*>(buff.data());
325
326
328 {
329 LOG_PRINT_L1("Unknown version of public address: " << blob.m_ver << ", expected " << CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER);
330 return false;
331 }
332
333 if(blob.check_sum != get_account_address_checksum(blob))
334 {
335 LOG_PRINT_L1("Wrong public address checksum");
336 return false;
337 }
338
339 //we success
340 info.address = blob.m_address;
341 info.is_subaddress = false;
342 info.has_payment_id = false;
343 }
344
345 return true;
346 }
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER
uint8_t get_account_address_checksum(const public_address_outer_blob &bl)
bool parse_binary(const std::string &blob, T &v)
bool decode_addr(const std::string &addr, uint64_t &tag, std::string &data)
Definition base58.cpp:238
CXA_THROW_INFO_T * info
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_account_address_from_str_or_url()

bool cryptonote::get_account_address_from_str_or_url ( address_parse_info & info,
network_type nettype,
const std::string & str_or_url,
std::function< std::string(const std::string &, const std::vector< std::string > &, bool)> dns_confirm )

Definition at line 348 of file cryptonote_basic_impl.cpp.

354 {
355 if (get_account_address_from_str(info, nettype, str_or_url))
356 return true;
357 bool dnssec_valid;
358 std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(str_or_url, dnssec_valid, dns_confirm);
359 return !address_str.empty() &&
360 get_account_address_from_str(info, nettype, address_str);
361 }
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
std::string get_account_address_as_str_from_url(const std::string &url, bool &dnssec_valid, std::function< std::string(const std::string &, const std::vector< std::string > &, bool)> dns_confirm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_account_integrated_address_as_str()

std::string cryptonote::get_account_integrated_address_as_str ( network_type nettype,
account_public_address const & adr,
crypto::hash8 const & payment_id )

Definition at line 218 of file cryptonote_basic_impl.cpp.

223 {
225
226 integrated_address iadr = {
227 adr, payment_id
228 };
229 return tools::base58::encode_addr(integrated_address_prefix, t_serializable_object_to_blob(iadr));
230 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_account_integrated_address_checksum()

uint8_t cryptonote::get_account_integrated_address_checksum ( const public_integrated_address_outer_blob & bl)

Definition at line 197 of file cryptonote_basic_impl.cpp.

198 {
199 const unsigned char* pbuf = reinterpret_cast<const unsigned char*>(&bl);
200 uint8_t summ = 0;
201 for(size_t i = 0; i!= sizeof(public_integrated_address_outer_blob)-1; i++)
202 summ += pbuf[i];
203
204 return summ;
205 }

◆ get_additional_tx_pub_keys_from_extra() [1/2]

std::vector< crypto::public_key > cryptonote::get_additional_tx_pub_keys_from_extra ( const std::vector< uint8_t > & tx_extra)

Definition at line 558 of file cryptonote_format_utils.cpp.

559 {
560 // parse
561 std::vector<tx_extra_field> tx_extra_fields;
562 parse_tx_extra(tx_extra, tx_extra_fields);
563 // find corresponding field
564 tx_extra_additional_pub_keys additional_pub_keys;
565 if(!find_tx_extra_field_by_type(tx_extra_fields, additional_pub_keys))
566 return {};
567 return additional_pub_keys.data;
568 }
std::vector< crypto::public_key > data
Definition tx_extra.h:170
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_additional_tx_pub_keys_from_extra() [2/2]

std::vector< crypto::public_key > cryptonote::get_additional_tx_pub_keys_from_extra ( const transaction_prefix & tx)

Definition at line 570 of file cryptonote_format_utils.cpp.

571 {
573 }
std::vector< crypto::public_key > get_additional_tx_pub_keys_from_extra(const std::vector< uint8_t > &tx_extra)
Here is the call graph for this function:

◆ get_blob_hash() [1/4]

crypto::hash cryptonote::get_blob_hash ( const blobdata & blob)

Definition at line 998 of file cryptonote_format_utils.cpp.

999 {
1000 crypto::hash h = null_hash;
1001 get_blob_hash(blob, h);
1002 return h;
1003 }
Here is the call graph for this function:

◆ get_blob_hash() [2/4]

void cryptonote::get_blob_hash ( const blobdata & blob,
crypto::hash & res )

Definition at line 947 of file cryptonote_format_utils.cpp.

948 {
949 cn_fast_hash(blob.data(), blob.size(), res);
950 }
Here is the call graph for this function:

◆ get_blob_hash() [3/4]

crypto::hash cryptonote::get_blob_hash ( const epee::span< const char > & blob)

Definition at line 1005 of file cryptonote_format_utils.cpp.

1006 {
1007 crypto::hash h = null_hash;
1008 get_blob_hash(blob, h);
1009 return h;
1010 }
Here is the call graph for this function:

◆ get_blob_hash() [4/4]

void cryptonote::get_blob_hash ( const epee::span< const char > & blob,
crypto::hash & res )

Definition at line 942 of file cryptonote_format_utils.cpp.

943 {
944 cn_fast_hash(blob.data(), blob.size(), res);
945 }
constexpr std::size_t size() const noexcept
Definition span.h:111
constexpr pointer data() const noexcept
Definition span.h:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_complete_entry()

block_complete_entry cryptonote::get_block_complete_entry ( block & b,
tx_memory_pool & pool )

Definition at line 1406 of file cryptonote_core.cpp.

1407 {
1410 for (const auto &tx_hash: b.tx_hashes)
1411 {
1412 cryptonote::blobdata txblob;
1413 CHECK_AND_ASSERT_THROW_MES(pool.get_transaction(tx_hash, txblob), "Transaction not found in pool");
1414 bce.txs.push_back(txblob);
1415 }
1416 return bce;
1417 }
bool get_transaction(const crypto::hash &h, cryptonote::blobdata &txblob) const
get a specific transaction from the pool
Definition tx_pool.cpp:1185
blobdata block_to_blob(const block &b)
std::vector< blobdata > txs
blobdata block
std::vector< crypto::hash > tx_hashes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_hash() [1/2]

crypto::hash cryptonote::get_block_hash ( const block & b)

Definition at line 1215 of file cryptonote_format_utils.cpp.

1216 {
1217 crypto::hash p = null_hash;
1218 get_block_hash(b, p);
1219 return p;
1220 }
bool get_block_hash(const block &b, crypto::hash &res)
Here is the call graph for this function:

◆ get_block_hash() [2/2]

bool cryptonote::get_block_hash ( const block & b,
crypto::hash & res )

Definition at line 1195 of file cryptonote_format_utils.cpp.

1196 {
1197 if (b.is_hash_valid())
1198 {
1199#ifdef ENABLE_HASH_CASH_INTEGRITY_CHECK
1200 CHECK_AND_ASSERT_THROW_MES(!calculate_block_hash(b, res) || b.hash == res, "block hash cash integrity failure");
1201#endif
1202 res = b.hash;
1203 ++block_hashes_cached_count;
1204 return true;
1205 }
1206 ++block_hashes_calculated_count;
1207 bool ret = calculate_block_hash(b, res);
1208 if (!ret)
1209 return false;
1210 b.hash = res;
1211 b.set_hash_valid(true);
1212 return true;
1213 }
bool calculate_block_hash(const block &b, crypto::hash &res, const blobdata *blob)
bool is_hash_valid() const
void set_hash_valid(bool v) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_hashing_blob()

blobdata cryptonote::get_block_hashing_blob ( const block & b)

Definition at line 1181 of file cryptonote_format_utils.cpp.

1182 {
1183 blobdata blob = t_serializable_object_to_blob(static_cast<block_header>(b));
1184 crypto::hash tree_root_hash = get_tx_tree_hash(b);
1185 blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
1186 blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
1187 return blob;
1188 }
void get_tx_tree_hash(const std::vector< crypto::hash > &tx_hashes, crypto::hash &h)
std::string get_varint_data(const T &v)
Returns the string that represents the varint.
Definition varint.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_height()

uint64_t cryptonote::get_block_height ( const block & b)

Definition at line 744 of file cryptonote_format_utils.cpp.

745 {
746 CHECK_AND_ASSERT_MES(b.miner_tx.vin.size() == 1, 0, "wrong miner tx in block: " << get_block_hash(b) << ", b.miner_tx.vin.size() != 1");
747 CHECKED_GET_SPECIFIC_VARIANT(b.miner_tx.vin[0], const txin_gen, coinbase_in, 0);
748 return coinbase_in.height;
749 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_longhash() [1/2]

bool cryptonote::get_block_longhash ( const block & b,
crypto::hash & res,
uint64_t height )

Definition at line 1222 of file cryptonote_format_utils.cpp.

1223 {
1225 const int cn_variant = b.major_version == 6 ? b.major_version - 5 : 0; // Emergency HF so anti-asic is only if HF 6
1226 crypto::cn_slow_hash(bd.data(), bd.size(), res, cn_variant);
1227 return true;
1228 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_longhash() [2/2]

crypto::hash cryptonote::get_block_longhash ( const block & b,
uint64_t height )

Definition at line 1250 of file cryptonote_format_utils.cpp.

1251 {
1252 crypto::hash p = null_hash;
1254 return p;
1255 }
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
Here is the call graph for this function:

◆ get_block_reward()

bool cryptonote::get_block_reward ( size_t median_weight,
size_t current_block_weight,
uint64_t already_generated_coins,
uint64_t & reward,
uint8_t version,
uint64_t current_block_height,
network_type nettype )

Definition at line 91 of file cryptonote_basic_impl.cpp.

91 {
92 static_assert(DIFFICULTY_TARGET%60==0,"difficulty target must be a multiple of 60");
93 static_assert(DIFFICULTY_TARGET_V6%60==0,"difficulty target V6 must be a multiple of 60");
94
95 const int target = version >= 6 ? DIFFICULTY_TARGET_V6 : DIFFICULTY_TARGET;
96
97 const int target_minutes = target / 60;
98
99 uint64_t full_reward_zone = get_min_block_weight(version);
100
101 const uint64_t premine = 1260000000000U;
102 if (median_weight > 0 && already_generated_coins < premine && !(current_block_weight >= 2 * full_reward_zone)) {
103 reward = premine;
104 return true;
105 }
106
107 uint64_t base_reward;
108
109 // After v9 the reward drops by ~75%, fixed reward curve that halves every 4 years (up to 2 halvings)
110 if(version >= 9) {
111
112 uint64_t V9_BLOCK_HEIGHT = 0;
113 switch(nettype) {
114 case MAINNET:
115 V9_BLOCK_HEIGHT = 862866;
116 break;
117 case TESTNET:
118 V9_BLOCK_HEIGHT = 707121;
119 break;
120 case STAGENET:
121 V9_BLOCK_HEIGHT = 39000;
122 break;
123 default:
124 V9_BLOCK_HEIGHT = 39000;
125 }
126
127 base_reward = version >= 10 ? 100 * COIN : 400 * COIN;
128 uint8_t halvings = (current_block_height - V9_BLOCK_HEIGHT) / 1051200; // Every 4 years
129
130 // Tail emission after 2nd halving
131 if (halvings > 2) {
132
133 //Force 2x tail emission after 2nd halving if circulating supply < max supply
134 base_reward = (already_generated_coins >= ETN_SUPPLY) ? FINAL_SUBSIDY_PER_MINUTE : FINAL_SUBSIDY_PER_MINUTE * 2;
135
136 } else {
137 base_reward >>= halvings;
138 }
139 } else {
140 //After v8 the reward drops by ~75%
141 double emission_speed_factor = (version == 8 ? EMISSION_SPEED_FACTOR_PER_MINUTE_V8 : EMISSION_SPEED_FACTOR_PER_MINUTE) - (target_minutes-1);
142
143 base_reward = (ETN_SUPPLY - already_generated_coins) / pow(2, emission_speed_factor);
144
145 if (base_reward < FINAL_SUBSIDY_PER_MINUTE*target_minutes)
146 {
147 base_reward = FINAL_SUBSIDY_PER_MINUTE*target_minutes;
148 }
149 }
150
151 //make it soft
152 if (median_weight < full_reward_zone) {
153 median_weight = full_reward_zone;
154 }
155
156 if (current_block_weight <= median_weight) {
157 reward = base_reward;
158 return true;
159 }
160
161 if(current_block_weight > 2 * median_weight) {
162 MERROR("Block cumulative weight is too big: " << current_block_weight << ", expected less than " << 2 * median_weight);
163 return false;
164 }
165
166 assert(median_weight < std::numeric_limits<uint32_t>::max());
167 assert(current_block_weight < std::numeric_limits<uint32_t>::max());
168
169 uint64_t product_hi;
170 // BUGFIX: 32-bit saturation bug (e.g. ARM7), the result was being
171 // treated as 32-bit by default.
172 uint64_t multiplicand = 2 * median_weight - current_block_weight;
173 multiplicand *= current_block_weight;
174 uint64_t product_lo = mul128(base_reward, multiplicand, &product_hi);
175
176 uint64_t reward_hi;
177 uint64_t reward_lo;
178 div128_32(product_hi, product_lo, static_cast<uint32_t>(median_weight), &reward_hi, &reward_lo);
179 div128_32(reward_hi, reward_lo, static_cast<uint32_t>(median_weight), &reward_hi, &reward_lo);
180 assert(0 == reward_hi);
181 assert(reward_lo < base_reward);
182
183 reward = reward_lo;
184 return true;
185 }
uint8_t version
#define COIN
#define EMISSION_SPEED_FACTOR_PER_MINUTE
#define DIFFICULTY_TARGET
#define DIFFICULTY_TARGET_V6
#define FINAL_SUBSIDY_PER_MINUTE
#define EMISSION_SPEED_FACTOR_PER_MINUTE_V8
#define ETN_SUPPLY
#define MERROR(x)
Definition misc_log_ex.h:73
size_t get_min_block_weight(uint8_t version)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_config()

const config_t & cryptonote::get_config ( network_type nettype)
inline

Definition at line 266 of file cryptonote_config.h.

267 {
268 static const config_t mainnet = {
278 };
279 static const config_t testnet = {
289 };
290 static const config_t stagenet = {
300 };
301 switch (nettype)
302 {
303 case MAINNET: return mainnet;
304 case TESTNET: return testnet;
305 case STAGENET: return stagenet;
306 case FAKECHAIN: return mainnet;
307 default: throw std::runtime_error("Invalid network type");
308 }
309 };
boost::uuids::uuid const NETWORK_ID
uint32_t const GENESIS_NONCE
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint16_t const ZMQ_RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
uint16_t const P2P_DEFAULT_PORT
uint16_t const RPC_DEFAULT_PORT
std::string const GENESIS_TX
uint16_t const ZMQ_RPC_DEFAULT_PORT
uint16_t const RPC_DEFAULT_PORT
boost::uuids::uuid const NETWORK_ID
uint32_t const GENESIS_NONCE
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint16_t const P2P_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
std::string const GENESIS_TX
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
std::string const GENESIS_TX
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
uint16_t const RPC_DEFAULT_PORT
boost::uuids::uuid const NETWORK_ID
uint32_t const GENESIS_NONCE
uint16_t const ZMQ_RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
uint16_t const P2P_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Here is the caller graph for this function:

◆ get_default_decimal_point()

unsigned int cryptonote::get_default_decimal_point ( )

Definition at line 964 of file cryptonote_format_utils.cpp.

965 {
966 return default_decimal_point;
967 }

◆ get_destination_view_key_pub()

crypto::public_key cryptonote::get_destination_view_key_pub ( const std::vector< tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr )

Definition at line 200 of file cryptonote_tx_utils.cpp.

201 {
203 size_t count = 0;
204 for (const auto &i : destinations)
205 {
206 if (i.amount == 0)
207 continue;
208 if (change_addr && i.addr == *change_addr)
209 continue;
210 if (i.addr == addr)
211 continue;
212 if (count > 0)
213 return null_pkey;
214 addr = i.addr;
215 ++count;
216 }
217 if (count == 0 && change_addr)
218 return change_addr->m_view_public_key;
219 return addr.m_view_public_key;
220 }
const crypto::public_key null_pkey
Definition crypto.cpp:72

◆ get_encrypted_payment_id_from_tx_extra_nonce()

bool cryptonote::get_encrypted_payment_id_from_tx_extra_nonce ( const blobdata & extra_nonce,
crypto::hash8 & payment_id )

Definition at line 712 of file cryptonote_format_utils.cpp.

713 {
714 if(sizeof(crypto::hash8) + 1 != extra_nonce.size())
715 return false;
716 if (TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID != extra_nonce[0])
717 return false;
718 payment_id = *reinterpret_cast<const crypto::hash8*>(extra_nonce.data() + 1);
719 return true;
720 }
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID
Definition tx_extra.h:49
Here is the caller graph for this function:

◆ get_hash_stats()

void cryptonote::get_hash_stats ( uint64_t & tx_hashes_calculated,
uint64_t & tx_hashes_cached,
uint64_t & block_hashes_calculated,
uint64_t & block_hashes_cached )

Definition at line 1338 of file cryptonote_format_utils.cpp.

1339 {
1340 tx_hashes_calculated = tx_hashes_calculated_count;
1341 tx_hashes_cached = tx_hashes_cached_count;
1342 block_hashes_calculated = block_hashes_calculated_count;
1343 block_hashes_cached = block_hashes_cached_count;
1344 }

◆ get_inputs_etn_amount()

bool cryptonote::get_inputs_etn_amount ( const transaction & tx,
uint64_t & etn )

Definition at line 722 of file cryptonote_format_utils.cpp.

723 {
724 etn = 0;
725 if(tx.version == 1 || tx.version == 2) {
726 for(const auto& in: tx.vin)
727 {
728 CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
729 etn += tokey_in.amount;
730 }
731 }
732 else //tx.version >= 3 (public transactions: can spend only new inputs)
733 {
734 for(const auto& in: tx.vin)
735 {
736 CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key_public, tokey_in, false);
737 etn += tokey_in.amount;
738 }
739 }
740
741 return true;
742 }
Here is the caller graph for this function:

◆ get_max_tx_size()

size_t cryptonote::get_max_tx_size ( )

Definition at line 86 of file cryptonote_basic_impl.cpp.

87 {
89 }
#define CRYPTONOTE_MAX_TX_SIZE

◆ get_min_block_weight()

size_t cryptonote::get_min_block_weight ( uint8_t version)

Definition at line 73 of file cryptonote_basic_impl.cpp.

74 {
75 if (version < 2)
77 if (version < 5)
79 if (version < 8)
81 if (version < 10)
84 }
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V8
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V10
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_multisig_blinded_secret_key()

crypto::secret_key cryptonote::get_multisig_blinded_secret_key ( const crypto::secret_key & key)

Definition at line 47 of file multisig.cpp.

48 {
49 rct::keyV data;
50 data.reserve(2);
51 data.push_back(rct::sk2rct(key));
52 data.push_back(multisig_salt);
53 crypto::secret_key result = rct::rct2sk(rct::hash_to_scalar(data));
54 memwipe(&data[0], sizeof(rct::key));
55 return result;
56 }
void * memwipe(void *src, size_t n)
void hash_to_scalar(key &hash, const void *data, const std::size_t l)
Definition rctOps.cpp:536
std::vector< key > keyV
Definition rctTypes.h:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_blobsize()

template<class t_object>
size_t cryptonote::get_object_blobsize ( const t_object & o)

Definition at line 185 of file cryptonote_format_utils.h.

186 {
188 return b.size();
189 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_hash() [1/2]

template<class t_object>
bool cryptonote::get_object_hash ( const t_object & o,
crypto::hash & res )

Definition at line 178 of file cryptonote_format_utils.h.

179 {
181 return true;
182 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_object_hash() [2/2]

template<class t_object>
bool cryptonote::get_object_hash ( const t_object & o,
crypto::hash & res,
size_t & blob_size )

Definition at line 192 of file cryptonote_format_utils.h.

193 {
195 blob_size = bl.size();
196 get_blob_hash(bl, res);
197 return true;
198 }
Here is the call graph for this function:

◆ get_outs_etn_amount()

uint64_t cryptonote::get_outs_etn_amount ( const transaction & tx)

Definition at line 845 of file cryptonote_format_utils.cpp.

846 {
847 uint64_t outputs_amount = 0;
848 for(const auto& o: tx.vout)
849 outputs_amount += o.amount;
850 return outputs_amount;
851 }
Here is the caller graph for this function:

◆ get_payment_id_from_tx_extra_nonce()

bool cryptonote::get_payment_id_from_tx_extra_nonce ( const blobdata & extra_nonce,
crypto::hash & payment_id )

Definition at line 702 of file cryptonote_format_utils.cpp.

703 {
704 if(sizeof(crypto::hash) + 1 != extra_nonce.size())
705 return false;
706 if(TX_EXTRA_NONCE_PAYMENT_ID != extra_nonce[0])
707 return false;
708 payment_id = *reinterpret_cast<const crypto::hash*>(extra_nonce.data() + 1);
709 return true;
710 }
#define TX_EXTRA_NONCE_PAYMENT_ID
Definition tx_extra.h:48
Here is the caller graph for this function:

◆ get_protocol_state_char()

◆ get_protocol_state_string()

std::string cryptonote::get_protocol_state_string ( cryptonote_connection_context::state s)
inline

Definition at line 72 of file connection_context.h.

73 {
74 switch (s)
75 {
77 return "before_handshake";
79 return "synchronizing";
81 return "standby";
83 return "idle";
85 return "normal";
86 default:
87 return "unknown";
88 }
89 }

◆ get_pruned_transaction_hash()

crypto::hash cryptonote::get_pruned_transaction_hash ( const transaction & t,
const crypto::hash & pruned_data_hash )

Definition at line 1057 of file cryptonote_format_utils.cpp.

1058 {
1059 // v1 transactions hash the entire blob
1060 CHECK_AND_ASSERT_THROW_MES(t.version > 1, "Hash for pruned v1 tx cannot be calculated");
1061
1062 // v2 transactions hash different parts together, than hash the set of those hashes
1064
1065 // prefix
1067
1068 transaction &tt = const_cast<transaction&>(t);
1069
1070 // base rct
1071 {
1072 std::stringstream ss;
1073 binary_archive<true> ba(ss);
1074 const size_t inputs = t.vin.size();
1075 const size_t outputs = t.vout.size();
1076 bool r = tt.rct_signatures.serialize_rctsig_base(ba, inputs, outputs);
1077 CHECK_AND_ASSERT_THROW_MES(r, "Failed to serialize rct signatures base");
1078 cryptonote::get_blob_hash(ss.str(), hashes[1]);
1079 }
1080
1081 // prunable rct
1083 hashes[2] = crypto::null_hash;
1084 else
1085 hashes[2] = pruned_data_hash;
1086
1087 // the tx hash is the hash of the 3 hashes
1089 return res;
1090 }
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition rctTypes.h:251
Here is the call graph for this function:

◆ get_transaction_hash() [1/4]

crypto::hash cryptonote::get_transaction_hash ( const transaction & t)

Definition at line 1012 of file cryptonote_format_utils.cpp.

1013 {
1014 crypto::hash h = null_hash;
1015 get_transaction_hash(t, h, NULL);
1016 CHECK_AND_ASSERT_THROW_MES(get_transaction_hash(t, h, NULL), "Failed to calculate transaction hash");
1017 return h;
1018 }
Here is the call graph for this function:

◆ get_transaction_hash() [2/4]

bool cryptonote::get_transaction_hash ( const transaction & t,
crypto::hash & res )

Definition at line 1020 of file cryptonote_format_utils.cpp.

1021 {
1022 return get_transaction_hash(t, res, NULL);
1023 }
Here is the call graph for this function:

◆ get_transaction_hash() [3/4]

bool cryptonote::get_transaction_hash ( const transaction & t,
crypto::hash & res,
size_t & blob_size )

Definition at line 1176 of file cryptonote_format_utils.cpp.

1177 {
1178 return get_transaction_hash(t, res, &blob_size);
1179 }
Here is the call graph for this function:

◆ get_transaction_hash() [4/4]

bool cryptonote::get_transaction_hash ( const transaction & t,
crypto::hash & res,
size_t * blob_size )

Definition at line 1142 of file cryptonote_format_utils.cpp.

1143 {
1144 if (t.is_hash_valid())
1145 {
1146#ifdef ENABLE_HASH_CASH_INTEGRITY_CHECK
1147 CHECK_AND_ASSERT_THROW_MES(!calculate_transaction_hash(t, res, blob_size) || t.hash == res, "tx hash cash integrity failure");
1148#endif
1149 res = t.hash;
1150 if (blob_size)
1151 {
1152 if (!t.is_blob_size_valid())
1153 {
1155 t.set_blob_size_valid(true);
1156 }
1157 *blob_size = t.blob_size;
1158 }
1159 ++tx_hashes_cached_count;
1160 return true;
1161 }
1162 ++tx_hashes_calculated_count;
1163 bool ret = calculate_transaction_hash(t, res, blob_size);
1164 if (!ret)
1165 return false;
1166 t.hash = res;
1167 t.set_hash_valid(true);
1168 if (blob_size)
1169 {
1170 t.blob_size = *blob_size;
1171 t.set_blob_size_valid(true);
1172 }
1173 return true;
1174 }
void set_hash_valid(bool v) const
bool calculate_transaction_hash(const transaction &t, crypto::hash &res, size_t *blob_size)
size_t get_object_blobsize(const t_object &o)
Here is the call graph for this function:

◆ get_transaction_prefix_hash() [1/2]

crypto::hash cryptonote::get_transaction_prefix_hash ( const transaction_prefix & tx)

Definition at line 121 of file cryptonote_format_utils.cpp.

122 {
123 crypto::hash h = null_hash;
125 return h;
126 }
Here is the call graph for this function:

◆ get_transaction_prefix_hash() [2/2]

void cryptonote::get_transaction_prefix_hash ( const transaction_prefix & tx,
crypto::hash & h )

Definition at line 112 of file cryptonote_format_utils.cpp.

113 {
114 std::ostringstream s;
117
118 crypto::cn_fast_hash(s.str().data(), s.str().size(), h);
119 }
bool serialize(Archive &ar, T &v)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_transaction_prunable_hash()

crypto::hash cryptonote::get_transaction_prunable_hash ( const transaction & t,
const cryptonote::blobdata * blobdata )

Definition at line 1050 of file cryptonote_format_utils.cpp.

1051 {
1053 CHECK_AND_ASSERT_THROW_MES(calculate_transaction_prunable_hash(t, blobdata, res), "Failed to calculate tx prunable hash");
1054 return res;
1055 }
Here is the call graph for this function:

◆ get_transaction_weight() [1/2]

uint64_t cryptonote::get_transaction_weight ( const transaction & tx)

Definition at line 352 of file cryptonote_format_utils.cpp.

353 {
354 size_t blob_size;
355 if (tx.is_blob_size_valid())
356 {
357 blob_size = tx.blob_size;
358 }
359 else
360 {
361 std::ostringstream s;
363 ::serialization::serialize(a, const_cast<transaction&>(tx));
364 blob_size = s.str().size();
365 }
366 return get_transaction_weight(tx, blob_size);
367 }
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
Here is the call graph for this function:

◆ get_transaction_weight() [2/2]

uint64_t cryptonote::get_transaction_weight ( const transaction & tx,
size_t blob_size )

Definition at line 347 of file cryptonote_format_utils.cpp.

348 {
349 return blob_size;
350 }
Here is the caller graph for this function:

◆ get_tx_fee() [1/2]

uint64_t cryptonote::get_tx_fee ( const transaction & tx)

Definition at line 394 of file cryptonote_format_utils.cpp.

395 {
396 uint64_t r = 0;
397 if(!get_tx_fee(tx, r))
398 return 0;
399 return r;
400 }
bool get_tx_fee(const transaction &tx, uint64_t &fee)
Here is the call graph for this function:

◆ get_tx_fee() [2/2]

bool cryptonote::get_tx_fee ( const transaction & tx,
uint64_t & fee )

Definition at line 369 of file cryptonote_format_utils.cpp.

370 {
371 uint64_t amount_in = 0;
372 uint64_t amount_out = 0;
373 for(auto& in: tx.vin)
374 {
375 CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key) || in.type() == typeid(txin_to_key_public), 0, "unexpected type id in transaction");
376
377 if(tx.version == 1 || tx.version == 2)
378 {
379 amount_in += boost::get<txin_to_key>(in).amount;
380 }
381 else
382 {
383 amount_in += boost::get<txin_to_key_public>(in).amount;
384 }
385 }
386 for(auto& o: tx.vout)
387 amount_out += o.amount;
388
389 CHECK_AND_ASSERT_MES(amount_in >= amount_out, false, "transaction spend (" <<amount_in << ") more than it has (" << amount_out << ")");
390 fee = amount_in - amount_out;
391 return true;
392 }
Here is the caller graph for this function:

◆ get_tx_pub_key_from_extra() [1/3]

crypto::public_key cryptonote::get_tx_pub_key_from_extra ( const std::vector< uint8_t > & tx_extra,
size_t pk_index )

Definition at line 518 of file cryptonote_format_utils.cpp.

519 {
520 std::vector<tx_extra_field> tx_extra_fields;
521 parse_tx_extra(tx_extra, tx_extra_fields);
522
523 tx_extra_pub_key pub_key_field;
524 if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index))
525 return null_pkey;
526
527 return pub_key_field.pub_key;
528 }
crypto::public_key pub_key
Definition tx_extra.h:102
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_tx_pub_key_from_extra() [2/3]

crypto::public_key cryptonote::get_tx_pub_key_from_extra ( const transaction & tx,
size_t pk_index )

Definition at line 535 of file cryptonote_format_utils.cpp.

536 {
537 return get_tx_pub_key_from_extra(tx.extra, pk_index);
538 }
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
Here is the call graph for this function:

◆ get_tx_pub_key_from_extra() [3/3]

crypto::public_key cryptonote::get_tx_pub_key_from_extra ( const transaction_prefix & tx_prefix,
size_t pk_index )

Definition at line 530 of file cryptonote_format_utils.cpp.

531 {
532 return get_tx_pub_key_from_extra(tx_prefix.extra, pk_index);
533 }
Here is the call graph for this function:

◆ get_tx_tree_hash() [1/3]

crypto::hash cryptonote::get_tx_tree_hash ( const block & b)

Definition at line 1318 of file cryptonote_format_utils.cpp.

1319 {
1320 std::vector<crypto::hash> txs_ids;
1321 txs_ids.reserve(1 + b.tx_hashes.size());
1322 crypto::hash h = null_hash;
1323 size_t bl_sz = 0;
1324 CHECK_AND_ASSERT_THROW_MES(get_transaction_hash(b.miner_tx, h, bl_sz), "Failed to calculate transaction hash");
1325 txs_ids.push_back(h);
1326 for(auto& th: b.tx_hashes)
1327 txs_ids.push_back(th);
1328 return get_tx_tree_hash(txs_ids);
1329 }
Here is the call graph for this function:

◆ get_tx_tree_hash() [2/3]

crypto::hash cryptonote::get_tx_tree_hash ( const std::vector< crypto::hash > & tx_hashes)

Definition at line 1311 of file cryptonote_format_utils.cpp.

1312 {
1313 crypto::hash h = null_hash;
1314 get_tx_tree_hash(tx_hashes, h);
1315 return h;
1316 }
Here is the call graph for this function:

◆ get_tx_tree_hash() [3/3]

void cryptonote::get_tx_tree_hash ( const std::vector< crypto::hash > & tx_hashes,
crypto::hash & h )

Definition at line 1306 of file cryptonote_format_utils.cpp.

1307 {
1308 tree_hash(tx_hashes.data(), tx_hashes.size(), h);
1309 }
void tree_hash(const char(*hashes)[HASH_SIZE], size_t count, char *root_hash)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unit()

std::string cryptonote::get_unit ( unsigned int decimal_point)

Definition at line 969 of file cryptonote_format_utils.cpp.

970 {
971 if (decimal_point == (unsigned int)-1)
972 decimal_point = default_decimal_point;
973 switch (decimal_point)
974 {
975 case 2:
976 return "electroneum";
977 case 0:
978 return "ecent";
979 default:
980 ASSERT_MES_AND_THROW("Invalid decimal point specification: " << decimal_point);
981 }
982 }
#define ASSERT_MES_AND_THROW(message)

◆ getpos() [1/2]

template<>
unsigned int cryptonote::getpos ( binary_archive< false > & ar)
inline

Definition at line 243 of file cryptonote_basic.h.

243{ return ar.stream().tellg(); }
stream_type & stream()

◆ getpos() [2/2]

template<>
unsigned int cryptonote::getpos ( binary_archive< true > & ar)
inline

Definition at line 242 of file cryptonote_basic.h.

242{ return ar.stream().tellp(); }

◆ hex()

std::string cryptonote::hex ( difficulty_type v)

Definition at line 254 of file difficulty.cpp.

255 {
256 static const char chars[] = "0123456789abcdef";
257 std::string s;
258 while (v > 0)
259 {
260 s.push_back(chars[(v & 0xf).convert_to<unsigned>()]);
261 v >>= 4;
262 }
263 if (s.empty())
264 s += "0";
265 std::reverse(s.begin(), s.end());
266 return "0x" + s;
267 }

◆ is_coinbase()

bool cryptonote::is_coinbase ( const transaction & tx)

Definition at line 232 of file cryptonote_basic_impl.cpp.

233 {
234 if(tx.vin.size() != 1)
235 return false;
236
237 if(tx.vin[0].type() != typeid(txin_gen))
238 return false;
239
240 return true;
241 }
Here is the caller graph for this function:

◆ is_out_to_acc()

bool cryptonote::is_out_to_acc ( const account_keys & acc,
const txout_to_key & out_key,
const crypto::public_key & tx_pub_key,
const std::vector< crypto::public_key > & additional_tx_pub_keys,
size_t output_index )

Definition at line 862 of file cryptonote_format_utils.cpp.

863 {
864 crypto::key_derivation derivation;
865 bool r = acc.get_device().generate_key_derivation(tx_pub_key, acc.m_view_secret_key, derivation);
866 CHECK_AND_ASSERT_MES(r, false, "Failed to generate key derivation");
869 CHECK_AND_ASSERT_MES(r, false, "Failed to derive public key");
870 if (pk == out_key.key)
871 return true;
872 // try additional tx pubkeys if available
873 if (!additional_tx_pub_keys.empty())
874 {
875 CHECK_AND_ASSERT_MES(output_index < additional_tx_pub_keys.size(), false, "wrong number of additional tx pubkeys");
876 r = acc.get_device().generate_key_derivation(additional_tx_pub_keys[output_index], acc.m_view_secret_key, derivation);
877 CHECK_AND_ASSERT_MES(r, false, "Failed to generate key derivation");
879 CHECK_AND_ASSERT_MES(r, false, "Failed to derive public key");
880 return pk == out_key.key;
881 }
882 return false;
883 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_out_to_acc_precomp()

boost::optional< subaddress_receive_info > cryptonote::is_out_to_acc_precomp ( const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
const crypto::public_key & out_key,
const crypto::key_derivation & derivation,
const std::vector< crypto::key_derivation > & additional_derivations,
size_t output_index,
hw::device & hwdev )

Definition at line 885 of file cryptonote_format_utils.cpp.

886 {
887 // try the shared tx pubkey
888 crypto::public_key subaddress_spendkey;
889 hwdev.derive_subaddress_public_key(out_key, derivation, output_index, subaddress_spendkey);
890 auto found = subaddresses.find(subaddress_spendkey);
891 if (found != subaddresses.end())
892 return subaddress_receive_info{ found->second, derivation };
893 // try additional tx pubkeys if available
894 if (!additional_derivations.empty())
895 {
896 CHECK_AND_ASSERT_MES(output_index < additional_derivations.size(), boost::none, "wrong number of additional derivations");
897 hwdev.derive_subaddress_public_key(out_key, additional_derivations[output_index], output_index, subaddress_spendkey);
898 found = subaddresses.find(subaddress_spendkey);
899 if (found != subaddresses.end())
900 return subaddress_receive_info{ found->second, additional_derivations[output_index] };
901 }
902 return boost::none;
903 }
virtual bool derive_subaddress_public_key(const crypto::public_key &pub, const crypto::key_derivation &derivation, const std::size_t output_index, crypto::public_key &derived_pub)=0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_out_to_acc_precomp_public()

boost::optional< subaddress_receive_info > cryptonote::is_out_to_acc_precomp_public ( const std::unordered_map< crypto::public_key, subaddress_index > & subaddresses,
const cryptonote::account_public_address output_address )

Definition at line 905 of file cryptonote_format_utils.cpp.

906 {
907 crypto::public_key subaddress_spendkey = output_address.m_spend_public_key;
908 auto found = subaddresses.find(subaddress_spendkey);
909 if (found != subaddresses.end()){
910 return subaddress_receive_info{found->second, {}};
911 }
912 return boost::none;
913 }

◆ is_v1_tx() [1/2]

bool cryptonote::is_v1_tx ( const blobdata & tx_blob)

Definition at line 203 of file cryptonote_format_utils.cpp.

204 {
205 return is_v1_tx(blobdata_ref{tx_blob.data(), tx_blob.size()});
206 }
epee::span< const char > blobdata_ref

◆ is_v1_tx() [2/2]

bool cryptonote::is_v1_tx ( const blobdata_ref & tx_blob)

Definition at line 190 of file cryptonote_format_utils.cpp.

191 {
192 //TODO: Public - assure return true. Build logic for prunable v2/v3 tx data later.
193 return true;
194
196 const char* begin = static_cast<const char*>(tx_blob.data());
197 const char* end = begin + tx_blob.size();
198 int read = tools::read_varint(begin, end, version);
199 if (read <= 0)
200 throw std::runtime_error("Internal error getting transaction version");
201 }
std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&0<=bits &&bits<=std::numeric_limits< T >::digits, int >::type read_varint(InputIt &&first, InputIt &&last, T &write)
reads in the varint that is pointed to by InputIt into write
Definition varint.h:95
Here is the call graph for this function:

◆ is_valid_decomposed_amount()

bool cryptonote::is_valid_decomposed_amount ( uint64_t amount)

Definition at line 1331 of file cryptonote_format_utils.cpp.

1332 {
1333 const uint64_t *begin = valid_decomposed_outputs;
1334 const uint64_t *end = valid_decomposed_outputs + sizeof(valid_decomposed_outputs) / sizeof(valid_decomposed_outputs[0]);
1335 return std::binary_search(begin, end, amount);
1336 }
Here is the caller graph for this function:

◆ lmdb_resized()

void cryptonote::lmdb_resized ( MDB_env * env)

Definition at line 502 of file db_lmdb.cpp.

503{
505
506 MGINFO("LMDB map resize detected.");
507
508 MDB_envinfo mei;
509
510 mdb_env_info(env, &mei);
511 uint64_t old = mei.me_mapsize;
512
514
515 int result = mdb_env_set_mapsize(env, 0);
516 if (result)
517 throw0(DB_ERROR(lmdb_error("Failed to set new mapsize: ", result).c_str()));
518
519 mdb_env_info(env, &mei);
520 uint64_t new_mapsize = mei.me_mapsize;
521
522 MGINFO("LMDB Mapsize increased." << " Old: " << old / (1024 * 1024) << "MiB" << ", New: " << new_mapsize / (1024 * 1024) << "MiB");
523
525}
A generic BlockchainDB exception.
int mdb_env_info(MDB_env *env, MDB_envinfo *stat)
Return information about the LMDB environment.
int mdb_env_set_mapsize(MDB_env *env, mdb_size_t size)
Set the size of the memory map to use for this environment.
mdb_size_t me_mapsize
Definition lmdb.h:503
#define MGINFO(x)
Definition misc_log_ex.h:80
Information about the environment.
Definition lmdb.h:501
static void prevent_new_txns()
Definition db_lmdb.cpp:487
static void allow_new_txns()
Definition db_lmdb.cpp:497
static void wait_no_active_txns()
Definition db_lmdb.cpp:492
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lmdb_txn_begin()

int cryptonote::lmdb_txn_begin ( MDB_env * env,
MDB_txn * parent,
unsigned int flags,
MDB_txn ** txn )
inline

Definition at line 527 of file db_lmdb.cpp.

528{
529 int res = mdb_txn_begin(env, parent, flags, txn);
530 if (res == MDB_MAP_RESIZED) {
531 lmdb_resized(env);
532 res = mdb_txn_begin(env, parent, flags, txn);
533 }
534 return res;
535}
#define MDB_MAP_RESIZED
Definition lmdb.h:465
int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
Create a transaction for use with the environment.
void lmdb_resized(MDB_env *env)
Definition db_lmdb.cpp:502
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lmdb_txn_renew()

int cryptonote::lmdb_txn_renew ( MDB_txn * txn)
inline

Definition at line 537 of file db_lmdb.cpp.

538{
539 int res = mdb_txn_renew(txn);
540 if (res == MDB_MAP_RESIZED) {
542 res = mdb_txn_renew(txn);
543 }
544 return res;
545}
int mdb_txn_renew(MDB_txn *txn)
Renew a read-only transaction.
MDB_env * mdb_txn_env(MDB_txn *txn)
Returns the transaction's MDB_env.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_acc_outs() [1/2]

bool cryptonote::lookup_acc_outs ( const account_keys & acc,
const transaction & tx,
const crypto::public_key & tx_pub_key,
const std::vector< crypto::public_key > & additional_tx_pub_keys,
std::vector< size_t > & outs,
uint64_t & etn_transfered )

Definition at line 924 of file cryptonote_format_utils.cpp.

925 {
926 CHECK_AND_ASSERT_MES(additional_tx_pub_keys.empty() || additional_tx_pub_keys.size() == tx.vout.size(), false, "wrong number of additional pubkeys" );
927 etn_transfered = 0;
928 size_t i = 0;
929 for(const tx_out& o: tx.vout)
930 {
931 CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_key), false, "wrong type id in transaction out" );
932 if(is_out_to_acc(acc, boost::get<txout_to_key>(o.target), tx_pub_key, additional_tx_pub_keys, i))
933 {
934 outs.push_back(i);
935 etn_transfered += o.amount;
936 }
937 i++;
938 }
939 return true;
940 }
bool is_out_to_acc(const account_keys &acc, const txout_to_key &out_key, const crypto::public_key &tx_pub_key, const std::vector< crypto::public_key > &additional_tx_pub_keys, size_t output_index)
txout_target_v target
Here is the call graph for this function:

◆ lookup_acc_outs() [2/2]

bool cryptonote::lookup_acc_outs ( const account_keys & acc,
const transaction & tx,
std::vector< size_t > & outs,
uint64_t & etn_transfered )

Definition at line 915 of file cryptonote_format_utils.cpp.

916 {
918 if(null_pkey == tx_pub_key)
919 return false;
920 std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
921 return lookup_acc_outs(acc, tx, tx_pub_key, additional_tx_pub_keys, outs, etn_transfered);
922 }
bool lookup_acc_outs(const account_keys &acc, const transaction &tx, std::vector< size_t > &outs, uint64_t &etn_transfered)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ max128bit()

const boost::multiprecision::uint256_t cryptonote::max128bit ( std::numeric_limits< boost::multiprecision::uint128_t > ::max())
Here is the caller graph for this function:

◆ max256bit()

const boost::multiprecision::uint512_t cryptonote::max256bit ( std::numeric_limits< boost::multiprecision::uint256_t > ::max())
Here is the caller graph for this function:

◆ max64bit()

const difficulty_type cryptonote::max64bit ( std::numeric_limits< std::uint64_t > ::max())
Here is the caller graph for this function:

◆ multisig_rounds_required()

uint32_t cryptonote::multisig_rounds_required ( uint32_t participants,
uint32_t threshold )

Definition at line 181 of file multisig.cpp.

182 {
183 CHECK_AND_ASSERT_THROW_MES(participants >= threshold, "participants must be greater or equal than threshold");
184 return participants - threshold + 1;
185 }
uint8_t threshold
Here is the caller graph for this function:

◆ new_db()

BlockchainDB * cryptonote::new_db ( const std::string & db_type)

Definition at line 107 of file blockchain_db.cpp.

108{
109 if (db_type == "lmdb")
110 return new BlockchainLMDB();
111#if defined(BERKELEY_DB)
112 if (db_type == "berkeley")
113 return new BlockchainBDB();
114#endif
115 return NULL;
116}
Here is the caller graph for this function:

◆ next_difficulty()

difficulty_type cryptonote::next_difficulty ( std::vector< uint64_t > timestamps,
std::vector< difficulty_type > cumulative_difficulties,
size_t target_seconds,
uint8_t version )

Definition at line 210 of file difficulty.cpp.

210 {
211
212 const size_t difficultyWindow = version == 6 ? DIFFICULTY_WINDOW_V6 : DIFFICULTY_WINDOW;
213
214 //cutoff DIFFICULTY_LAG
215 if(timestamps.size() > difficultyWindow)
216 {
217 timestamps.resize(difficultyWindow);
218 cumulative_difficulties.resize(difficultyWindow);
219 }
220
221
222 size_t length = timestamps.size();
223 assert(length == cumulative_difficulties.size());
224 if (length <= 1) {
225 return 1;
226 }
227 static_assert(DIFFICULTY_WINDOW >= 2, "Window is too small");
228 static_assert(DIFFICULTY_WINDOW_V6 >= 2, "Window is too small");
229 assert(length <= difficultyWindow);
230 sort(timestamps.begin(), timestamps.end());
231 size_t cut_begin, cut_end;
232 static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Cut length is too large");
233 static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW_V6 - 2, "Cut length is too large");
234 if (length <= difficultyWindow - 2 * DIFFICULTY_CUT) {
235 cut_begin = 0;
236 cut_end = length;
237 } else {
238 cut_begin = (length - (difficultyWindow - 2 * DIFFICULTY_CUT) + 1) / 2;
239 cut_end = cut_begin + (difficultyWindow - 2 * DIFFICULTY_CUT);
240 }
241 assert(/*cut_begin >= 0 &&*/ cut_begin + 2 <= cut_end && cut_end <= length);
242 uint64_t time_span = timestamps[cut_end - 1] - timestamps[cut_begin];
243 if (time_span == 0) {
244 time_span = 1;
245 }
246 difficulty_type total_work = cumulative_difficulties[cut_end - 1] - cumulative_difficulties[cut_begin];
247 assert(total_work > 0);
248 boost::multiprecision::uint256_t res = (boost::multiprecision::uint256_t(total_work) * target_seconds + time_span - 1) / time_span;
249 if(res > max128bit)
250 return 0; // to behave like previous implementation, may be better return max128bit?
251 return res.convert_to<difficulty_type>();
252 }
#define DIFFICULTY_WINDOW
#define DIFFICULTY_CUT
#define DIFFICULTY_WINDOW_V6
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:43
const boost::multiprecision::uint256_t max128bit(std::numeric_limits< boost::multiprecision::uint128_t >::max())
Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_difficulty_64()

uint64_t cryptonote::next_difficulty_64 ( std::vector< std::uint64_t > timestamps,
std::vector< uint64_t > cumulative_difficulties,
size_t target_seconds,
uint8_t version )

Definition at line 123 of file difficulty.cpp.

123 {
124
125 const size_t difficultyWindow = version == 6 ? DIFFICULTY_WINDOW_V6 : DIFFICULTY_WINDOW;
126
127 if(timestamps.size() > difficultyWindow)
128 {
129 timestamps.resize(difficultyWindow);
130 cumulative_difficulties.resize(difficultyWindow);
131 }
132
133 size_t length = timestamps.size();
134 assert(length == cumulative_difficulties.size());
135 if (length <= 1) {
136 return 1;
137 }
138
139 static_assert(DIFFICULTY_WINDOW >= 2, "Window is too small");
140 static_assert(DIFFICULTY_WINDOW_V6 >= 2, "Window is too small");
141 assert(length <= difficultyWindow);
142 sort(timestamps.begin(), timestamps.end());
143 size_t cut_begin, cut_end;
144
145 static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Cut length is too large");
146 static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW_V6 - 2, "Cut length is too large");
147
148 if (length <= difficultyWindow - 2 * DIFFICULTY_CUT) {
149 cut_begin = 0;
150 cut_end = length;
151 } else {
152 cut_begin = (length - (difficultyWindow - 2 * DIFFICULTY_CUT) + 1) / 2;
153 cut_end = cut_begin + (difficultyWindow - 2 * DIFFICULTY_CUT);
154 }
155 assert(/*cut_begin >= 0 &&*/ cut_begin + 2 <= cut_end && cut_end <= length);
156 uint64_t time_span = timestamps[cut_end - 1] - timestamps[cut_begin];
157 if (time_span == 0) {
158 time_span = 1;
159 }
160 uint64_t total_work = cumulative_difficulties[cut_end - 1] - cumulative_difficulties[cut_begin];
161 assert(total_work > 0);
162 uint64_t low, high;
163 mul(total_work, target_seconds, low, high);
164 // blockchain errors "difficulty overhead" if this function returns zero.
165 // TODO: consider throwing an exception instead
166 if (high != 0 || low + time_span - 1 < low) {
167 return 0;
168 }
169 return (low + time_span - 1) / time_span;
170 }
Here is the caller graph for this function:

◆ obj_to_json_str()

template<typename T>
std::string cryptonote::obj_to_json_str ( T & obj)

Definition at line 201 of file cryptonote_format_utils.h.

202 {
203 std::stringstream ss;
204 json_archive<true> ar(ss, true);
205 bool r = ::serialization::serialize(ar, obj);
206 CHECK_AND_ASSERT_MES(r, "", "obj_to_json_str failed: serialization::serialize returned false");
207 return ss.str();
208 }
a archive using the JSON standard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<()

std::ostream & cryptonote::operator<< ( std::ostream & out,
const cryptonote::subaddress_index & subaddr_index )
inline

Definition at line 59 of file subaddress_index.h.

60 {
61 return out << subaddr_index.major << '/' << subaddr_index.minor;
62 }

◆ operator==() [1/2]

bool cryptonote::operator== ( const cryptonote::block & a,
const cryptonote::block & b )

Definition at line 367 of file cryptonote_basic_impl.cpp.

Here is the call graph for this function:

◆ operator==() [2/2]

bool cryptonote::operator== ( const cryptonote::transaction & a,
const cryptonote::transaction & b )

Definition at line 363 of file cryptonote_basic_impl.cpp.

Here is the call graph for this function:

◆ parse_amount()

bool cryptonote::parse_amount ( uint64_t & amount,
const std::string & str_amount_ )

Definition at line 312 of file cryptonote_format_utils.cpp.

313 {
314 std::string str_amount = str_amount_;
315 boost::algorithm::trim(str_amount);
316
317 size_t point_index = str_amount.find_first_of('.');
318 size_t fraction_size;
319 if (std::string::npos != point_index)
320 {
321 fraction_size = str_amount.size() - point_index - 1;
322 while (default_decimal_point < fraction_size && '0' == str_amount.back())
323 {
324 str_amount.erase(str_amount.size() - 1, 1);
325 --fraction_size;
326 }
327 if (default_decimal_point < fraction_size)
328 return false;
329 str_amount.erase(point_index, 1);
330 }
331 else
332 {
333 fraction_size = 0;
334 }
335
336 if (str_amount.empty())
337 return false;
338
339 if (fraction_size < default_decimal_point)
340 {
341 str_amount.append(default_decimal_point - fraction_size, '0');
342 }
343
344 return string_tools::get_xtype_from_string(amount, str_amount);
345 }
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_and_validate_block_from_blob() [1/3]

bool cryptonote::parse_and_validate_block_from_blob ( const blobdata & b_blob,
block & b )

Definition at line 1276 of file cryptonote_format_utils.cpp.

1277 {
1278 return parse_and_validate_block_from_blob(b_blob, b, NULL);
1279 }
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b, crypto::hash *block_hash)
Here is the call graph for this function:

◆ parse_and_validate_block_from_blob() [2/3]

bool cryptonote::parse_and_validate_block_from_blob ( const blobdata & b_blob,
block & b,
crypto::hash & block_hash )

Definition at line 1281 of file cryptonote_format_utils.cpp.

1282 {
1283 return parse_and_validate_block_from_blob(b_blob, b, &block_hash);
1284 }
Here is the call graph for this function:

◆ parse_and_validate_block_from_blob() [3/3]

bool cryptonote::parse_and_validate_block_from_blob ( const blobdata & b_blob,
block & b,
crypto::hash * block_hash )

Definition at line 1257 of file cryptonote_format_utils.cpp.

1258 {
1259 std::stringstream ss;
1260 ss << b_blob;
1261 binary_archive<false> ba(ss);
1262 bool r = ::serialization::serialize(ba, b);
1263 CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob");
1266 if (block_hash)
1267 {
1268 calculate_block_hash(b, *block_hash, &b_blob);
1269 ++block_hashes_calculated_count;
1270 b.hash = *block_hash;
1271 b.set_hash_valid(true);
1272 }
1273 return true;
1274 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_and_validate_tx_base_from_blob()

bool cryptonote::parse_and_validate_tx_base_from_blob ( const blobdata & tx_blob,
transaction & tx )

Definition at line 146 of file cryptonote_format_utils.cpp.

147 {
148 std::stringstream ss;
149 ss << tx_blob;
151 bool r = tx.serialize_base(ba);
152 CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
153 CHECK_AND_ASSERT_MES(expand_transaction_1(tx, true), false, "Failed to expand transaction data");
155 return true;
156 }
bool expand_transaction_1(transaction &tx, bool base_only)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_and_validate_tx_from_blob() [1/3]

bool cryptonote::parse_and_validate_tx_from_blob ( const blobdata & tx_blob,
transaction & tx )

Definition at line 133 of file cryptonote_format_utils.cpp.

134 {
135 std::stringstream ss;
136 ss << tx_blob;
138 bool r = ::serialization::serialize(ba, tx);
139 CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
140 CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
142 tx.set_blob_size(tx_blob.size());
143 return true;
144 }
void set_blob_size(size_t sz)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_and_validate_tx_from_blob() [2/3]

bool cryptonote::parse_and_validate_tx_from_blob ( const blobdata & tx_blob,
transaction & tx,
crypto::hash & tx_hash )

Definition at line 168 of file cryptonote_format_utils.cpp.

169 {
170 std::stringstream ss;
171 ss << tx_blob;
173 bool r = ::serialization::serialize(ba, tx);
174 CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
175 CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
177 //TODO: validate tx
178
179 return get_transaction_hash(tx, tx_hash);
180 }
Here is the call graph for this function:

◆ parse_and_validate_tx_from_blob() [3/3]

bool cryptonote::parse_and_validate_tx_from_blob ( const blobdata & tx_blob,
transaction & tx,
crypto::hash & tx_hash,
crypto::hash & tx_prefix_hash )

Definition at line 182 of file cryptonote_format_utils.cpp.

183 {
184 if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash))
185 return false;
186 get_transaction_prefix_hash(tx, tx_prefix_hash);
187 return true;
188 }
Here is the call graph for this function:

◆ parse_and_validate_tx_prefix_from_blob()

bool cryptonote::parse_and_validate_tx_prefix_from_blob ( const blobdata & tx_blob,
transaction_prefix & tx )

Definition at line 158 of file cryptonote_format_utils.cpp.

159 {
160 std::stringstream ss;
161 ss << tx_blob;
163 bool r = ::serialization::serialize_noeof(ba, tx);
164 CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction prefix from blob");
165 return true;
166 }
bool serialize_noeof(Archive &ar, T &v)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_tx_extra()

bool cryptonote::parse_tx_extra ( const std::vector< uint8_t > & tx_extra,
std::vector< tx_extra_field > & tx_extra_fields )

Definition at line 402 of file cryptonote_format_utils.cpp.

403 {
404 tx_extra_fields.clear();
405
406 if(tx_extra.empty())
407 return true;
408
409 std::string extra_str(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size());
410 std::istringstream iss(extra_str);
411 binary_archive<false> ar(iss);
412
413 bool eof = false;
414 while (!eof)
415 {
416 tx_extra_field field;
417 bool r = ::do_serialize(ar, field);
418 CHECK_AND_NO_ASSERT_MES_L1(r, false, "failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
419 tx_extra_fields.push_back(field);
420
421 std::ios_base::iostate state = iss.rdstate();
422 eof = (EOF == iss.peek());
423 iss.clear(state);
424 }
425 CHECK_AND_NO_ASSERT_MES_L1(::serialization::check_stream_state(ar), false, "failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
426
427 return true;
428 }
bool check_stream_state(Archive &ar, bool noeof=false)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ power_integral()

uint64_t cryptonote::power_integral ( uint64_t a,
uint64_t b )

Definition at line 302 of file cryptonote_format_utils.cpp.

303 {
304 if(b == 0)
305 return 1;
306 uint64_t total = a;
307 for(uint64_t i = 1; i != b; i++)
308 total *= a;
309 return total;
310 }

◆ print_etn()

std::string cryptonote::print_etn ( uint64_t amount,
unsigned int decimal_point )

Definition at line 984 of file cryptonote_format_utils.cpp.

985 {
986 if (decimal_point == (unsigned int)-1)
987 decimal_point = default_decimal_point;
988 std::string s = std::to_string(amount);
989 if(s.size() < decimal_point+1)
990 {
991 s.insert(0, decimal_point+1 - s.size(), '0');
992 }
993 if (decimal_point > 0)
994 s.insert(s.size() - decimal_point, ".");
995 return s;
996 }
Here is the caller graph for this function:

◆ relative_output_offsets_to_absolute()

std::vector< uint64_t > cryptonote::relative_output_offsets_to_absolute ( const std::vector< uint64_t > & off)

Definition at line 1230 of file cryptonote_format_utils.cpp.

1231 {
1232 std::vector<uint64_t> res = off;
1233 for(size_t i = 1; i < res.size(); i++)
1234 res[i] += res[i-1];
1235 return res;
1236 }
Here is the caller graph for this function:

◆ remove_field_from_tx_extra()

bool cryptonote::remove_field_from_tx_extra ( std::vector< uint8_t > & tx_extra,
const std::type_info & type )

Definition at line 655 of file cryptonote_format_utils.cpp.

656 {
657 if (tx_extra.empty())
658 return true;
659 std::string extra_str(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size());
660 std::istringstream iss(extra_str);
661 binary_archive<false> ar(iss);
662 std::ostringstream oss;
663 binary_archive<true> newar(oss);
664
665 bool eof = false;
666 while (!eof)
667 {
668 tx_extra_field field;
669 bool r = ::do_serialize(ar, field);
670 CHECK_AND_NO_ASSERT_MES_L1(r, false, "failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
671 if (field.type() != type)
672 ::do_serialize(newar, field);
673
674 std::ios_base::iostate state = iss.rdstate();
675 eof = (EOF == iss.peek());
676 iss.clear(state);
677 }
678 CHECK_AND_NO_ASSERT_MES_L1(::serialization::check_stream_state(ar), false, "failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
679 tx_extra.clear();
680 std::string s = oss.str();
681 tx_extra.reserve(s.size());
682 std::copy(s.begin(), s.end(), std::back_inserter(tx_extra));
683 return true;
684 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_default_decimal_point()

void cryptonote::set_default_decimal_point ( unsigned int decimal_point)

Definition at line 952 of file cryptonote_format_utils.cpp.

953 {
954 switch (decimal_point)
955 {
956 case 2:
957 default_decimal_point = decimal_point;
958 break;
959 default:
960 ASSERT_MES_AND_THROW("Invalid decimal point specification: " << decimal_point);
961 }
962 }

◆ set_encrypted_payment_id_to_tx_extra_nonce()

void cryptonote::set_encrypted_payment_id_to_tx_extra_nonce ( blobdata & extra_nonce,
const crypto::hash8 & payment_id )

Definition at line 694 of file cryptonote_format_utils.cpp.

695 {
696 extra_nonce.clear();
697 extra_nonce.push_back(TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID);
698 const uint8_t* payment_id_ptr = reinterpret_cast<const uint8_t*>(&payment_id);
699 std::copy(payment_id_ptr, payment_id_ptr + sizeof(payment_id), std::back_inserter(extra_nonce));
700 }

◆ set_payment_id_to_tx_extra_nonce()

void cryptonote::set_payment_id_to_tx_extra_nonce ( blobdata & extra_nonce,
const crypto::hash & payment_id )

Definition at line 686 of file cryptonote_format_utils.cpp.

687 {
688 extra_nonce.clear();
689 extra_nonce.push_back(TX_EXTRA_NONCE_PAYMENT_ID);
690 const uint8_t* payment_id_ptr = reinterpret_cast<const uint8_t*>(&payment_id);
691 std::copy(payment_id_ptr, payment_id_ptr + sizeof(payment_id), std::back_inserter(extra_nonce));
692 }
Here is the caller graph for this function:

◆ short_hash_str()

std::string cryptonote::short_hash_str ( const crypto::hash & h)

Definition at line 853 of file cryptonote_format_utils.cpp.

854 {
855 std::string res = string_tools::pod_to_hex(h);
856 CHECK_AND_ASSERT_MES(res.size() == 64, res, "wrong hash256 with string_tools::pod_to_hex conversion");
857 auto erased_pos = res.erase(8, 48);
858 res.insert(8, "....");
859 return res;
860 }
Here is the call graph for this function:

◆ slow_memmem()

size_t cryptonote::slow_memmem ( const void * start_buff,
size_t buflen,
const void * pat,
size_t patlen )

Definition at line 1315 of file core_rpc_server.cpp.

1316 {
1317 const void* buf = start_buff;
1318 const void* end=(const char*)buf+buflen;
1319 if (patlen > buflen || patlen == 0) return 0;
1320 while(buflen>0 && (buf=memchr(buf,((const char*)pat)[0],buflen-patlen+1)))
1321 {
1322 if(memcmp(buf,pat,patlen)==0)
1323 return (const char*)buf - (const char*)start_buff;
1324 buf=(const char*)buf+1;
1325 buflen = (const char*)end - (const char*)buf;
1326 }
1327 return 0;
1328 }
size_t patlen
const char * pat
size_t buflen
const char * buf
Here is the caller graph for this function:

◆ sort_tx_extra() [1/2]

bool cryptonote::sort_tx_extra ( const std::vector< uint8_t > & tx_extra,
std::vector< uint8_t > & sorted_tx_extra,
bool allow_partial )

Definition at line 445 of file cryptonote_format_utils.cpp.

446 {
447 std::vector<tx_extra_field> tx_extra_fields;
448
449 if(tx_extra.empty())
450 {
451 sorted_tx_extra.clear();
452 return true;
453 }
454
455 std::string extra_str(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size());
456 std::istringstream iss(extra_str);
457 binary_archive<false> ar(iss);
458
459 bool eof = false;
460 size_t processed = 0;
461 while (!eof)
462 {
463 tx_extra_field field;
464 bool r = ::do_serialize(ar, field);
465 if (!r)
466 {
467 MWARNING("failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
468 if (!allow_partial)
469 return false;
470 break;
471 }
472 tx_extra_fields.push_back(field);
473 processed = iss.tellg();
474
475 std::ios_base::iostate state = iss.rdstate();
476 eof = (EOF == iss.peek());
477 iss.clear(state);
478 }
480 {
481 MWARNING("failed to deserialize extra field. extra = " << string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size())));
482 if (!allow_partial)
483 return false;
484 }
485 MTRACE("Sorted " << processed << "/" << tx_extra.size());
486
487 std::ostringstream oss;
488 binary_archive<true> nar(oss);
489
490 // sort by:
491 if (!pick<tx_extra_pub_key>(nar, tx_extra_fields, TX_EXTRA_TAG_PUBKEY)) return false;
492 if (!pick<tx_extra_additional_pub_keys>(nar, tx_extra_fields, TX_EXTRA_TAG_ADDITIONAL_PUBKEYS)) return false;
493 if (!pick<tx_extra_nonce>(nar, tx_extra_fields, TX_EXTRA_NONCE)) return false;
494 if (!pick<tx_extra_merge_mining_tag>(nar, tx_extra_fields, TX_EXTRA_MERGE_MINING_TAG)) return false;
495 if (!pick<tx_extra_bridge_source_address>(nar, tx_extra_fields, TX_EXTRA_TAG_BRIDGE_SOURCE_ADDRESS)) return false;
496 if (!pick<tx_extra_bridge_smartchain_address>(nar, tx_extra_fields, TX_EXTRA_TAG_BRIDGE_SMARTCHAIN_ADDRESS)) return false;
497 if (!pick<tx_extra_bridge_ownership_sig>(nar, tx_extra_fields, TX_EXTRA_TAG_BRIDGE_OWNERSHIP_SIG)) return false;
498 if (!pick<tx_extra_mysterious_minergate>(nar, tx_extra_fields, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG)) return false;
499 if (!pick<tx_extra_padding>(nar, tx_extra_fields, TX_EXTRA_TAG_PADDING)) return false;
500
501 // if not empty, someone added a new type and did not add a case above
502 if (!tx_extra_fields.empty())
503 {
504 MERROR("tx_extra_fields not empty after sorting, someone forgot to add a case above");
505 return false;
506 }
507
508 std::string oss_str = oss.str();
509 if (allow_partial && processed < tx_extra.size())
510 {
511 MDEBUG("Appending unparsed data");
512 oss_str += std::string((const char*)tx_extra.data() + processed, tx_extra.size() - processed);
513 }
514 sorted_tx_extra = std::vector<uint8_t>(oss_str.begin(), oss_str.end());
515 return true;
516 }
#define MTRACE(x)
Definition misc_log_ex.h:77
#define TX_EXTRA_TAG_PADDING
Definition tx_extra.h:38
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG
Definition tx_extra.h:46
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS
Definition tx_extra.h:42
#define TX_EXTRA_MERGE_MINING_TAG
Definition tx_extra.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort_tx_extra() [2/2]

bool cryptonote::sort_tx_extra ( const std::vector< uint8_t > & tx_extra,
std::vector< uint8_t > & sorted_tx_extra,
bool allow_partial = false )

◆ t_serializable_object_from_blob()

template<class t_object>
bool cryptonote::t_serializable_object_from_blob ( t_object & to,
const blobdata & b_blob )

Definition at line 150 of file cryptonote_format_utils.h.

151 {
152 std::stringstream ss;
153 ss << b_blob;
155 bool r = ::serialization::serialize(ba, to);
156 return r;
157 }
Here is the call graph for this function:

◆ t_serializable_object_to_blob() [1/2]

template<class t_object>
blobdata cryptonote::t_serializable_object_to_blob ( const t_object & to)

Definition at line 170 of file cryptonote_format_utils.h.

171 {
172 blobdata b;
174 return b;
175 }
Here is the call graph for this function:

◆ t_serializable_object_to_blob() [2/2]

template<class t_object>
bool cryptonote::t_serializable_object_to_blob ( const t_object & to,
blobdata & b_blob )

Definition at line 160 of file cryptonote_format_utils.h.

161 {
162 std::stringstream ss;
164 bool r = ::serialization::serialize(ba, const_cast<t_object&>(to));
165 b_blob = ss.str();
166 return r;
167 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tx_sanity_check()

bool cryptonote::tx_sanity_check ( Blockchain & blockchain,
const cryptonote::blobdata & tx_blob )

Definition at line 42 of file tx_sanity_check.cpp.

43{
45
47 {
48 MERROR("Failed to parse transaction");
49 return false;
50 }
51
53 {
54 MERROR("Transaction is coinbase");
55 return false;
56 }
57 std::set<uint64_t> rct_indices;
58 size_t n_indices = 0;
59
60 for (const auto &txin : tx.vin)
61 {
62 if (txin.type() != typeid(cryptonote::txin_to_key))
63 continue;
64 const cryptonote::txin_to_key &in_to_key = boost::get<cryptonote::txin_to_key>(txin);
65 if (in_to_key.amount != 0)
66 continue;
67 const std::vector<uint64_t> absolute = cryptonote::relative_output_offsets_to_absolute(in_to_key.key_offsets);
68 for (uint64_t offset: absolute)
69 rct_indices.insert(offset);
70 n_indices += in_to_key.key_offsets.size();
71 }
72
73 if (tx.version < 3 && n_indices <= 10)
74 {
75 MERROR("n_indices is only " << n_indices);
76 return true;
77 }
78
79 return true;
80}
std::vector< uint64_t > relative_output_offsets_to_absolute(const std::vector< uint64_t > &off)
bool is_coinbase(const transaction &tx)
std::vector< uint64_t > key_offsets
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tx_to_blob() [1/2]

blobdata cryptonote::tx_to_blob ( const transaction & tx)

Definition at line 1296 of file cryptonote_format_utils.cpp.

1297 {
1299 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tx_to_blob() [2/2]

bool cryptonote::tx_to_blob ( const transaction & tx,
blobdata & b_blob )

Definition at line 1301 of file cryptonote_format_utils.cpp.

1302 {
1303 return t_serializable_object_to_blob(tx, b_blob);
1304 }
Here is the call graph for this function:

Variable Documentation

◆ arg_addr_db_salvage

const command_line::arg_descriptor< bool, false > cryptonote::arg_addr_db_salvage
Initial value:
= {
"addr-db-salvage"
, "Try to salvage a addr tx database if it seems corrupted"
, false
}

Definition at line 101 of file blockchain_db.cpp.

101 {
102 "addr-db-salvage"
103, "Try to salvage a addr tx database if it seems corrupted"
104, false
105};

◆ arg_block_download_max_size

const command_line::arg_descriptor< size_t > cryptonote::arg_block_download_max_size
Initial value:
= {
"block-download-max-size"
, "Set maximum size of block download queue in bytes (0 for default)"
, 0
}

Definition at line 117 of file cryptonote_core.cpp.

117 {
118 "block-download-max-size"
119 , "Set maximum size of block download queue in bytes (0 for default)"
120 , 0
121 };

◆ arg_data_dir

const command_line::arg_descriptor< std::string, false, true, 2 > cryptonote::arg_data_dir
Initial value:
= {
"data-dir"
, "Specify data directory"
, [](std::array<bool, 2> testnet_stagenet, bool defaulted, std::string val)->std::string {
if (testnet_stagenet[0])
return (boost::filesystem::path(val) / "testnet").string();
else if (testnet_stagenet[1])
return (boost::filesystem::path(val) / "stagenet").string();
return val;
}
}
const command_line::arg_descriptor< bool, false > arg_testnet_on
const command_line::arg_descriptor< bool, false > arg_stagenet_on
std::string get_default_data_dir()
Returns the default data directory.
Definition util.cpp:600

Definition at line 96 of file cryptonote_core.cpp.

96 {
97 "data-dir"
98 , "Specify data directory"
101 , [](std::array<bool, 2> testnet_stagenet, bool defaulted, std::string val)->std::string {
102 if (testnet_stagenet[0])
103 return (boost::filesystem::path(val) / "testnet").string();
104 else if (testnet_stagenet[1])
105 return (boost::filesystem::path(val) / "stagenet").string();
106 return val;
107 }
108 };

◆ arg_db_salvage

const command_line::arg_descriptor< bool, false > cryptonote::arg_db_salvage
Initial value:
= {
"db-salvage"
, "Try to salvage a blockchain database if it seems corrupted"
, false
}

Definition at line 95 of file blockchain_db.cpp.

95 {
96 "db-salvage"
97, "Try to salvage a blockchain database if it seems corrupted"
98, false
99};

◆ arg_db_sync_mode

const command_line::arg_descriptor< std::string > cryptonote::arg_db_sync_mode
Initial value:
= {
"db-sync-mode"
, "Specify sync option, using format [safe|fast|fastest]:[sync|async]:[<nblocks_per_sync>[blocks]|<nbytes_per_sync>[bytes]]."
, "fast:async:250000000bytes"
}

Definition at line 90 of file blockchain_db.cpp.

90 {
91 "db-sync-mode"
92, "Specify sync option, using format [safe|fast|fastest]:[sync|async]:[<nblocks_per_sync>[blocks]|<nbytes_per_sync>[bytes]]."
93, "fast:async:250000000bytes"
94};

◆ arg_db_type

const command_line::arg_descriptor< std::string > cryptonote::arg_db_type
Initial value:
= {
"db-type"
, DEFAULT_DB_TYPE
}
std::string arg_db_type_description

Definition at line 85 of file blockchain_db.cpp.

85 {
86 "db-type"
88, DEFAULT_DB_TYPE
89};

◆ arg_db_type_description

std::string cryptonote::arg_db_type_description = "Specify database type, available: " + cryptonote::blockchain_db_types(", ")

Definition at line 84 of file blockchain_db.cpp.

◆ arg_disable_dns_checkpoints

const command_line::arg_descriptor<bool> cryptonote::arg_disable_dns_checkpoints
Initial value:
= {
"disable-dns-checkpoints"
, "Do not retrieve checkpoints from DNS"
}

Definition at line 113 of file cryptonote_core.cpp.

113 {
114 "disable-dns-checkpoints"
115 , "Do not retrieve checkpoints from DNS"
116 };

◆ arg_fallback_to_pow

const command_line::arg_descriptor< bool > cryptonote::arg_fallback_to_pow
Initial value:
= {
"fallback-to-pow"
, "Disables all Validator feature and fallback consensus to standard Proof-of-Work (CryptoNote V1)."
"This argument is a decentralization safety measure in case something happens with Electroneum Ltd"
"so that users can fork the network to Proof of Work. (Anti Meteor Feature)."
"Before using this flag, please determine whether or not you want to use a checkpoint for the PoW fork (--fallback-to-pow-checkpoint-hash and --fallback-to-pow-checkpoint-height)"
"Please note that this is only a temporary solution so that people can continue the chain in a sensible decentralised way immediately if Electroneum ceased to exist. Long term solutions are explained in our docs folder"
"***WARNING: IF YOU USE THIS ARGUMENT AND MINE BLOCKS AND LATER WISH TO RETURN TO THE TIP OF THE V8 *MODERATED* BLOCKCHAIN, YOU WILL HAVE TO MANUALLY POP BLOCKS BACK USING THE DAEMON (OR IMPORT) PROGRAM"
, false
}

Definition at line 223 of file cryptonote_core.cpp.

223 {
224 "fallback-to-pow"
225 , "Disables all Validator feature and fallback consensus to standard Proof-of-Work (CryptoNote V1)."
226 "This argument is a decentralization safety measure in case something happens with Electroneum Ltd"
227 "so that users can fork the network to Proof of Work. (Anti Meteor Feature)."
228 "Before using this flag, please determine whether or not you want to use a checkpoint for the PoW fork (--fallback-to-pow-checkpoint-hash and --fallback-to-pow-checkpoint-height)"
229 "Please note that this is only a temporary solution so that people can continue the chain in a sensible decentralised way immediately if Electroneum ceased to exist. Long term solutions are explained in our docs folder"
230 "***WARNING: IF YOU USE THIS ARGUMENT AND MINE BLOCKS AND LATER WISH TO RETURN TO THE TIP OF THE V8 *MODERATED* BLOCKCHAIN, YOU WILL HAVE TO MANUALLY POP BLOCKS BACK USING THE DAEMON (OR IMPORT) PROGRAM"
231 , false
232 };

◆ arg_fallback_to_pow_checkpoint_hash

const command_line::arg_descriptor< std::string > cryptonote::arg_fallback_to_pow_checkpoint_hash
Initial value:
= {
"fallback-to-pow-checkpoint-hash"
, "Used in conjunction with --fallback-to-pow. This flag allows you to specify the *hash* of a checkpoint that would mark the new beginning of the PoW chain agreed upon by the community"
, ""
}

Definition at line 240 of file cryptonote_core.cpp.

240 {
241 "fallback-to-pow-checkpoint-hash"
242 , "Used in conjunction with --fallback-to-pow. This flag allows you to specify the *hash* of a checkpoint that would mark the new beginning of the PoW chain agreed upon by the community"
243 , ""
244 };

◆ arg_fallback_to_pow_checkpoint_height

const command_line::arg_descriptor< uint64_t > cryptonote::arg_fallback_to_pow_checkpoint_height
Initial value:
= {
"fallback-to-pow-checkpoint-height"
, "Used in conjunction with --fallback-to-pow. This flag allows you to specify the *height* of a checkpoint that would mark the new beginning of the PoW chain agreed upon by the community"
, 0
}

Definition at line 234 of file cryptonote_core.cpp.

234 {
235 "fallback-to-pow-checkpoint-height"
236 , "Used in conjunction with --fallback-to-pow. This flag allows you to specify the *height* of a checkpoint that would mark the new beginning of the PoW chain agreed upon by the community"
237 , 0
238 };

◆ arg_fixed_difficulty

const command_line::arg_descriptor< difficulty_type > cryptonote::arg_fixed_difficulty
Initial value:
= {
"fixed-difficulty"
, "Fixed difficulty used for testing."
, 0
}

Definition at line 86 of file cryptonote_core.cpp.

86 {
87 "fixed-difficulty"
88 , "Fixed difficulty used for testing."
89 , 0
90 };

◆ arg_offline

const command_line::arg_descriptor< bool > cryptonote::arg_offline
Initial value:
= {
"offline"
, "Do not listen for peers, nor connect to any"
}

Definition at line 109 of file cryptonote_core.cpp.

109 {
110 "offline"
111 , "Do not listen for peers, nor connect to any"
112 };

◆ arg_regtest_on

const command_line::arg_descriptor< bool, false > cryptonote::arg_regtest_on
Initial value:
= {
"regtest"
, "Run in a regression testing mode."
, false
}

Definition at line 81 of file cryptonote_core.cpp.

81 {
82 "regtest"
83 , "Run in a regression testing mode."
84 , false
85 };

◆ arg_skip_block_sig_verification

const command_line::arg_descriptor< bool > cryptonote::arg_skip_block_sig_verification
Initial value:
= {
"ignore-bsig"
, "Ignore block signature & signatory verification. Used for testing."
, false
}

Definition at line 91 of file cryptonote_core.cpp.

91 {
92 "ignore-bsig"
93 , "Ignore block signature & signatory verification. Used for testing."
94 , false
95 };

◆ arg_stagenet_on

const command_line::arg_descriptor< bool, false > cryptonote::arg_stagenet_on
Initial value:
= {
"stagenet"
, "Run on stagenet. The wallet must be launched with --stagenet flag."
, false
}

Definition at line 76 of file cryptonote_core.cpp.

76 {
77 "stagenet"
78 , "Run on stagenet. The wallet must be launched with --stagenet flag."
79 , false
80 };

◆ arg_testnet_on

const command_line::arg_descriptor< bool, false > cryptonote::arg_testnet_on
Initial value:
= {
"testnet"
, "Run on testnet. The wallet must be launched with --testnet flag."
, false
}

Definition at line 71 of file cryptonote_core.cpp.

71 {
72 "testnet"
73 , "Run on testnet. The wallet must be launched with --testnet flag."
74 , false
75 };