Electroneum
cryptonote Namespace Reference

Holds cryptonote related classes and helpers. More...

Namespaces

 bootstrap
 
 json
 
 rpc
 

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  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  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  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_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  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_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_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...
 

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::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_tcore_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_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. More...
 
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 More...
 
typedef std::set< tx_by_fee_and_receive_time_entry, txComparesorted_tx_container
 container for sorting transactions by fee per unit size More...
 

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 }
 

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 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)
 
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 More...
 
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)
 
difficulty_type next_difficulty (std::vector< std::uint64_t > timestamps, std::vector< difficulty_type > cumulative_difficulties, size_t target_seconds, uint8_t version=1)
 
std::ostream & operator<< (std::ostream &out, const cryptonote::subaddress_index &subaddr_index)
 
const config_tget_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 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 More...
 
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) More...
 
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 More...
 
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< boolarg_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< boolarg_regtest_on
 
const command_line::arg_descriptor< difficulty_typearg_fixed_difficulty
 
const command_line::arg_descriptor< boolarg_skip_block_sig_verification
 
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
 
const command_line::arg_descriptor< boolarg_offline
 
const command_line::arg_descriptor< boolarg_disable_dns_checkpoints
 
const command_line::arg_descriptor< size_t > arg_block_download_max_size
 
const command_line::arg_descriptor< boolarg_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_outs_t

◆ 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

◆ 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 353 of file db_lmdb.cpp.

◆ mdb_block_info_1

◆ mdb_block_info_2

◆ mdb_block_info_3

◆ mdb_block_info_4

◆ mdb_rflags

◆ mdb_threadinfo

◆ mdb_txn_cursors

◆ outkey

◆ outtx

◆ 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 106 of file blockchain_db.h.

◆ txin_v

◆ txindex

◆ txout_target_v

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
prune_mode_prune 
prune_mode_update 
prune_mode_check 

Definition at line 2441 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,
82  db_nosync
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 244 of file cryptonote_config.h.

245  {
246  MAINNET = 0,
247  TESTNET,
248  STAGENET,
249  FAKECHAIN,
250  UNDEFINED = 255
251  };

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 1188 of file cryptonote_format_utils.cpp.

1189  {
1190  std::vector<uint64_t> res = off;
1191  if(!off.size())
1192  return res;
1193  std::sort(res.begin(), res.end());//just to be sure, actually it is already should be sorted
1194  for(size_t i = res.size()-1; i != 0; i--)
1195  res[i] -= res[i-1];
1196 
1197  return res;
1198  }
const char * res
Definition: hmac_keccak.cpp:41

◆ 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 572 of file cryptonote_format_utils.cpp.

573  {
574  // convert to variant
575  tx_extra_field field = tx_extra_additional_pub_keys{ additional_pub_keys };
576  // serialize
577  std::ostringstream oss;
578  binary_archive<true> ar(oss);
579  bool r = ::do_serialize(ar, field);
580  CHECK_AND_NO_ASSERT_MES_L1(r, false, "failed to serialize tx extra additional tx pub keys");
581  // append
582  std::string tx_extra_str = oss.str();
583  size_t pos = tx_extra.size();
584  tx_extra.resize(tx_extra.size() + tx_extra_str.size());
585  memcpy(&tx_extra[pos], tx_extra_str.data(), tx_extra_str.size());
586  return true;
587  }
void * memcpy(void *a, const void *b, size_t c)
#define CHECK_AND_NO_ASSERT_MES_L1(expr, fail_ret_val, message)
Definition: misc_log_ex.h:193
void do_serialize(boost::mpl::false_, Archive &a, epee::net_utils::network_address &na)
boost::variant< tx_extra_padding, tx_extra_pub_key, tx_extra_nonce, tx_extra_merge_mining_tag, tx_extra_additional_pub_keys, tx_extra_mysterious_minergate > tx_extra_field
Definition: tx_extra.h:187
::std::string string
Definition: gtest-port.h:1097
Here is the call 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 589 of file cryptonote_format_utils.cpp.

590  {
591  CHECK_AND_ASSERT_MES(extra_nonce.size() <= TX_EXTRA_NONCE_MAX_COUNT, false, "extra nonce could be 255 bytes max");
592  size_t start_pos = tx_extra.size();
593  tx_extra.resize(tx_extra.size() + 2 + extra_nonce.size());
594  //write tag
595  tx_extra[start_pos] = TX_EXTRA_NONCE;
596  //write len
597  ++start_pos;
598  tx_extra[start_pos] = static_cast<uint8_t>(extra_nonce.size());
599  //write data
600  ++start_pos;
601  memcpy(&tx_extra[start_pos], extra_nonce.data(), extra_nonce.size());
602  return true;
603  }
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:181
unsigned char uint8_t
Definition: stdint.h:124
#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 547 of file cryptonote_format_utils.cpp.

548  {
549  tx_extra.resize(tx_extra.size() + 1 + sizeof(crypto::public_key));
550  tx_extra[tx_extra.size() - 1 - sizeof(crypto::public_key)] = TX_EXTRA_TAG_PUBKEY;
551  *reinterpret_cast<crypto::public_key*>(&tx_extra[tx_extra.size() - sizeof(crypto::public_key)]) = tx_pub_key;
552  return true;
553  }
POD_CLASS public_key
Definition: crypto.h:76
#define TX_EXTRA_TAG_PUBKEY
Definition: tx_extra.h:39
Here is the caller graph for this function:

◆ 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 537 of file cryptonote_format_utils.cpp.

538  {
539  return add_tx_pub_key_to_extra(tx.extra, tx_pub_key);
540  }
bool add_tx_pub_key_to_extra(std::vector< uint8_t > &tx_extra, 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 542 of file cryptonote_format_utils.cpp.

543  {
544  return add_tx_pub_key_to_extra(tx.extra, tx_pub_key);
545  }
Here is the call graph for this function:

◆ block_to_blob() [1/2]

blobdata cryptonote::block_to_blob ( const block b)

Definition at line 1236 of file cryptonote_format_utils.cpp.

1237  {
1239  }
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 1241 of file cryptonote_format_utils.cpp.

1242  {
1243  return t_serializable_object_to_blob(b, b_blob);
1244  }
Here is the call graph for this function:

◆ blockchain_db_types()

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

Definition at line 70 of file blockchain_db.cpp.

71 {
72  int i;
73  std::string ret = "";
74  for (i=0; db_types[i]; i++)
75  {
76  if (i)
77  ret += sep;
78  ret += db_types[i];
79  }
80  return ret;
81 }
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 59 of file blockchain_db.cpp.

60 {
61  int i;
62  for (i=0; db_types[i]; i++)
63  {
64  if (db_types[i] == db_type)
65  return true;
66  }
67  return false;
68 }
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 1140 of file cryptonote_format_utils.cpp.

1141  {
1143  }
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  {
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 *)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
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 1042 of file cryptonote_format_utils.cpp.

1043  {
1044  // v1 transactions hash the entire blob
1045  if (t.version == 1)
1046  {
1047  size_t ignored_blob_size, &blob_size_ref = blob_size ? *blob_size : ignored_blob_size;
1048  return get_object_hash(t, res, blob_size_ref);
1049  }
1050 
1051  // v2 transactions hash different parts together, than hash the set of those hashes
1052  crypto::hash hashes[3];
1053 
1054  // prefix
1056 
1057  const blobdata blob = tx_to_blob(t);
1058  const unsigned int unprunable_size = t.unprunable_size;
1059  const unsigned int prefix_size = t.prefix_size;
1060 
1061  // base rct
1062  CHECK_AND_ASSERT_MES(prefix_size <= unprunable_size && unprunable_size <= blob.size(), false, "Inconsistent transaction prefix, unprunable and blob sizes");
1063  cryptonote::get_blob_hash(epee::span<const char>(blob.data() + prefix_size, unprunable_size - prefix_size), hashes[1]);
1064 
1065  // prunable rct
1066  if (t.rct_signatures.type == rct::RCTTypeNull)
1067  {
1068  hashes[2] = crypto::null_hash;
1069  }
1070  else
1071  {
1072  CHECK_AND_ASSERT_MES(calculate_transaction_prunable_hash(t, &blob, hashes[2]), false, "Failed to get tx prunable hash");
1073  }
1074 
1075  // the tx hash is the hash of the 3 hashes
1076  res = cn_fast_hash(hashes, sizeof(hashes));
1077 
1078  // we still need the size
1079  if (blob_size)
1080  {
1081  if (!t.is_blob_size_valid())
1082  {
1083  t.blob_size = blob.size();
1084  t.set_blob_size_valid(true);
1085  }
1086  *blob_size = t.blob_size;
1087  }
1088 
1089  return true;
1090  }
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)
bool tx_to_blob(const transaction &tx, blobdata &b_blob)
crypto::hash get_transaction_prefix_hash(const transaction_prefix &tx)
std::string blobdata
Definition: blobdatatype.h:39
@ 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 975 of file cryptonote_format_utils.cpp.

976  {
977  if (t.version == 1)
978  return false;
979  const unsigned int unprunable_size = t.unprunable_size;
980  if (blob && unprunable_size)
981  {
982  CHECK_AND_ASSERT_MES(unprunable_size <= blob->size(), false, "Inconsistent transaction unprunable and blob sizes");
983  cryptonote::get_blob_hash(epee::span<const char>(blob->data() + unprunable_size, blob->size() - unprunable_size), res);
984  }
985  else
986  {
987  transaction &tt = const_cast<transaction&>(t);
988  std::stringstream ss;
989  binary_archive<true> ba(ss);
990  const size_t inputs = t.vin.size();
991  const size_t outputs = t.vout.size();
992  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;
993  bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin);
994  CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable");
995  cryptonote::get_blob_hash(ss.str(), res);
996  }
997  return true;
998  }
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 753 of file cryptonote_format_utils.cpp.

754  {
755  return check_inputs_overflow(tx) && check_outs_overflow(tx);
756  }
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
Definition: difficulty.cpp:106
const difficulty_type max64bit(std::numeric_limits< std::uint64_t >::max())
bool check_hash_128(const crypto::hash &hash, difficulty_type difficulty)
Definition: difficulty.cpp:184
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_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:254
const boost::multiprecision::uint512_t max256bit(std::numeric_limits< boost::multiprecision::uint256_t >::max())
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 758 of file cryptonote_format_utils.cpp.

759  {
760  uint64_t etn = 0;
761  if(tx.version >= 3)
762  {
763  for(const auto& in: tx.vin)
764  {
765  CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key_public, tokey_in, false);
766  if(etn > tokey_in.amount + etn)
767  return false;
768  etn += tokey_in.amount;
769  }
770  return true;
771  }
772 
773  for(const auto& in: tx.vin)
774  {
775  CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
776  if(etn > tokey_in.amount + etn)
777  return false;
778  etn += tokey_in.amount;
779  }
780  return true;
781  }
#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 701 of file cryptonote_format_utils.cpp.

702  {
703  for(const auto& in: tx.vin)
704  {
705  if (tx.version == 1 || tx.version == 2)
706  {
707  CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), false, "wrong variant type: "
708  << in.type().name() << ", expected " << typeid(txin_to_key).name()
709  << ", in transaction id=" << get_transaction_hash(tx));
710  }
711  else //tx.version >= 3 (public transactions: can spend only new inputs)
712  {
713  CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key_public), false, "wrong variant type: "
714  << in.type().name() << ", expected " << typeid(txin_to_key_public).name()
715  << ", in transaction id=" << get_transaction_hash(tx));
716  }
717  }
718  return true;
719  }
bool get_transaction_hash(const transaction &t, crypto::hash &res, size_t &blob_size)
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 783 of file cryptonote_format_utils.cpp.

784  {
785  uint64_t etn = 0;
786  for(const auto& o: tx.vout)
787  {
788  if(etn > o.amount + etn)
789  return false;
790  etn += o.amount;
791  }
792  return true;
793  }
Here is the caller graph for this function:

◆ check_outs_valid()

bool cryptonote::check_outs_valid ( const transaction tx)

Definition at line 721 of file cryptonote_format_utils.cpp.

722  {
723  for(const tx_out& out: tx.vout)
724  {
725  if (tx.version == 1)
726  {
727  CHECK_AND_ASSERT_MES(out.target.type() == typeid(txout_to_key), false, "wrong variant type: "
728  << out.target.type().name() << ", expected " << typeid(txout_to_key).name()
729  << ", in transaction id=" << get_transaction_hash(tx));
730 
731  CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
732 
733  if(!check_key(boost::get<txout_to_key>(out.target).key))
734  return false;
735  }
736  else //tx.version >= 2 (public transactions: only new public outputs are allowed)
737  {
738  CHECK_AND_ASSERT_MES(out.target.type() == typeid(txout_to_key_public), false, "wrong variant type: "
739  << out.target.type().name() << ", expected " << typeid(txout_to_key_public).name()
740  << ", in transaction id=" << get_transaction_hash(tx));
741 
742  CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
743 
744  if(!check_key(boost::get<txout_to_key_public>(out.target).address.m_spend_public_key) ||
745  !check_key(boost::get<txout_to_key_public>(out.target).address.m_view_public_key))
746  return false;
747  }
748 
749  }
750  return true;
751  }
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool check_key(const public_key &key)
Definition: crypto.h:254
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 53 of file cryptonote_tx_utils.cpp.

54  {
55  num_stdaddresses = 0;
56  num_subaddresses = 0;
57  std::unordered_set<cryptonote::account_public_address> unique_dst_addresses;
58  for(const tx_destination_entry& dst_entr: destinations)
59  {
60  if (change_addr && dst_entr.addr == change_addr)
61  continue;
62  if (unique_dst_addresses.count(dst_entr.addr) == 0)
63  {
64  unique_dst_addresses.insert(dst_entr.addr);
65  if (dst_entr.is_subaddress)
66  {
67  ++num_subaddresses;
68  single_dest_subaddress = dst_entr.addr;
69  }
70  else
71  {
72  ++num_stdaddresses;
73  }
74  }
75  }
76  LOG_PRINT_L2("destinations include " << num_stdaddresses << " standard addresses and " << num_subaddresses << " subaddresses");
77  }
#define LOG_PRINT_L2(x)
Definition: misc_log_ex.h:101
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 79 of file cryptonote_tx_utils.cpp.

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

604  {
605  std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
606  subaddresses[sender_account_keys.m_account_address.m_spend_public_key] = {0,0};
607  crypto::secret_key tx_key;
608  std::vector<crypto::secret_key> additional_tx_keys;
609  std::vector<tx_destination_entry> destinations_copy = destinations;
610  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);
611  }
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_and_get_tx_key()

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 575 of file cryptonote_tx_utils.cpp.

576  {
577  hw::device &hwdev = sender_account_keys.get_device();
578  hwdev.open_tx(tx_key);
579  try {
580  // figure out if we need to make additional tx pubkeys
581  size_t num_stdaddresses = 0;
582  size_t num_subaddresses = 0;
583  account_public_address single_dest_subaddress;
584  classify_addresses(destinations, change_addr, num_stdaddresses, num_subaddresses, single_dest_subaddress);
585  bool need_additional_txkeys = num_subaddresses > 0 && (num_stdaddresses > 0 || num_subaddresses > 1);
586  if (need_additional_txkeys)
587  {
588  additional_tx_keys.clear();
589  for (const auto &d: destinations)
590  additional_tx_keys.push_back(keypair::generate(sender_account_keys.get_device()).sec);
591  }
592 
593  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);
594  hwdev.close_tx();
595  return r;
596  } catch(...) {
597  hwdev.close_tx();
598  throw;
599  }
600  }
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)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_with_tx_key()

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 220 of file cryptonote_tx_utils.cpp.

221  {
222  hw::device &hwdev = sender_account_keys.get_device();
223 
224  if (sources.empty())
225  {
226  LOG_ERROR("Empty sources");
227  return false;
228  }
229 
230  std::vector<rct::key> amount_keys;
231  //test tx is sent through this scope TWICE, once as a test and once for real... therefore we set null before each run.
232  tx.set_null_besides_version();
233  amount_keys.clear();
234  if (msout)
235  {
236  msout->c.clear();
237  }
238 
239  tx.unlock_time = unlock_time;
240 
241  tx.extra = extra;
242  crypto::public_key txkey_pub;
243 
244  // if we have a stealth payment id, find it and encrypt it with the tx key now
245  std::vector<tx_extra_field> tx_extra_fields;
246  if (parse_tx_extra(tx.extra, tx_extra_fields))
247  {
248  bool add_dummy_payment_id = true;
249  tx_extra_nonce extra_nonce;
250  if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
251  {
252  crypto::hash payment_id = null_hash;
253  crypto::hash8 payment_id8 = null_hash8;
254  if (get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8))
255  {
256  LOG_PRINT_L2("Adding cleartext payment ID to extra nonce. Encrypted PIDs are now deprecated." << payment_id8);
257 
258  std::string extra_nonce;
259 
260  memcpy(payment_id.data, payment_id8.data, 8); // convert short pid to regular
261  memset(payment_id.data + 8, 0, 24); // merely a sanity check
262 
263  set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
264  remove_field_from_tx_extra(tx.extra, typeid(tx_extra_nonce));
265  if (!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
266  {
267  LOG_ERROR("Failed to add payment id to tx extra");
268  return false;
269  }
270  LOG_PRINT_L1("Encrypted payment ID: " << payment_id8);
271  add_dummy_payment_id = false;
272  }
273  else if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id))
274  {
275  add_dummy_payment_id = false;
276  }
277  }
278 
279  // we don't add one if we've got more than the usual 1 destination plus change
280  if (destinations.size() > 2)
281  add_dummy_payment_id = false;
282 
283  if (add_dummy_payment_id)
284  {
285  std::string extra_nonce;
286  crypto::hash payment_id = null_hash;
287 
288  set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
289  if (!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
290  {
291  LOG_ERROR("Failed to add dummy payment id to tx extra");
292  // continue anyway
293  }
294  }
295  }
296  else
297  {
298  MWARNING("Failed to parse tx extra");
299  tx_extra_fields.clear();
300  }
301 
302  struct input_generation_context_data
303  {
304  keypair in_ephemeral;
305  };
306  std::vector<input_generation_context_data> in_contexts;
307 
308  uint64_t summary_inputs_etn = 0;
309  //fill inputs
310  int idx = -1;
311 
312  if(tx.version < 3) {
313  for (const tx_source_entry &src_entr : sources) {
314  ++idx;
315  if (src_entr.real_output >= src_entr.outputs.size()) {//
316  LOG_ERROR("real_output index (" << src_entr.real_output << ")bigger than output_keys.size()="
317  << src_entr.outputs.size());
318  return false;
319  }
320  summary_inputs_etn += src_entr.amount;
321 
322  //key_derivation recv_derivation;
323  in_contexts.push_back(input_generation_context_data());
324  // Tx output private key which gets its value assigned inside generate_key_image_helper
325  keypair &in_ephemeral = in_contexts.back().in_ephemeral;
326  crypto::key_image img;//
327  const auto &out_key = reinterpret_cast<const crypto::public_key &>(src_entr.outputs[src_entr.real_output].second.dest);
328  if (!generate_key_image_helper(sender_account_keys, subaddresses, out_key, src_entr.real_out_tx_key,
329  src_entr.real_out_additional_tx_keys, src_entr.real_output_in_tx_index,
330  in_ephemeral, img, hwdev, account_major_offset)) {
331  LOG_ERROR("Key image generation failed!");
332  return false;
333  }
334 
335  //check that derivated key is equal with real output key (if non multisig)
336  if (!msout && !(in_ephemeral.pub == src_entr.outputs[src_entr.real_output].second.dest)) {
337  LOG_ERROR("derived public key mismatch with output public key at index "
338  << idx << ", real out "
339  << src_entr.real_output << "! "
340  << ENDL << "derived_key:"
341  << string_tools::pod_to_hex(in_ephemeral.pub)
342  << ENDL
343  << "real output_public_key:"
344  << string_tools::pod_to_hex(src_entr.outputs[src_entr.real_output].second.dest));
345 
346  LOG_ERROR("amount " << src_entr.amount << ", rct " << src_entr.rct);
347  LOG_ERROR("tx pubkey " << src_entr.real_out_tx_key << ", real_output_in_tx_index "
348  << src_entr.real_output_in_tx_index);
349  return false;
350  }
351 
352  //put key image into tx input
353  txin_to_key input_to_key;
354  input_to_key.amount = src_entr.amount;
355  input_to_key.k_image = msout ? rct::rct2ki(src_entr.multisig_kLRki.ki) : img;
356 
357  //fill outputs array and use relative offsets
358  for (const tx_source_entry::output_entry &out_entry: src_entr.outputs)
359  input_to_key.key_offsets.push_back(out_entry.first);
360 
361  input_to_key.key_offsets = absolute_output_offsets_to_relative(input_to_key.key_offsets);
362  tx.vin.push_back(input_to_key);
363  }
364 
365  // sort ins by their key image
366  std::vector<size_t> ins_order(sources.size());
367  for (size_t n = 0; n < sources.size(); ++n)
368  ins_order[n] = n;
369  std::sort(ins_order.begin(), ins_order.end(), [&](const size_t i0, const size_t i1) {
370  const txin_to_key &tk0 = boost::get<txin_to_key>(tx.vin[i0]);
371  const txin_to_key &tk1 = boost::get<txin_to_key>(tx.vin[i1]);
372  return memcmp(&tk0.k_image, &tk1.k_image, sizeof(tk0.k_image)) > 0;
373  });
374  tools::apply_permutation(ins_order, [&] (size_t i0, size_t i1) {
375  std::swap(tx.vin[i0], tx.vin[i1]);
376  std::swap(in_contexts[i0], in_contexts[i1]);
377  std::swap(sources[i0], sources[i1]);
378  });
379 
380  if (shuffle_outs)
381  {
382  std::shuffle(destinations.begin(), destinations.end(), std::default_random_engine(crypto::rand<unsigned int>()));
383  }
384  } else{ // tx v3 onwards
385  for (const tx_source_entry &src_entr : sources) {
386  ++idx;
387  summary_inputs_etn += src_entr.amount;
388 
389  txin_to_key_public input;
390  input.amount = src_entr.amount;
391  input.tx_hash = src_entr.tx_hash;
392  input.relative_offset = src_entr.real_output_in_tx_index;
393 
394  tx.vin.push_back(input);
395  }
396  } //END OF WORK WITH INPUTS
397 
398  // figure out if we need to make additional tx pubkeys
399  size_t num_stdaddresses = 0;
400  size_t num_subaddresses = 0;
401  account_public_address single_dest_subaddress;
402  classify_addresses(destinations, change_addr, num_stdaddresses, num_subaddresses, single_dest_subaddress);
403 
404  // if this is a single-destination transfer to a subaddress, we set the tx pubkey to R=s*D
405  //todo: 4.0.0.0
406  if (num_stdaddresses == 0 && num_subaddresses == 1)
407  {
408  txkey_pub = rct::rct2pk(hwdev.scalarmultKey(rct::pk2rct(single_dest_subaddress.m_spend_public_key), rct::sk2rct(tx_key)));
409  }
410  else
411  {
412  txkey_pub = rct::rct2pk(hwdev.scalarmultBase(rct::sk2rct(tx_key)));
413  }
414  remove_field_from_tx_extra(tx.extra, typeid(tx_extra_pub_key));
415  add_tx_pub_key_to_extra(tx, txkey_pub);
416 
417  std::vector<crypto::public_key> additional_tx_public_keys;
418 
419  // we don't need to include additional tx keys if:
420  // - all the destinations are standard addresses
421  // - there's only one destination which is a subaddress
422  bool need_additional_txkeys = num_subaddresses > 0 && (num_stdaddresses > 0 || num_subaddresses > 1);
423  if (need_additional_txkeys)
424  CHECK_AND_ASSERT_MES(destinations.size() == additional_tx_keys.size(), false, "Wrong amount of additional tx keys");
425 
426  uint64_t summary_outs_etn = 0;
427  //fill outputs
428  size_t output_index = 0;
429  for (const tx_destination_entry &dst_entr: destinations) {
430  if(tx.version == 1) {
431  crypto::public_key out_eph_public_key;
432 
433  hwdev.generate_output_ephemeral_keys(tx.version, sender_account_keys, txkey_pub, tx_key,
434  dst_entr, change_addr, output_index,
435  need_additional_txkeys, additional_tx_keys,
436  additional_tx_public_keys, amount_keys, out_eph_public_key);
437 
438  tx_out out;
439  out.amount = dst_entr.amount;
440  txout_to_key tk;
441  tk.key = out_eph_public_key;
442  out.target = tk;
443  tx.vout.push_back(out);
444  output_index++;
445  summary_outs_etn += dst_entr.amount;
446  }else{
447  tx_out out;
448  out.amount = dst_entr.amount;
449  txout_to_key_public tkp;
450  tkp.address.m_view_public_key = dst_entr.addr.m_view_public_key;
451  tkp.address.m_spend_public_key = dst_entr.addr.m_spend_public_key;
452  tkp.m_address_prefix = dst_entr.is_subaddress ?
455  out.target = tkp;
456  tx.vout.push_back(out);
457  output_index++;
458  summary_outs_etn += dst_entr.amount;
459  }
460  }
461 
462  CHECK_AND_ASSERT_MES(additional_tx_public_keys.size() == additional_tx_keys.size(), false, "Internal error creating additional public keys");
463 
464  remove_field_from_tx_extra(tx.extra, typeid(tx_extra_additional_pub_keys));
465 
466  LOG_PRINT_L2("tx pubkey: " << txkey_pub);
467  if (need_additional_txkeys)
468  {
469  LOG_PRINT_L2("additional tx pubkeys: ");
470  for (size_t i = 0; i < additional_tx_public_keys.size(); ++i)
471  LOG_PRINT_L2(additional_tx_public_keys[i]);
472  add_additional_tx_pub_keys_to_extra(tx.extra, additional_tx_public_keys);
473  }
474 
475  if (!sort_tx_extra(tx.extra, tx.extra))
476  return false;
477 
478  //check etn
479  if(summary_outs_etn > summary_inputs_etn )
480  {
481  LOG_ERROR("Transaction inputs ETN ("<< summary_inputs_etn << ") less than outputs ETN (" << summary_outs_etn << ")");
482  return false;
483  }
484 
485  // check for watch only wallet
486  bool zero_secret_key = true;
487  for (size_t i = 0; i < sizeof(sender_account_keys.m_spend_secret_key); ++i)
488  zero_secret_key &= (sender_account_keys.m_spend_secret_key.data[i] == 0);
489  if (zero_secret_key)
490  {
491  MDEBUG("Null secret key, skipping signatures");
492  }
493 
494  //generate ring signatures
495  crypto::hash tx_prefix_hash;
496  hwdev.get_transaction_prefix_hash(tx, tx_prefix_hash);
497 
498  std::stringstream ss_ring_s;
499  size_t i = 0;
500 
501  if(tx.version < 3)
502  {
503  for(const tx_source_entry& src_entr: sources)
504  {
505  ss_ring_s << "pub_keys:" << ENDL;
506  std::vector<const crypto::public_key *> keys_ptrs;
507  std::vector<crypto::public_key> keys(src_entr.outputs.size());
508  size_t ii = 0;
509  for (const tx_source_entry::output_entry &o: src_entr.outputs) {
510  keys[ii] = rct2pk(o.second.dest);
511  keys_ptrs.push_back(&keys[ii]);
512  ss_ring_s << o.second.dest << ENDL;
513  ++ii;
514  }
515 
516  tx.signatures.push_back(std::vector<crypto::signature>());
517  std::vector<crypto::signature> &sigs = tx.signatures.back();
518  sigs.resize(src_entr.outputs.size());
519  if (!zero_secret_key)
520  hwdev.generate_ring_signature(tx_prefix_hash, boost::get<txin_to_key>(tx.vin[i]).k_image, keys_ptrs,
521  in_contexts[i].in_ephemeral.sec, src_entr.real_output, sigs.data());
522  ss_ring_s << "signatures:" << ENDL;
523  std::for_each(sigs.begin(), sigs.end(), [&](const crypto::signature &s) { ss_ring_s << s << ENDL; });
524  ss_ring_s << "prefix_hash:" << tx_prefix_hash << ENDL << "in_ephemeral_key: "
525  << in_contexts[i].in_ephemeral.sec << ENDL << "real_output: " << src_entr.real_output << ENDL;
526  i++;
527 
528  MCINFO("construct_tx",
529  "transaction_created: " << get_transaction_hash(tx) << ENDL << obj_to_json_str(tx) << ENDL
530  << ss_ring_s.str());
531  }
532  }
533  else
534  { //new public signatures for v3 onwards
535  for(uint64_t i = 0; i< tx.vin.size(); i++) {
537  std::vector<crypto::signature> signature_vec;
538  if (!zero_secret_key) {
539 
540  subaddress_index input_subaddress_index = sources[i].subaddr_index;
541  crypto::secret_key private_view_for_sig;
542  crypto::secret_key private_spend_for_sig;
543 
544  if (input_subaddress_index.major == 0 && input_subaddress_index.minor == 0) {
545  private_view_for_sig = sender_account_keys.m_view_secret_key;
546  private_spend_for_sig = sender_account_keys.m_spend_secret_key;
547  } else {
548  private_spend_for_sig = hwdev.get_subaddress_private_spendkey(sender_account_keys,
549  input_subaddress_index);
550  private_view_for_sig = hwdev.get_subaddress_private_viewkey(sender_account_keys.m_view_secret_key,
551  private_spend_for_sig);
552  }
553 
555  tx_prefix_hash,
556  i,
557  private_view_for_sig,
558  private_spend_for_sig,
559  signature
560  );
561  }
562  signature_vec.push_back(signature);
563  tx.signatures.push_back(signature_vec);
564  }
565 
566  MCINFO("construct_tx",
567  "transaction_created (v3): " << get_transaction_hash(tx) << ENDL << obj_to_json_str(tx));
568  }
569 
570  tx.invalidate_hashes();
571 
572  return true;
573  }
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
#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
Definition: misc_log_ex.h:149
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
POD_CLASS signature
Definition: crypto.h:108
POD_CLASS hash8
Definition: hash.h:53
POD_CLASS key_image
Definition: crypto.h:102
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 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)
crypto::hash get_transaction_hash(const transaction &t)
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)
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
void apply_permutation(std::vector< size_t > permutation, const F &swap)
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint64_t amount
Definition: chaingen.h:290
std::vector< key > c
Definition: rctTypes.h:112
Here is the call graph for this function:
Here is the caller 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 209 of file cryptonote_format_utils.h.

210  {
211  if (0 == amount)
212  {
213  return;
214  }
215 
216  bool is_dust_handled = false;
217  uint64_t dust = 0;
218  uint64_t order = 1;
219  while (0 != amount)
220  {
221  uint64_t chunk = (amount % 10) * order;
222  amount /= 10;
223  order *= 10;
224 
225  if (dust + chunk <= dust_threshold)
226  {
227  dust += chunk;
228  }
229  else
230  {
231  if (!is_dust_handled && 0 != dust)
232  {
233  dust_handler(dust);
234  is_dust_handled = true;
235  }
236  if (0 != chunk)
237  {
238  chunk_handler(chunk);
239  }
240  }
241  }
242 
243  if (!is_dust_handled && 0 != dust)
244  {
245  dust_handler(dust);
246  }
247  }
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 1304 of file cryptonote_format_utils.cpp.

1305  {
1307  crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
1308  sc_sub((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
1309  return key;
1310  }
const char * data() const noexcept
size_t size() const noexcept
void sc_sub(unsigned char *, const unsigned char *, const unsigned char *)
const char * key
Definition: hmac_keccak.cpp:39
void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant=0, uint64_t height=0)
Definition: hash.h:79
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 1296 of file cryptonote_format_utils.cpp.

1297  {
1299  crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
1300  sc_add((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
1301  return key;
1302  }
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 1873 of file cryptonote_core.cpp.

1874  {
1875  if (n <= 1)
1876  return 1.0;
1877  double f = n;
1878  while (n-- > 1)
1879  f *= n;
1880  return f;
1881  }

◆ 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 613 of file cryptonote_tx_utils.cpp.

618  {
619  //genesis block
620  bl = boost::value_initialized<block>();
621 
622 
623  account_public_address ac = boost::value_initialized<account_public_address>();
624  std::vector<size_t> sz;
625  construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
626  blobdata txb = tx_to_blob(bl.miner_tx);
627  std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
628 
629  std::string genesis_coinbase_tx_hex = genesis_tx;
630 
631  blobdata tx_bl;
632  bool r = string_tools::parse_hexstr_to_binbuff(genesis_tx, tx_bl);
633  CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
634  r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
635  CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
636  bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
637  bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
638  bl.timestamp = 0;
639  bl.nonce = nonce;
640  miner::find_nonce_for_given_block(bl, 1, 0);
641  bl.invalidate_hashes();
642  return true;
643  }
#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)
blobdata tx_to_blob(const transaction &tx)
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)
Definition: string_tools.h:92
std::string buff_to_hex_nodelimer(const std::string &src)
Definition: string_tools.h:87
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 
249  if (ack.m_spend_secret_key == crypto::null_skey)
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
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  {
164  crypto::key_image pki;
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;
90  crypto::secret_key blinded_skey = get_multisig_blinded_secret_key(keys.m_spend_secret_key);
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:322
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 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
77  crypto::secret_key blinded_skey = get_multisig_blinded_secret_key(keys.m_spend_secret_key);
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();
62  const crypto::secret_key spend_secret_key = get_multisig_blinded_secret_key(keys.m_spend_secret_key);
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)
Definition: misc_log_ex.h:173
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition: crypto.h:260
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 
215  return tools::base58::encode_addr(address_prefix, t_serializable_object_to_blob(adr));
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  {
250  uint64_t integrated_address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
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  {
287  integrated_address iadr;
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)
Definition: binary_utils.h:41
bool decode_addr(const std::string &addr, uint64_t &tag, std::string &data)
Definition: base58.cpp:238
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
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)
Definition: dns_utils.cpp:479
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  {
224  uint64_t integrated_address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
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 555 of file cryptonote_format_utils.cpp.

556  {
557  // parse
558  std::vector<tx_extra_field> tx_extra_fields;
559  parse_tx_extra(tx_extra, tx_extra_fields);
560  // find corresponding field
561  tx_extra_additional_pub_keys additional_pub_keys;
562  if(!find_tx_extra_field_by_type(tx_extra_fields, additional_pub_keys))
563  return {};
564  return additional_pub_keys.data;
565  }
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 567 of file cryptonote_format_utils.cpp.

568  {
569  return get_additional_tx_pub_keys_from_extra(tx.extra);
570  }
std::vector< crypto::public_key > get_additional_tx_pub_keys_from_extra(const transaction_prefix &tx)
Here is the caller graph for this function:

◆ get_blob_hash() [1/4]

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

Definition at line 948 of file cryptonote_format_utils.cpp.

949  {
950  crypto::hash h = null_hash;
951  get_blob_hash(blob, h);
952  return h;
953  }
crypto::hash get_blob_hash(const epee::span< const char > &blob)

◆ get_blob_hash() [2/4]

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

Definition at line 897 of file cryptonote_format_utils.cpp.

898  {
899  cn_fast_hash(blob.data(), blob.size(), res);
900  }
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 955 of file cryptonote_format_utils.cpp.

956  {
957  crypto::hash h = null_hash;
958  get_blob_hash(blob, h);
959  return h;
960  }

◆ get_blob_hash() [4/4]

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

Definition at line 892 of file cryptonote_format_utils.cpp.

893  {
894  cn_fast_hash(blob.data(), blob.size(), res);
895  }
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 1357 of file cryptonote_core.cpp.

1358  {
1359  block_complete_entry bce;
1360  bce.block = cryptonote::block_to_blob(b);
1361  for (const auto &tx_hash: b.tx_hashes)
1362  {
1363  cryptonote::blobdata txblob;
1364  CHECK_AND_ASSERT_THROW_MES(pool.get_transaction(tx_hash, txblob), "Transaction not found in pool");
1365  bce.txs.push_back(txblob);
1366  }
1367  return bce;
1368  }
blobdata block_to_blob(const block &b)
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 1165 of file cryptonote_format_utils.cpp.

1166  {
1167  crypto::hash p = null_hash;
1168  get_block_hash(b, p);
1169  return p;
1170  }
crypto::hash get_block_hash(uint64_t height)

◆ get_block_hash() [2/2]

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

Definition at line 1145 of file cryptonote_format_utils.cpp.

1146  {
1147  if (b.is_hash_valid())
1148  {
1149 #ifdef ENABLE_HASH_CASH_INTEGRITY_CHECK
1150  CHECK_AND_ASSERT_THROW_MES(!calculate_block_hash(b, res) || b.hash == res, "block hash cash integrity failure");
1151 #endif
1152  res = b.hash;
1153  ++block_hashes_cached_count;
1154  return true;
1155  }
1156  ++block_hashes_calculated_count;
1157  bool ret = calculate_block_hash(b, res);
1158  if (!ret)
1159  return false;
1160  b.hash = res;
1161  b.set_hash_valid(true);
1162  return true;
1163  }
bool calculate_block_hash(const block &b, crypto::hash &res, const blobdata *blob)
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 1131 of file cryptonote_format_utils.cpp.

1132  {
1133  blobdata blob = t_serializable_object_to_blob(static_cast<block_header>(b));
1134  crypto::hash tree_root_hash = get_tx_tree_hash(b);
1135  blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
1136  blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
1137  return blob;
1138  }
crypto::hash get_tx_tree_hash(const block &b)
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 694 of file cryptonote_format_utils.cpp.

695  {
696  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");
697  CHECKED_GET_SPECIFIC_VARIANT(b.miner_tx.vin[0], const txin_gen, coinbase_in, 0);
698  return coinbase_in.height;
699  }
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 1172 of file cryptonote_format_utils.cpp.

1173  {
1175  const int cn_variant = b.major_version == 6 ? b.major_version - 5 : 0; // Emergency HF so anti-asic is only if HF 6
1176  crypto::cn_slow_hash(bd.data(), bd.size(), res, cn_variant);
1177  return true;
1178  }
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 1200 of file cryptonote_format_utils.cpp.

1201  {
1202  crypto::hash p = null_hash;
1203  get_block_longhash(b, p, height);
1204  return p;
1205  }
crypto::hash get_block_longhash(const block &b, uint64_t height)

◆ 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  }
#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)
version
Supported socks variants.
Definition: socks.h:58
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 264 of file cryptonote_config.h.

265  {
266  static const config_t mainnet = {
276  };
277  static const config_t testnet = {
287  };
288  static const config_t stagenet = {
298  };
299  switch (nettype)
300  {
301  case MAINNET: return mainnet;
302  case TESTNET: return testnet;
303  case STAGENET: return stagenet;
304  case FAKECHAIN: return mainnet;
305  default: throw std::runtime_error("Invalid network type");
306  }
307  };
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
Here is the caller graph for this function:

◆ get_default_decimal_point()

unsigned int cryptonote::get_default_decimal_point ( )

Definition at line 914 of file cryptonote_format_utils.cpp.

915  {
916  return default_decimal_point;
917  }

◆ 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 198 of file cryptonote_tx_utils.cpp.

199  {
200  account_public_address addr = {null_pkey, null_pkey};
201  size_t count = 0;
202  for (const auto &i : destinations)
203  {
204  if (i.amount == 0)
205  continue;
206  if (change_addr && i.addr == *change_addr)
207  continue;
208  if (i.addr == addr)
209  continue;
210  if (count > 0)
211  return null_pkey;
212  addr = i.addr;
213  ++count;
214  }
215  if (count == 0 && change_addr)
216  return change_addr->m_view_public_key;
217  return addr.m_view_public_key;
218  }
const crypto::public_key null_pkey
Definition: crypto.cpp:72
mdb_size_t count(MDB_cursor *cur)
Here is the call graph for this function:

◆ 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 662 of file cryptonote_format_utils.cpp.

663  {
664  if(sizeof(crypto::hash8) + 1 != extra_nonce.size())
665  return false;
666  if (TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID != extra_nonce[0])
667  return false;
668  payment_id = *reinterpret_cast<const crypto::hash8*>(extra_nonce.data() + 1);
669  return true;
670  }
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID
Definition: tx_extra.h:46
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 1288 of file cryptonote_format_utils.cpp.

1289  {
1290  tx_hashes_calculated = tx_hashes_calculated_count;
1291  tx_hashes_cached = tx_hashes_cached_count;
1292  block_hashes_calculated = block_hashes_calculated_count;
1293  block_hashes_cached = block_hashes_cached_count;
1294  }

◆ get_inputs_etn_amount()

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

Definition at line 672 of file cryptonote_format_utils.cpp.

673  {
674  etn = 0;
675  if(tx.version == 1 || tx.version == 2) {
676  for(const auto& in: tx.vin)
677  {
678  CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
679  etn += tokey_in.amount;
680  }
681  }
682  else //tx.version >= 3 (public transactions: can spend only new inputs)
683  {
684  for(const auto& in: tx.vin)
685  {
686  CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key_public, tokey_in, false);
687  etn += tokey_in.amount;
688  }
689  }
690 
691  return true;
692  }
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 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 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 182 of file cryptonote_format_utils.h.

183  {
185  return b.size();
186  }
blobdata t_serializable_object_to_blob(const t_object &to)
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 175 of file cryptonote_format_utils.h.

176  {
178  return true;
179  }
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 189 of file cryptonote_format_utils.h.

190  {
192  blob_size = bl.size();
193  get_blob_hash(bl, res);
194  return true;
195  }
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 795 of file cryptonote_format_utils.cpp.

796  {
797  uint64_t outputs_amount = 0;
798  for(const auto& o: tx.vout)
799  outputs_amount += o.amount;
800  return outputs_amount;
801  }
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 652 of file cryptonote_format_utils.cpp.

653  {
654  if(sizeof(crypto::hash) + 1 != extra_nonce.size())
655  return false;
656  if(TX_EXTRA_NONCE_PAYMENT_ID != extra_nonce[0])
657  return false;
658  payment_id = *reinterpret_cast<const crypto::hash*>(extra_nonce.data() + 1);
659  return true;
660  }
#define TX_EXTRA_NONCE_PAYMENT_ID
Definition: tx_extra.h:45
Here is the caller graph for this function:

◆ get_protocol_state_char()

char cryptonote::get_protocol_state_char ( cryptonote_connection_context::state  s)
inline

Definition at line 91 of file connection_context.h.

92  {
93  switch (s)
94  {
95  case cryptonote_connection_context::state_before_handshake:
96  return 'h';
97  case cryptonote_connection_context::state_synchronizing:
98  return 's';
99  case cryptonote_connection_context::state_standby:
100  return 'w';
101  case cryptonote_connection_context::state_idle:
102  return 'i';
103  case cryptonote_connection_context::state_normal:
104  return 'n';
105  default:
106  return 'u';
107  }
108  }

◆ 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  {
76  case cryptonote_connection_context::state_before_handshake:
77  return "before_handshake";
78  case cryptonote_connection_context::state_synchronizing:
79  return "synchronizing";
80  case cryptonote_connection_context::state_standby:
81  return "standby";
82  case cryptonote_connection_context::state_idle:
83  return "idle";
84  case cryptonote_connection_context::state_normal:
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 1007 of file cryptonote_format_utils.cpp.

1008  {
1009  // v1 transactions hash the entire blob
1010  CHECK_AND_ASSERT_THROW_MES(t.version > 1, "Hash for pruned v1 tx cannot be calculated");
1011 
1012  // v2 transactions hash different parts together, than hash the set of those hashes
1013  crypto::hash hashes[3];
1014 
1015  // prefix
1017 
1018  transaction &tt = const_cast<transaction&>(t);
1019 
1020  // base rct
1021  {
1022  std::stringstream ss;
1023  binary_archive<true> ba(ss);
1024  const size_t inputs = t.vin.size();
1025  const size_t outputs = t.vout.size();
1026  bool r = tt.rct_signatures.serialize_rctsig_base(ba, inputs, outputs);
1027  CHECK_AND_ASSERT_THROW_MES(r, "Failed to serialize rct signatures base");
1028  cryptonote::get_blob_hash(ss.str(), hashes[1]);
1029  }
1030 
1031  // prunable rct
1032  if (t.rct_signatures.type == rct::RCTTypeNull)
1033  hashes[2] = crypto::null_hash;
1034  else
1035  hashes[2] = pruned_data_hash;
1036 
1037  // the tx hash is the hash of the 3 hashes
1039  return res;
1040  }
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 962 of file cryptonote_format_utils.cpp.

963  {
964  crypto::hash h = null_hash;
965  get_transaction_hash(t, h, NULL);
966  CHECK_AND_ASSERT_THROW_MES(get_transaction_hash(t, h, NULL), "Failed to calculate transaction hash");
967  return h;
968  }
Here is the caller graph for this function:

◆ get_transaction_hash() [2/4]

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

Definition at line 970 of file cryptonote_format_utils.cpp.

971  {
972  return get_transaction_hash(t, res, NULL);
973  }
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 1126 of file cryptonote_format_utils.cpp.

1127  {
1128  return get_transaction_hash(t, res, &blob_size);
1129  }
Here is the caller 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 1092 of file cryptonote_format_utils.cpp.

1093  {
1094  if (t.is_hash_valid())
1095  {
1096 #ifdef ENABLE_HASH_CASH_INTEGRITY_CHECK
1097  CHECK_AND_ASSERT_THROW_MES(!calculate_transaction_hash(t, res, blob_size) || t.hash == res, "tx hash cash integrity failure");
1098 #endif
1099  res = t.hash;
1100  if (blob_size)
1101  {
1102  if (!t.is_blob_size_valid())
1103  {
1104  t.blob_size = get_object_blobsize(t);
1105  t.set_blob_size_valid(true);
1106  }
1107  *blob_size = t.blob_size;
1108  }
1109  ++tx_hashes_cached_count;
1110  return true;
1111  }
1112  ++tx_hashes_calculated_count;
1113  bool ret = calculate_transaction_hash(t, res, blob_size);
1114  if (!ret)
1115  return false;
1116  t.hash = res;
1117  t.set_hash_valid(true);
1118  if (blob_size)
1119  {
1120  t.blob_size = *blob_size;
1121  t.set_blob_size_valid(true);
1122  }
1123  return true;
1124  }
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 caller 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;
116  ::serialization::serialize(a, const_cast<transaction_prefix&>(tx));
117 
118  crypto::cn_fast_hash(s.str().data(), s.str().size(), h);
119  }
void cn_fast_hash(const void *data, std::size_t length, hash &hash)
Definition: hash.h:69
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
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 1000 of file cryptonote_format_utils.cpp.

1001  {
1002  crypto::hash res;
1003  CHECK_AND_ASSERT_THROW_MES(calculate_transaction_prunable_hash(t, blobdata, res), "Failed to calculate tx prunable hash");
1004  return res;
1005  }
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)
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  }
uint64_t get_tx_fee(const transaction &tx)

◆ 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 515 of file cryptonote_format_utils.cpp.

516  {
517  std::vector<tx_extra_field> tx_extra_fields;
518  parse_tx_extra(tx_extra, tx_extra_fields);
519 
520  tx_extra_pub_key pub_key_field;
521  if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index))
522  return null_pkey;
523 
524  return pub_key_field.pub_key;
525  }
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 532 of file cryptonote_format_utils.cpp.

533  {
534  return get_tx_pub_key_from_extra(tx.extra, pk_index);
535  }
crypto::public_key get_tx_pub_key_from_extra(const transaction &tx, size_t pk_index)
Here is the caller 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 527 of file cryptonote_format_utils.cpp.

528  {
529  return get_tx_pub_key_from_extra(tx_prefix.extra, pk_index);
530  }
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 1268 of file cryptonote_format_utils.cpp.

1269  {
1270  std::vector<crypto::hash> txs_ids;
1271  txs_ids.reserve(1 + b.tx_hashes.size());
1272  crypto::hash h = null_hash;
1273  size_t bl_sz = 0;
1274  CHECK_AND_ASSERT_THROW_MES(get_transaction_hash(b.miner_tx, h, bl_sz), "Failed to calculate transaction hash");
1275  txs_ids.push_back(h);
1276  for(auto& th: b.tx_hashes)
1277  txs_ids.push_back(th);
1278  return get_tx_tree_hash(txs_ids);
1279  }
Here is the caller 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 1261 of file cryptonote_format_utils.cpp.

1262  {
1263  crypto::hash h = null_hash;
1264  get_tx_tree_hash(tx_hashes, h);
1265  return h;
1266  }

◆ 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 1256 of file cryptonote_format_utils.cpp.

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

◆ get_unit()

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

Definition at line 919 of file cryptonote_format_utils.cpp.

920  {
921  if (decimal_point == (unsigned int)-1)
922  decimal_point = default_decimal_point;
923  switch (decimal_point)
924  {
925  case 2:
926  return "electroneum";
927  case 0:
928  return "ecent";
929  default:
930  ASSERT_MES_AND_THROW("Invalid decimal point specification: " << decimal_point);
931  }
932  }
#define ASSERT_MES_AND_THROW(message)
Definition: misc_log_ex.h:172

◆ getpos() [1/2]

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

Definition at line 237 of file cryptonote_basic.h.

237 { return ar.stream().tellg(); }
stream_type & stream()
Here is the call graph for this function:

◆ getpos() [2/2]

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

Definition at line 236 of file cryptonote_basic.h.

236 { return ar.stream().tellp(); }
Here is the call graph for this function:

◆ 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 812 of file cryptonote_format_utils.cpp.

813  {
814  crypto::key_derivation derivation;
815  bool r = acc.get_device().generate_key_derivation(tx_pub_key, acc.m_view_secret_key, derivation);
816  CHECK_AND_ASSERT_MES(r, false, "Failed to generate key derivation");
818  r = acc.get_device().derive_public_key(derivation, output_index, acc.m_account_address.m_spend_public_key, pk);
819  CHECK_AND_ASSERT_MES(r, false, "Failed to derive public key");
820  if (pk == out_key.key)
821  return true;
822  // try additional tx pubkeys if available
823  if (!additional_tx_pub_keys.empty())
824  {
825  CHECK_AND_ASSERT_MES(output_index < additional_tx_pub_keys.size(), false, "wrong number of additional tx pubkeys");
826  r = acc.get_device().generate_key_derivation(additional_tx_pub_keys[output_index], acc.m_view_secret_key, derivation);
827  CHECK_AND_ASSERT_MES(r, false, "Failed to generate key derivation");
828  r = acc.get_device().derive_public_key(derivation, output_index, acc.m_account_address.m_spend_public_key, pk);
829  CHECK_AND_ASSERT_MES(r, false, "Failed to derive public key");
830  return pk == out_key.key;
831  }
832  return false;
833  }
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 835 of file cryptonote_format_utils.cpp.

836  {
837  // try the shared tx pubkey
838  crypto::public_key subaddress_spendkey;
839  hwdev.derive_subaddress_public_key(out_key, derivation, output_index, subaddress_spendkey);
840  auto found = subaddresses.find(subaddress_spendkey);
841  if (found != subaddresses.end())
842  return subaddress_receive_info{ found->second, derivation };
843  // try additional tx pubkeys if available
844  if (!additional_derivations.empty())
845  {
846  CHECK_AND_ASSERT_MES(output_index < additional_derivations.size(), boost::none, "wrong number of additional derivations");
847  hwdev.derive_subaddress_public_key(out_key, additional_derivations[output_index], output_index, subaddress_spendkey);
848  found = subaddresses.find(subaddress_spendkey);
849  if (found != subaddresses.end())
850  return subaddress_receive_info{ found->second, additional_derivations[output_index] };
851  }
852  return boost::none;
853  }
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 855 of file cryptonote_format_utils.cpp.

856  {
857  crypto::public_key subaddress_spendkey = output_address.m_spend_public_key;
858  auto found = subaddresses.find(subaddress_spendkey);
859  if (found != subaddresses.end()){
860  return subaddress_receive_info{found->second, {}};
861  }
862  return boost::none;
863  }

◆ 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  }
bool is_v1_tx(const blobdata &tx_blob)
epee::span< const char > blobdata_ref
Definition: blobdatatype.h:40
Here is the call graph for this function:

◆ 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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_valid_decomposed_amount()

bool cryptonote::is_valid_decomposed_amount ( uint64_t  amount)

Definition at line 1281 of file cryptonote_format_utils.cpp.

1282  {
1283  const uint64_t *begin = valid_decomposed_outputs;
1284  const uint64_t *end = valid_decomposed_outputs + sizeof(valid_decomposed_outputs) / sizeof(valid_decomposed_outputs[0]);
1285  return std::binary_search(begin, end, amount);
1286  }
Here is the caller graph for this function:

◆ lmdb_resized()

void cryptonote::lmdb_resized ( MDB_env env)

Definition at line 495 of file db_lmdb.cpp.

496 {
497  mdb_txn_safe::prevent_new_txns();
498 
499  MGINFO("LMDB map resize detected.");
500 
501  MDB_envinfo mei;
502 
503  mdb_env_info(env, &mei);
504  uint64_t old = mei.me_mapsize;
505 
506  mdb_txn_safe::wait_no_active_txns();
507 
508  int result = mdb_env_set_mapsize(env, 0);
509  if (result)
510  throw0(DB_ERROR(lmdb_error("Failed to set new mapsize: ", result).c_str()));
511 
512  mdb_env_info(env, &mei);
513  uint64_t new_mapsize = mei.me_mapsize;
514 
515  MGINFO("LMDB Mapsize increased." << " Old: " << old / (1024 * 1024) << "MiB" << ", New: " << new_mapsize / (1024 * 1024) << "MiB");
516 
517  mdb_txn_safe::allow_new_txns();
518 }
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
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 520 of file db_lmdb.cpp.

521 {
522  int res = mdb_txn_begin(env, parent, flags, txn);
523  if (res == MDB_MAP_RESIZED) {
524  lmdb_resized(env);
525  res = mdb_txn_begin(env, parent, flags, txn);
526  }
527  return res;
528 }
#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:495
Here is the caller graph for this function:

◆ lmdb_txn_renew()

int cryptonote::lmdb_txn_renew ( MDB_txn txn)
inline

Definition at line 530 of file db_lmdb.cpp.

531 {
532  int res = mdb_txn_renew(txn);
533  if (res == MDB_MAP_RESIZED) {
535  res = mdb_txn_renew(txn);
536  }
537  return res;
538 }
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 874 of file cryptonote_format_utils.cpp.

875  {
876  CHECK_AND_ASSERT_MES(additional_tx_pub_keys.empty() || additional_tx_pub_keys.size() == tx.vout.size(), false, "wrong number of additional pubkeys" );
877  etn_transfered = 0;
878  size_t i = 0;
879  for(const tx_out& o: tx.vout)
880  {
881  CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_key), false, "wrong type id in transaction out" );
882  if(is_out_to_acc(acc, boost::get<txout_to_key>(o.target), tx_pub_key, additional_tx_pub_keys, i))
883  {
884  outs.push_back(i);
885  etn_transfered += o.amount;
886  }
887  i++;
888  }
889  return true;
890  }
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)
Here is the call graph for this function:
Here is the caller 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 865 of file cryptonote_format_utils.cpp.

866  {
868  if(null_pkey == tx_pub_key)
869  return false;
870  std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
871  return lookup_acc_outs(acc, tx, tx_pub_key, additional_tx_pub_keys, outs, etn_transfered);
872  }
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)
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
Definition: blockchain.cpp:92

◆ new_db()

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

Definition at line 100 of file blockchain_db.cpp.

101 {
102  if (db_type == "lmdb")
103  return new BlockchainLMDB();
104 #if defined(BERKELEY_DB)
105  if (db_type == "berkeley")
106  return new BlockchainBDB();
107 #endif
108  return NULL;
109 }
Here is the caller graph for this function:

◆ next_difficulty() [1/2]

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

◆ next_difficulty() [2/2]

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  }

◆ obj_to_json_str()

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

Definition at line 198 of file cryptonote_format_utils.h.

199  {
200  std::stringstream ss;
201  json_archive<true> ar(ss, true);
202  bool r = ::serialization::serialize(ar, obj);
203  CHECK_AND_ASSERT_MES(r, "", "obj_to_json_str failed: serialization::serialize returned false");
204  return ss.str();
205  }
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.

367  {
369  }
bool get_block_hash(const block &b, crypto::hash &res)
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  }
std::string & trim(std::string &str)
Definition: string_tools.h:288
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Definition: string_tools.h:125
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 1226 of file cryptonote_format_utils.cpp.

1227  {
1228  return parse_and_validate_block_from_blob(b_blob, b, NULL);
1229  }
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 1231 of file cryptonote_format_utils.cpp.

1232  {
1233  return parse_and_validate_block_from_blob(b_blob, b, &block_hash);
1234  }
Here is the caller 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 1207 of file cryptonote_format_utils.cpp.

1208  {
1209  std::stringstream ss;
1210  ss << b_blob;
1211  binary_archive<false> ba(ss);
1212  bool r = ::serialization::serialize(ba, b);
1213  CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob");
1214  b.invalidate_hashes();
1215  b.miner_tx.invalidate_hashes();
1216  if (block_hash)
1217  {
1218  calculate_block_hash(b, *block_hash, &b_blob);
1219  ++block_hashes_calculated_count;
1220  b.hash = *block_hash;
1221  b.set_hash_valid(true);
1222  }
1223  return true;
1224  }
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;
150  binary_archive<false> ba(ss);
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");
154  tx.invalidate_hashes();
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;
137  binary_archive<false> ba(ss);
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");
141  tx.invalidate_hashes();
142  tx.set_blob_size(tx_blob.size());
143  return true;
144  }
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;
172  binary_archive<false> ba(ss);
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");
176  tx.invalidate_hashes();
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  }
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx, crypto::hash &tx_hash, crypto::hash &tx_prefix_hash)
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;
162  binary_archive<false> ba(ss);
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)
Definition: blake256.h:37
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 934 of file cryptonote_format_utils.cpp.

935  {
936  if (decimal_point == (unsigned int)-1)
937  decimal_point = default_decimal_point;
938  std::string s = std::to_string(amount);
939  if(s.size() < decimal_point+1)
940  {
941  s.insert(0, decimal_point+1 - s.size(), '0');
942  }
943  if (decimal_point > 0)
944  s.insert(s.size() - decimal_point, ".");
945  return s;
946  }
std::string to_string(t_connection_type type)
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 1180 of file cryptonote_format_utils.cpp.

1181  {
1182  std::vector<uint64_t> res = off;
1183  for(size_t i = 1; i < res.size(); i++)
1184  res[i] += res[i-1];
1185  return res;
1186  }
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 605 of file cryptonote_format_utils.cpp.

606  {
607  if (tx_extra.empty())
608  return true;
609  std::string extra_str(reinterpret_cast<const char*>(tx_extra.data()), tx_extra.size());
610  std::istringstream iss(extra_str);
611  binary_archive<false> ar(iss);
612  std::ostringstream oss;
613  binary_archive<true> newar(oss);
614 
615  bool eof = false;
616  while (!eof)
617  {
618  tx_extra_field field;
619  bool r = ::do_serialize(ar, field);
620  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())));
621  if (field.type() != type)
622  ::do_serialize(newar, field);
623 
624  std::ios_base::iostate state = iss.rdstate();
625  eof = (EOF == iss.peek());
626  iss.clear(state);
627  }
628  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())));
629  tx_extra.clear();
630  std::string s = oss.str();
631  tx_extra.reserve(s.size());
632  std::copy(s.begin(), s.end(), std::back_inserter(tx_extra));
633  return true;
634  }
void copy(key &AA, const key &A)
Definition: rctOps.h:79
Here is the call graph for this function:

◆ set_default_decimal_point()

void cryptonote::set_default_decimal_point ( unsigned int  decimal_point)

Definition at line 902 of file cryptonote_format_utils.cpp.

903  {
904  switch (decimal_point)
905  {
906  case 2:
907  default_decimal_point = decimal_point;
908  break;
909  default:
910  ASSERT_MES_AND_THROW("Invalid decimal point specification: " << decimal_point);
911  }
912  }

◆ 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 644 of file cryptonote_format_utils.cpp.

645  {
646  extra_nonce.clear();
647  extra_nonce.push_back(TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID);
648  const uint8_t* payment_id_ptr = reinterpret_cast<const uint8_t*>(&payment_id);
649  std::copy(payment_id_ptr, payment_id_ptr + sizeof(payment_id), std::back_inserter(extra_nonce));
650  }
Here is the call graph for this function:

◆ 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 636 of file cryptonote_format_utils.cpp.

637  {
638  extra_nonce.clear();
639  extra_nonce.push_back(TX_EXTRA_NONCE_PAYMENT_ID);
640  const uint8_t* payment_id_ptr = reinterpret_cast<const uint8_t*>(&payment_id);
641  std::copy(payment_id_ptr, payment_id_ptr + sizeof(payment_id), std::back_inserter(extra_nonce));
642  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ short_hash_str()

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

Definition at line 803 of file cryptonote_format_utils.cpp.

804  {
806  CHECK_AND_ASSERT_MES(res.size() == 64, res, "wrong hash256 with string_tools::pod_to_hex conversion");
807  auto erased_pos = res.erase(8, 48);
808  res.insert(8, "....");
809  return res;
810  }
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 1212 of file core_rpc_server.cpp.

1213  {
1214  const void* buf = start_buff;
1215  const void* end=(const char*)buf+buflen;
1216  if (patlen > buflen || patlen == 0) return 0;
1217  while(buflen>0 && (buf=memchr(buf,((const char*)pat)[0],buflen-patlen+1)))
1218  {
1219  if(memcmp(buf,pat,patlen)==0)
1220  return (const char*)buf - (const char*)start_buff;
1221  buf=(const char*)buf+1;
1222  buflen = (const char*)end - (const char*)buf;
1223  }
1224  return 0;
1225  }
size_t patlen
Definition: slow_memmem.cpp:75
const char * pat
Definition: slow_memmem.cpp:76
size_t buflen
Definition: slow_memmem.cpp:73
const char * buf
Definition: slow_memmem.cpp:74
Here is the caller graph for this function:

◆ sort_tx_extra()

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_mysterious_minergate>(nar, tx_extra_fields, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG)) return false;
496  if (!pick<tx_extra_padding>(nar, tx_extra_fields, TX_EXTRA_TAG_PADDING)) return false;
497 
498  // if not empty, someone added a new type and did not add a case above
499  if (!tx_extra_fields.empty())
500  {
501  MERROR("tx_extra_fields not empty after sorting, someone forgot to add a case above");
502  return false;
503  }
504 
505  std::string oss_str = oss.str();
506  if (allow_partial && processed < tx_extra.size())
507  {
508  MDEBUG("Appending unparsed data");
509  oss_str += std::string((const char*)tx_extra.data() + processed, tx_extra.size() - processed);
510  }
511  sorted_tx_extra = std::vector<uint8_t>(oss_str.begin(), oss_str.end());
512  return true;
513  }
#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:43
#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:

◆ 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 147 of file cryptonote_format_utils.h.

148  {
149  std::stringstream ss;
150  ss << b_blob;
151  binary_archive<false> ba(ss);
152  bool r = ::serialization::serialize(ba, to);
153  return r;
154  }
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 167 of file cryptonote_format_utils.h.

168  {
169  blobdata b;
171  return b;
172  }
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 157 of file cryptonote_format_utils.h.

158  {
159  std::stringstream ss;
160  binary_archive<true> ba(ss);
161  bool r = ::serialization::serialize(ba, const_cast<t_object&>(to));
162  b_blob = ss.str();
163  return r;
164  }
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 1246 of file cryptonote_format_utils.cpp.

1247  {
1248  return t_serializable_object_to_blob(tx);
1249  }
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 1251 of file cryptonote_format_utils.cpp.

1252  {
1253  return t_serializable_object_to_blob(tx, b_blob);
1254  }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ 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.

◆ 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.

◆ 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 94 of file blockchain_db.cpp.

◆ 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 89 of file blockchain_db.cpp.

◆ 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 84 of file blockchain_db.cpp.

◆ arg_db_type_description

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

Definition at line 83 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.