2022-10-16 03:17:18 +02:00
// Copyright (c) 2014-2022 Zano Project
2018-12-27 18:50:45 +03:00
// Copyright (c) 2014-2018 The Louisdor Project
// Copyright (c) 2012-2013 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
# pragma once
# include <memory>
# include <boost/serialization/list.hpp>
# include <boost/serialization/vector.hpp>
# include <boost/serialization/deque.hpp>
# include <boost/serialization/singleton.hpp>
# include <boost/serialization/extended_type_info.hpp>
# include <boost/serialization/shared_ptr.hpp>
2022-09-14 20:54:05 +02:00
# include <boost/serialization/optional.hpp>
2018-12-27 18:50:45 +03:00
# include <atomic>
2020-04-26 01:49:57 +02:00
2018-12-27 18:50:45 +03:00
# include "include_base_utils.h"
# include "profile_tools.h"
# include "sync_locked_object.h"
# include "currency_core/currency_boost_serialization.h"
# include "currency_core/account_boost_serialization.h"
# include "currency_core/currency_format_utils.h"
2020-05-26 15:55:58 +03:00
# include "common/make_hashable.h"
2019-08-27 17:36:53 +02:00
# include "wallet_public_structs_defs.h"
2018-12-27 18:50:45 +03:00
# include "currency_core/currency_format_utils.h"
# include "common/unordered_containers_boost_serialization.h"
2020-04-26 01:49:57 +02:00
# include "common/atomics_boost_serialization.h"
2018-12-27 18:50:45 +03:00
# include "storages/portable_storage_template_helper.h"
# include "crypto/chacha8.h"
# include "crypto/hash.h"
# include "core_rpc_proxy.h"
# include "core_default_rpc_proxy.h"
# include "wallet_errors.h"
# include "eos/portable_archive.hpp"
# include "currency_core/core_runtime_config.h"
# include "currency_core/bc_offers_serialization.h"
# include "currency_core/bc_escrow_service.h"
2019-04-03 12:48:09 +03:00
# include "common/pod_array_file_container.h"
2020-04-29 01:23:48 +02:00
# include "wallet_chain_shortener.h"
2022-03-22 23:38:43 +02:00
# include "tor-connect/torlib/tor_lib_iface.h"
2022-10-23 23:48:43 +02:00
# include "currency_core/pos_mining.h"
2023-02-28 21:35:28 +01:00
# include "view_iface.h"
2018-12-27 18:50:45 +03:00
# define WALLET_DEFAULT_TX_SPENDABLE_AGE 10
# define WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL 1
2019-11-29 21:43:17 +01:00
# define WALLET_DEFAULT_POS_MINT_PACKING_SIZE 100
2019-11-27 03:19:10 +01:00
2020-06-10 23:56:14 +02:00
# define WALLET_TRANSFER_DETAIL_FLAG_SPENT uint32_t(1 << 0)
# define WALLET_TRANSFER_DETAIL_FLAG_BLOCKED uint32_t(1 << 1)
# define WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION uint32_t(1 << 2)
# define WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER uint32_t(1 << 3)
# define WALLET_TRANSFER_DETAIL_FLAG_COLD_SIG_RESERVATION uint32_t(1 << 4) // transfer is reserved for cold-signing (unsigned tx was created and passed for signing)
2021-01-31 18:05:26 +01:00
# define WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM uint32_t(1 << 5) // for htlc keeps info if this htlc belong as redeem or as refund
2020-06-10 23:56:14 +02:00
2020-05-04 17:11:25 +02:00
const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std : : numeric_limits < uint64_t > : : max ( ) ;
2022-09-06 19:41:20 +02:00
2020-04-24 01:05:36 +02:00
2018-12-27 18:50:45 +03:00
# undef LOG_DEFAULT_CHANNEL
# define LOG_DEFAULT_CHANNEL "wallet"
2019-02-21 21:33:52 +03:00
// wallet-specific logging functions
2020-08-09 01:30:34 +03:00
# define WLT_LOG(msg, level) LOG_PRINT("[W:" << m_log_prefix << "] " << msg, level)
2019-10-09 16:01:33 +03:00
# define WLT_LOG_L0(msg) LOG_PRINT_L0("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_L1(msg) LOG_PRINT_L1("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_L2(msg) LOG_PRINT_L2("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_L3(msg) LOG_PRINT_L3("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_L4(msg) LOG_PRINT_L4("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_ERROR(msg) LOG_ERROR("[W:" << m_log_prefix << "] " << msg)
# define WLT_LOG_BLUE(msg, log_level) LOG_PRINT_BLUE("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_LOG_CYAN(msg, log_level) LOG_PRINT_CYAN("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_LOG_GREEN(msg, log_level) LOG_PRINT_GREEN("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_LOG_MAGENTA(msg, log_level) LOG_PRINT_MAGENTA("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_LOG_RED(msg, log_level) LOG_PRINT_RED("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_LOG_YELLOW(msg, log_level) LOG_PRINT_YELLOW("[W:" << m_log_prefix << "] " << msg, log_level)
# define WLT_CHECK_AND_ASSERT_MES(expr, ret, msg) CHECK_AND_ASSERT_MES(expr, ret, "[W:" << m_log_prefix << "] " << msg)
# define WLT_CHECK_AND_ASSERT_MES_NO_RET(expr, msg) CHECK_AND_ASSERT_MES_NO_RET(expr, "[W:" << m_log_prefix << "] " << msg)
# define WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, "[W:" << m_log_prefix << "] " << msg)
# define WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, "[W:" << m_log_prefix << "] " << msg)
2020-08-07 17:30:12 +03:00
# define WLT_THROW_IF_FALSE_WALLET_EX_MES(cond, exception_t, msg, ...) THROW_IF_FALSE_WALLET_EX_MES(cond, exception_t, "[W:" << m_log_prefix << "] " << msg, ## __VA_ARGS__)
2019-02-21 21:33:52 +03:00
2021-01-31 23:07:06 +01:00
2019-08-03 19:15:56 +02:00
class test_generator ;
2018-12-27 18:50:45 +03:00
namespace tools
{
# pragma pack(push, 1)
struct wallet_file_binary_header
{
uint64_t m_signature ;
uint16_t m_cb_keys ;
2020-07-19 00:31:55 +02:00
//uint64_t m_cb_body; <-- this field never used, soo replace it with two other variables "m_ver" + and "m_reserved"
uint32_t m_ver ;
uint32_t m_reserved ; //for future use
2018-12-27 18:50:45 +03:00
} ;
# pragma pack (pop)
struct money_transfer2_details
{
std : : vector < size_t > receive_indices ;
std : : vector < size_t > spent_indices ;
} ;
class i_wallet2_callback
{
public :
2020-05-26 13:28:24 +03:00
enum message_severity { ms_red , ms_yellow , ms_normal } ;
2019-02-20 07:19:02 +00:00
virtual ~ i_wallet2_callback ( ) = default ;
2018-12-27 18:50:45 +03:00
virtual void on_new_block ( uint64_t /*height*/ , const currency : : block & /*block*/ ) { }
2022-12-10 00:00:20 +01:00
virtual void on_transfer2 ( const wallet_public : : wallet_transfer_info & wti , const std : : list < wallet_public : : asset_balance_entry > & balances , uint64_t total_mined ) { }
2018-12-27 18:50:45 +03:00
virtual void on_pos_block_found ( const currency : : block & /*block*/ ) { }
virtual void on_sync_progress ( const uint64_t & /*percents*/ ) { }
2019-08-27 17:36:53 +02:00
virtual void on_transfer_canceled ( const wallet_public : : wallet_transfer_info & wti ) { }
2020-05-26 13:28:24 +03:00
virtual void on_message ( message_severity /*severity*/ , const std : : string & /*m*/ ) { }
2022-03-19 04:12:13 +02:00
virtual void on_tor_status_change ( const std : : string & state ) { }
2023-03-27 22:03:31 +02:00
//mw api
virtual void on_mw_get_wallets ( std : : vector < wallet_public : : wallet_entry_info > & wallets ) { }
2023-03-29 20:26:46 +02:00
virtual bool on_mw_select_wallet ( uint64_t wallet_id ) { }
2018-12-27 18:50:45 +03:00
} ;
struct tx_dust_policy
{
2022-09-15 22:05:10 +02:00
uint64_t dust_threshold = 0 ;
bool add_to_fee = false ;
2018-12-27 18:50:45 +03:00
currency : : account_public_address addr_for_dust ;
tx_dust_policy ( uint64_t a_dust_threshold = DEFAULT_DUST_THRESHOLD , bool an_add_to_fee = true , currency : : account_public_address an_addr_for_dust = currency : : account_public_address ( ) )
: dust_threshold ( a_dust_threshold )
, add_to_fee ( an_add_to_fee )
, addr_for_dust ( an_addr_for_dust )
{
}
2019-04-03 12:48:09 +03:00
BEGIN_SERIALIZE_OBJECT ( )
FIELD ( dust_threshold )
FIELD ( add_to_fee )
FIELD ( addr_for_dust )
END_SERIALIZE ( )
} ;
2018-12-27 18:50:45 +03:00
2019-04-03 12:48:09 +03:00
class test_generator ;
2018-12-27 18:50:45 +03:00
2019-04-03 12:48:09 +03:00
# pragma pack(push, 1)
struct out_key_to_ki
{
crypto : : public_key out_key ;
crypto : : key_image key_image ;
} ;
# pragma pack(pop)
2018-12-27 18:50:45 +03:00
2022-07-08 20:52:04 +02:00
2019-04-03 12:48:09 +03:00
typedef tools : : pod_array_file_container < out_key_to_ki > pending_ki_file_container_t ;
2018-12-27 18:50:45 +03:00
2019-04-03 12:48:09 +03:00
namespace detail
{
//----------------------------------------------------------------------------------------------------
inline void digit_split_strategy ( const std : : vector < currency : : tx_destination_entry > & dsts ,
const currency : : tx_destination_entry & change_dst , uint64_t dust_threshold ,
std : : vector < currency : : tx_destination_entry > & splitted_dsts , uint64_t & dust , uint64_t max_output_allowed )
{
splitted_dsts . clear ( ) ;
dust = 0 ;
for ( auto & de : dsts )
{
if ( de . addr . size ( ) > 1 )
{
//for multisig we don't split
splitted_dsts . push_back ( de ) ;
}
2021-02-06 00:02:48 +01:00
else if ( de . htlc_options . expiration ! = 0 )
{
//for htlc we don't do split
splitted_dsts . push_back ( de ) ;
}
2019-04-03 12:48:09 +03:00
else
{
currency : : decompose_amount_into_digits ( de . amount , dust_threshold ,
2022-10-12 22:57:09 +02:00
[ & ] ( uint64_t chunk ) { splitted_dsts . push_back ( currency : : tx_destination_entry ( chunk , de . addr , de . asset_id ) ) ; } ,
[ & ] ( uint64_t a_dust ) { splitted_dsts . push_back ( currency : : tx_destination_entry ( a_dust , de . addr , de . asset_id ) ) ; } , max_output_allowed ) ;
2019-04-03 12:48:09 +03:00
}
}
if ( change_dst . amount > 0 )
{
if ( change_dst . addr . size ( ) > 1 )
{
//for multisig we don't split
splitted_dsts . push_back ( change_dst ) ;
}
else
{
currency : : decompose_amount_into_digits ( change_dst . amount , dust_threshold ,
[ & ] ( uint64_t chunk ) { splitted_dsts . push_back ( currency : : tx_destination_entry ( chunk , change_dst . addr ) ) ; } ,
[ & ] ( uint64_t a_dust ) { dust = a_dust ; } , max_output_allowed ) ;
}
}
}
//----------------------------------------------------------------------------------------------------
inline void null_split_strategy ( const std : : vector < currency : : tx_destination_entry > & dsts ,
const currency : : tx_destination_entry & change_dst , uint64_t dust_threshold ,
std : : vector < currency : : tx_destination_entry > & splitted_dsts , uint64_t & dust , uint64_t max_output_allowed )
{
splitted_dsts = dsts ;
dust = 0 ;
uint64_t change = change_dst . amount ;
if ( 0 < dust_threshold )
{
for ( uint64_t order = 10 ; order < = 10 * dust_threshold ; order * = 10 )
{
uint64_t dust_candidate = change_dst . amount % order ;
uint64_t change_candidate = ( change_dst . amount / order ) * order ;
if ( dust_candidate < = dust_threshold )
{
dust = dust_candidate ;
change = change_candidate ;
}
else
{
break ;
}
}
}
if ( 0 ! = change )
{
splitted_dsts . push_back ( currency : : tx_destination_entry ( change , change_dst . addr ) ) ;
}
}
//----------------------------------------------------------------------------------------------------
inline void void_split_strategy ( const std : : vector < currency : : tx_destination_entry > & dsts ,
const currency : : tx_destination_entry & change_dst , uint64_t dust_threshold ,
std : : vector < currency : : tx_destination_entry > & splitted_dsts , uint64_t & dust , uint64_t max_output_allowed )
{
2022-10-06 22:59:00 +02:00
splitted_dsts . insert ( splitted_dsts . end ( ) , dsts . begin ( ) , dsts . end ( ) ) ;
2019-04-03 12:48:09 +03:00
if ( change_dst . amount > 0 )
splitted_dsts . push_back ( change_dst ) ;
}
//----------------------------------------------------------------------------------------------------
enum split_strategy_id_t { ssi_none = 0 , ssi_digit = 1 , ssi_null = 2 , ssi_void = 3 } ;
//----------------------------------------------------------------------------------------------------
inline bool apply_split_strategy_by_id ( split_strategy_id_t id , const std : : vector < currency : : tx_destination_entry > & dsts ,
const currency : : tx_destination_entry & change_dst , uint64_t dust_threshold ,
std : : vector < currency : : tx_destination_entry > & splitted_dsts , uint64_t & dust , uint64_t max_output_allowed )
{
switch ( id )
{
case ssi_digit :
digit_split_strategy ( dsts , change_dst , dust_threshold , splitted_dsts , dust , max_output_allowed ) ;
return true ;
case ssi_null :
null_split_strategy ( dsts , change_dst , dust_threshold , splitted_dsts , dust , max_output_allowed ) ;
return true ;
case ssi_void :
void_split_strategy ( dsts , change_dst , dust_threshold , splitted_dsts , dust , max_output_allowed ) ;
return true ;
default :
return false ;
}
}
} // namespace detail
struct construct_tx_param
{
// preparing data for tx
std : : vector < currency : : tx_destination_entry > dsts ;
2022-09-15 22:05:10 +02:00
size_t fake_outputs_count = 0 ;
uint64_t fee = 0 ;
2019-04-03 12:48:09 +03:00
tx_dust_policy dust_policy ;
2022-09-15 22:05:10 +02:00
crypto : : hash multisig_id = currency : : null_hash ;
uint8_t flags = 0 ;
uint8_t split_strategy_id = 0 ;
bool mark_tx_as_complete = false ;
2019-04-03 12:48:09 +03:00
2021-02-02 19:02:28 +01:00
crypto : : hash htlc_tx_id ;
std : : string htlc_origin ;
2019-04-03 12:48:09 +03:00
// constructing tx
2022-09-15 22:05:10 +02:00
uint64_t unlock_time = 0 ;
2019-04-03 12:48:09 +03:00
std : : vector < currency : : extra_v > extra ;
std : : vector < currency : : attachment_v > attachments ;
currency : : account_public_address crypt_address ;
2022-09-15 22:05:10 +02:00
uint8_t tx_outs_attr = 0 ;
bool shuffle = false ;
bool perform_packing = false ;
2019-04-03 12:48:09 +03:00
} ;
2023-03-08 21:19:59 +01:00
struct mode_separate_context
{
currency : : transaction tx_for_mode_separate ;
view : : ionic_swap_proposal_info proposal ;
} ;
2022-09-05 12:30:08 +02:00
2022-09-20 22:01:52 +02:00
struct selection_for_amount
{
uint64_t needed_amount = 0 ;
2022-09-21 22:35:24 +02:00
uint64_t found_amount = 0 ;
2022-09-20 22:01:52 +02:00
//std::vector<uint64_t> selected_indicies;
} ;
typedef std : : unordered_map < crypto : : hash , selection_for_amount > assets_selection_context ;
2022-03-19 04:12:13 +02:00
class wallet2 : public tools : : tor : : t_transport_state_notifier
2018-12-27 18:50:45 +03:00
{
2020-06-14 02:17:10 +02:00
wallet2 ( const wallet2 & ) = delete ;
2018-12-27 18:50:45 +03:00
public :
2020-06-14 02:17:10 +02:00
wallet2 ( ) ;
2019-04-12 09:48:33 +03:00
static std : : string transfer_flags_to_str ( uint32_t flags ) ;
2018-12-27 18:50:45 +03:00
static std : : string transform_tx_to_str ( const currency : : transaction & tx ) ;
static currency : : transaction transform_str_to_tx ( const std : : string & tx_str ) ;
struct transaction_wallet_info
{
2022-09-15 22:05:10 +02:00
uint64_t m_block_height = 0 ;
uint64_t m_block_timestamp = 0 ;
2018-12-27 18:50:45 +03:00
currency : : transaction m_tx ;
BEGIN_KV_SERIALIZE_MAP ( )
KV_SERIALIZE ( m_block_height )
KV_SERIALIZE ( m_block_timestamp )
KV_SERIALIZE_CUSTOM ( m_tx , std : : string , tools : : wallet2 : : transform_tx_to_str , tools : : wallet2 : : transform_str_to_tx )
END_KV_SERIALIZE_MAP ( )
} ;
static const transaction_wallet_info & transform_ptr_to_value ( const std : : shared_ptr < transaction_wallet_info > & a ) ;
static std : : shared_ptr < transaction_wallet_info > transform_value_to_ptr ( const transaction_wallet_info & d ) ;
struct transfer_details_base ;
static uint64_t transfer_details_base_to_amount ( const transfer_details_base & tdb ) ;
static std : : string transfer_details_base_to_tx_hash ( const transfer_details_base & tdb ) ;
struct transfer_details_base
{
std : : shared_ptr < transaction_wallet_info > m_ptx_wallet_info ;
2022-09-15 22:05:10 +02:00
uint64_t m_internal_output_index = 0 ;
uint64_t m_spent_height = 0 ;
uint32_t m_flags = 0 ;
uint64_t m_amount = 0 ;
2022-09-14 20:54:05 +02:00
boost : : shared_ptr < crypto : : scalar_t > m_opt_blinding_mask ;
boost : : shared_ptr < crypto : : hash > m_asset_id ;
2018-12-27 18:50:45 +03:00
2022-05-19 21:22:44 +02:00
// @#@ will throw if type is not tx_out_bare, TODO: change according to new model,
// need to replace all get_tx_out_bare_from_out_v() to proper code
2022-06-30 21:47:59 +02:00
uint64_t amount ( ) const { return m_amount ; }
2022-05-19 21:22:44 +02:00
const currency : : tx_out_bare & output ( ) const { return currency : : get_tx_out_bare_from_out_v ( m_ptx_wallet_info - > m_tx . vout [ m_internal_output_index ] ) ; }
2020-05-25 15:05:25 +03:00
uint8_t mix_attr ( ) const { return output ( ) . target . type ( ) = = typeid ( currency : : txout_to_key ) ? boost : : get < const currency : : txout_to_key & > ( output ( ) . target ) . mix_attr : UINT8_MAX ; }
crypto : : hash tx_hash ( ) const { return get_transaction_hash ( m_ptx_wallet_info - > m_tx ) ; }
2018-12-27 18:50:45 +03:00
bool is_spent ( ) const { return m_flags & WALLET_TRANSFER_DETAIL_FLAG_SPENT ; }
2019-05-06 19:38:06 +02:00
bool is_spendable ( ) const { return ( m_flags & ( WALLET_TRANSFER_DETAIL_FLAG_SPENT | WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION | WALLET_TRANSFER_DETAIL_FLAG_COLD_SIG_RESERVATION ) ) = = 0 ; }
2019-05-02 18:46:24 +02:00
bool is_reserved_for_escrow ( ) const { return ( ( m_flags & WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION ) ! = 0 ) ; }
2022-09-14 20:54:05 +02:00
bool is_zc ( ) const { return m_opt_blinding_mask . get ( ) ; }
2022-09-15 22:05:10 +02:00
const crypto : : hash & get_asset_id ( ) const { if ( m_asset_id . get ( ) ) { return * m_asset_id ; } else { return currency : : null_hash ; } }
2018-12-27 18:50:45 +03:00
BEGIN_KV_SERIALIZE_MAP ( )
KV_SERIALIZE_CUSTOM ( m_ptx_wallet_info , const transaction_wallet_info & , tools : : wallet2 : : transform_ptr_to_value , tools : : wallet2 : : transform_value_to_ptr )
KV_SERIALIZE ( m_internal_output_index )
KV_SERIALIZE ( m_spent_height )
KV_SERIALIZE ( m_flags )
2022-06-30 21:47:59 +02:00
KV_SERIALIZE ( m_amount )
2022-09-12 20:38:32 +02:00
KV_SERIALIZE_N ( m_opt_blinding_mask , " blinding_mask " )
2022-09-14 20:54:05 +02:00
KV_SERIALIZE ( m_asset_id )
2018-12-27 18:50:45 +03:00
KV_SERIALIZE_EPHEMERAL_N ( uint64_t , tools : : wallet2 : : transfer_details_base_to_amount , " amount " )
KV_SERIALIZE_EPHEMERAL_N ( std : : string , tools : : wallet2 : : transfer_details_base_to_tx_hash , " tx_id " )
END_KV_SERIALIZE_MAP ( )
} ;
2021-02-14 00:28:39 +01:00
struct transfer_details_extra_option_htlc_info
{
std : : string origin ; //this field filled only if htlc had been redeemed
2022-09-15 22:05:10 +02:00
crypto : : hash redeem_tx_id = currency : : null_hash ;
2021-02-15 02:17:59 +01:00
} ;
2021-02-14 00:28:39 +01:00
2021-03-26 00:43:50 +03:00
typedef boost : : variant < transfer_details_extra_option_htlc_info , currency : : tx_payer > transfer_details_extra_options_v ;
2021-02-14 00:28:39 +01:00
2018-12-27 18:50:45 +03:00
struct transfer_details : public transfer_details_base
{
2022-09-15 22:05:10 +02:00
uint64_t m_global_output_index = 0 ;
2018-12-27 18:50:45 +03:00
crypto : : key_image m_key_image ; //TODO: key_image stored twice :(
2021-02-15 02:17:59 +01:00
std : : vector < transfer_details_extra_options_v > varian_options ;
2018-12-27 18:50:45 +03:00
2022-06-28 22:27:36 +02:00
//v2
2018-12-27 18:50:45 +03:00
BEGIN_KV_SERIALIZE_MAP ( )
KV_SERIALIZE ( m_global_output_index )
KV_SERIALIZE_POD_AS_HEX_STRING ( m_key_image )
KV_CHAIN_BASE ( transfer_details_base )
END_KV_SERIALIZE_MAP ( )
} ;
2021-01-31 19:42:02 +01:00
//used in wallet
struct htlc_expiration_trigger
{
2022-09-15 22:05:10 +02:00
bool is_wallet_owns_redeem = false ; //specify if this HTLC belong to this wallet by pkey_redeem or by pkey_refund
uint64_t transfer_index = 0 ;
2021-01-31 19:42:02 +01:00
} ;
2018-12-27 18:50:45 +03:00
struct payment_details
{
2022-09-15 22:05:10 +02:00
crypto : : hash m_tx_hash = currency : : null_hash ;
uint64_t m_amount = 0 ;
uint64_t m_block_height = 0 ;
uint64_t m_unlock_time = 0 ;
2018-12-27 18:50:45 +03:00
} ;
2022-10-23 23:48:43 +02:00
struct mining_context : public currency : : pos_mining_context
2018-12-27 18:50:45 +03:00
{
2022-09-09 20:16:14 +02:00
std : : string status ;
2022-09-05 12:30:08 +02:00
2022-10-23 23:48:43 +02:00
bool is_pos_allowed = false ;
2022-09-05 12:30:08 +02:00
2022-09-15 22:05:10 +02:00
uint64_t index = 0 ; // index in m_transfers
uint64_t stake_unlock_time = 0 ;
uint64_t height = 0 ;
uint64_t starter_timestamp = 0 ;
crypto : : hash last_block_hash = currency : : null_hash ;
2022-09-12 18:47:38 +02:00
2022-09-09 20:16:14 +02:00
uint64_t iterations_processed = 0 ;
uint64_t total_items_checked = 0 ;
uint64_t total_amount_checked = 0 ;
2018-12-27 18:50:45 +03:00
} ;
struct expiration_entry_info
{
std : : vector < uint64_t > selected_transfers ;
2022-09-15 22:05:10 +02:00
uint64_t change_amount = 0 ;
uint64_t expiration_time = 0 ;
crypto : : hash related_tx_id = currency : : null_hash ; // tx id which caused money lock, if any (ex: escrow proposal transport tx)
2018-12-27 18:50:45 +03:00
} ;
typedef std : : unordered_multimap < std : : string , payment_details > payment_container ;
typedef std : : deque < transfer_details > transfer_container ;
typedef std : : unordered_map < crypto : : hash , transfer_details_base > multisig_transfer_container ;
2019-08-27 17:36:53 +02:00
typedef std : : unordered_map < crypto : : hash , tools : : wallet_public : : escrow_contract_details_basic > escrow_contracts_container ;
2018-12-27 18:50:45 +03:00
typedef std : : map < uint64_t , std : : set < size_t > > free_amounts_cache_type ;
2022-09-20 22:01:52 +02:00
typedef std : : unordered_map < crypto : : hash , free_amounts_cache_type > free_assets_amounts_cache_type ;
2020-05-25 15:05:25 +03:00
typedef std : : unordered_map < std : : pair < uint64_t , uint64_t > , uint64_t > amount_gindex_to_transfer_id_container ; // maps [amount; gindex] -> tid
2018-12-27 18:50:45 +03:00
2020-05-19 20:12:43 +03:00
struct keys_file_data_old
2018-12-27 18:50:45 +03:00
{
crypto : : chacha8_iv iv ;
std : : string account_data ;
BEGIN_SERIALIZE_OBJECT ( )
FIELD ( iv )
FIELD ( account_data )
END_SERIALIZE ( )
} ;
2020-05-19 20:12:43 +03:00
struct keys_file_data
{
uint8_t version ;
crypto : : chacha8_iv iv ;
std : : string account_data ;
static keys_file_data from_old ( const keys_file_data_old & v )
{
keys_file_data result = AUTO_VAL_INIT ( result ) ;
result . iv = v . iv ;
result . account_data = v . account_data ;
return result ;
}
DEFINE_SERIALIZATION_VERSION ( 1 )
BEGIN_SERIALIZE_OBJECT ( )
VERSION_ENTRY ( version )
FIELD ( iv )
FIELD ( account_data )
END_SERIALIZE ( )
} ;
2022-06-28 22:27:36 +02:00
struct process_transaction_context
{
2022-09-15 22:05:10 +02:00
uint64_t tx_money_spent_in_ins = 0 ;
2022-06-28 22:27:36 +02:00
// check all outputs for spending (compare key images)
money_transfer2_details mtd ;
2022-09-15 22:05:10 +02:00
bool is_pos_coinbase = false ;
bool coin_base_tx = false ;
2022-06-28 22:27:36 +02:00
//PoW block don't have change, so all outs supposed to be marked as "mined"
2022-09-15 22:05:10 +02:00
bool is_derived_from_coinbase = false ;
size_t i = 0 ;
size_t sub_i = 0 ;
uint64_t height = 0 ;
2022-06-28 22:27:36 +02:00
} ;
2022-09-27 20:13:49 +02:00
struct wallet_own_asset_context
{
2022-09-28 22:06:07 +02:00
currency : : asset_descriptor_base asset_descriptor ;
2022-09-27 20:13:49 +02:00
crypto : : secret_key control_key ;
2022-09-29 19:18:05 +02:00
uint64_t height = 0 ;
2022-09-27 20:13:49 +02:00
BEGIN_BOOST_SERIALIZATION ( )
BOOST_SERIALIZE ( asset_descriptor )
BOOST_SERIALIZE ( control_key )
2022-09-29 19:18:05 +02:00
BOOST_SERIALIZE ( height )
2022-09-27 20:13:49 +02:00
END_BOOST_SERIALIZATION ( )
} ;
2018-12-27 18:50:45 +03:00
void assign_account ( const currency : : account_base & acc ) ;
2020-05-02 23:59:37 +03:00
void generate ( const std : : wstring & path , const std : : string & password , bool auditable_wallet ) ;
2020-11-18 21:20:08 +01:00
void restore ( const std : : wstring & path , const std : : string & pass , const std : : string & seed_or_tracking_seed , bool tracking_wallet , const std : : string & seed_password ) ;
2020-01-16 23:52:29 +01:00
void load ( const std : : wstring & path , const std : : string & password ) ;
2018-12-27 18:50:45 +03:00
void store ( ) ;
2019-04-13 01:10:29 +03:00
void store ( const std : : wstring & path ) ;
2019-04-12 09:48:33 +03:00
void store ( const std : : wstring & path , const std : : string & password ) ;
void store_watch_only ( const std : : wstring & path , const std : : string & password ) const ;
2020-07-19 00:31:55 +02:00
bool store_keys ( std : : string & buff , const std : : string & password , wallet2 : : keys_file_data & keys_file_data , bool store_as_watch_only = false ) ;
2020-06-03 21:29:43 +02:00
std : : wstring get_wallet_path ( ) const { return m_wallet_file ; }
std : : string get_wallet_password ( ) const { return m_password ; }
2019-02-25 17:31:21 +03:00
currency : : account_base & get_account ( ) { return m_account ; }
const currency : : account_base & get_account ( ) const { return m_account ; }
2018-12-27 18:50:45 +03:00
2021-07-20 15:36:47 +02:00
void get_recent_transfers_history ( std : : vector < wallet_public : : wallet_transfer_info > & trs , size_t offset , size_t count , uint64_t & total , uint64_t & last_item_index , bool exclude_mining_txs = false , bool start_from_end = true ) ;
2022-06-08 17:33:02 +02:00
bool is_consolidating_transaction ( const wallet_public : : wallet_transfer_info & wti ) ;
2018-12-27 18:50:45 +03:00
uint64_t get_recent_transfers_total_count ( ) ;
2020-01-23 03:26:25 +01:00
uint64_t get_transfer_entries_count ( ) ;
2020-09-01 00:26:22 +02:00
void get_unconfirmed_transfers ( std : : vector < wallet_public : : wallet_transfer_info > & trs , bool exclude_mining_txs = false ) ;
2018-12-27 18:50:45 +03:00
void init ( const std : : string & daemon_address = " http://localhost:8080 " ) ;
bool deinit ( ) ;
void stop ( ) { m_stop . store ( true , std : : memory_order_relaxed ) ; }
void reset_creation_time ( uint64_t timestamp ) ;
//i_wallet2_callback* callback() const { return m_wcallback; }
//void callback(i_wallet2_callback* callback) { m_callback = callback; }
2020-05-25 15:05:25 +03:00
void callback ( std : : shared_ptr < i_wallet2_callback > callback ) { m_wcallback = callback ; m_do_rise_transfer = ( callback ! = nullptr ) ; }
2023-03-27 22:03:31 +02:00
i_wallet2_callback * get_callback ( ) { return m_wcallback ; }
2018-12-27 18:50:45 +03:00
void set_do_rise_transfer ( bool do_rise ) { m_do_rise_transfer = do_rise ; }
bool has_related_alias_entry_unconfirmed ( const currency : : transaction & tx ) ;
void scan_tx_pool ( bool & has_related_alias_in_unconfirmed ) ;
void refresh ( ) ;
void refresh ( size_t & blocks_fetched ) ;
void refresh ( size_t & blocks_fetched , bool & received_money , std : : atomic < bool > & stop ) ;
bool refresh ( size_t & blocks_fetched , bool & received_money , bool & ok , std : : atomic < bool > & stop ) ;
void refresh ( std : : atomic < bool > & stop ) ;
void resend_unconfirmed ( ) ;
void push_offer ( const bc_services : : offer_details_ex & od , currency : : transaction & res_tx ) ;
2019-07-19 18:59:31 +03:00
void cancel_offer_by_id ( const crypto : : hash & tx_id , uint64_t of_ind , uint64_t fee , currency : : transaction & tx ) ;
2018-12-27 18:50:45 +03:00
void update_offer_by_id ( const crypto : : hash & tx_id , uint64_t of_ind , const bc_services : : offer_details_ex & od , currency : : transaction & res_tx ) ;
2022-06-16 17:02:00 +02:00
void request_alias_registration ( currency : : extra_alias_entry & ai , currency : : transaction & res_tx , uint64_t fee , uint64_t reward , const crypto : : secret_key & authority_key = currency : : null_skey ) ;
2018-12-27 18:50:45 +03:00
void request_alias_update ( currency : : extra_alias_entry & ai , currency : : transaction & res_tx , uint64_t fee , uint64_t reward ) ;
bool check_available_sources ( std : : list < uint64_t > & amounts ) ;
2022-09-26 21:57:24 +02:00
2022-10-03 22:03:54 +02:00
void publish_new_asset ( const currency : : asset_descriptor_base & asset_info , const std : : vector < currency : : tx_destination_entry > & destinations , currency : : transaction & result_tx , crypto : : hash & asset_id ) ;
2018-12-27 18:50:45 +03:00
bool set_core_proxy ( const std : : shared_ptr < i_core_proxy > & proxy ) ;
2019-11-29 21:43:17 +01:00
void set_pos_mint_packing_size ( uint64_t new_size ) ;
2020-04-28 00:40:31 +02:00
void set_minimum_height ( uint64_t h ) ;
2018-12-27 18:50:45 +03:00
std : : shared_ptr < i_core_proxy > get_core_proxy ( ) ;
uint64_t balance ( ) const ;
uint64_t balance ( uint64_t & unloked , uint64_t & awaiting_in , uint64_t & awaiting_out , uint64_t & mined ) const ;
2022-09-16 18:35:36 +02:00
bool balance ( std : : unordered_map < crypto : : hash , wallet_public : : asset_balance_entry_base > & balances , uint64_t & mined ) const ;
2022-11-18 21:04:05 +01:00
bool balance ( std : : list < wallet_public : : asset_balance_entry > & balances , uint64_t & mined ) const ;
2022-11-18 16:11:15 +01:00
2018-12-27 18:50:45 +03:00
uint64_t balance ( uint64_t & unloked ) const ;
2022-09-15 22:05:10 +02:00
2018-12-27 18:50:45 +03:00
uint64_t unlocked_balance ( ) const ;
2022-10-06 22:59:00 +02:00
void transfer ( uint64_t amount , const currency : : account_public_address & acc , const crypto : : hash & asset_id = currency : : null_hash ) ;
2022-11-23 15:10:06 +01:00
void transfer ( uint64_t amount , size_t fake_outs_count , const currency : : account_public_address & acc , uint64_t fee = TX_DEFAULT_FEE , const crypto : : hash & asset_id = currency : : null_hash ) ;
2022-10-06 22:59:00 +02:00
void transfer ( uint64_t amount , const currency : : account_public_address & acc , currency : : transaction & result_tx , const crypto : : hash & asset_id = currency : : null_hash ) ;
2018-12-27 18:50:45 +03:00
void transfer ( const std : : vector < currency : : tx_destination_entry > & dsts ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t fee ,
const std : : vector < currency : : extra_v > & extra ,
2019-04-03 12:48:09 +03:00
const std : : vector < currency : : attachment_v > & attachments ,
detail : : split_strategy_id_t destination_split_strategy_id ,
2018-12-27 18:50:45 +03:00
const tx_dust_policy & dust_policy ) ;
void transfer ( const std : : vector < currency : : tx_destination_entry > & dsts ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t fee ,
const std : : vector < currency : : extra_v > & extra ,
2019-04-03 12:48:09 +03:00
const std : : vector < currency : : attachment_v > & attachments ,
detail : : split_strategy_id_t destination_split_strategy_id ,
2018-12-27 18:50:45 +03:00
const tx_dust_policy & dust_policy ,
currency : : transaction & tx ,
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED ,
bool shuffle = true ,
uint8_t flags = 0 ,
2019-04-08 14:16:11 +03:00
bool send_to_network = true ,
2020-07-20 13:05:25 +03:00
std : : string * p_unsigned_filename_or_tx_blob_str = nullptr ) ;
2018-12-27 18:50:45 +03:00
void transfer ( const std : : vector < currency : : tx_destination_entry > & dsts ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t fee ,
const std : : vector < currency : : extra_v > & extra ,
2019-04-03 12:48:09 +03:00
const std : : vector < currency : : attachment_v > & attachments ) ;
2018-12-27 18:50:45 +03:00
void transfer ( const std : : vector < currency : : tx_destination_entry > & dsts ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t fee ,
const std : : vector < currency : : extra_v > & extra ,
2019-04-03 12:48:09 +03:00
const std : : vector < currency : : attachment_v > & attachments ,
2018-12-27 18:50:45 +03:00
currency : : transaction & tx ) ;
2021-02-03 00:13:44 +01:00
void transfer ( construct_tx_param & ctp ,
2019-11-28 05:28:36 +01:00
currency : : transaction & tx ,
bool send_to_network ,
2021-07-17 00:05:41 +02:00
std : : string * p_unsigned_filename_or_tx_blob_str = nullptr ) ;
2021-02-04 01:49:38 +01:00
void transfer ( construct_tx_param & ctp ,
currency : : finalized_tx & result ,
bool send_to_network ,
2021-07-17 00:05:41 +02:00
std : : string * p_unsigned_filename_or_tx_blob_str = nullptr ) ;
2021-02-04 01:49:38 +01:00
2019-11-28 05:28:36 +01:00
2018-12-27 18:50:45 +03:00
template < typename destination_split_strategy_t >
void transfer_from_contract (
const std : : list < currency : : account_keys > & owner_keys ,
crypto : : hash multisig_id ,
const std : : vector < currency : : tx_destination_entry > & dsts ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t fee ,
const std : : vector < currency : : extra_v > & extra ,
2019-04-03 12:48:09 +03:00
const std : : vector < currency : : attachment_v > & attachments ,
2018-12-27 18:50:45 +03:00
destination_split_strategy_t destination_split_strategy ,
const tx_dust_policy & dust_policy ,
currency : : transaction & tx ,
uint8_t tx_outs_attr ,
bool shuffle ,
uint8_t flags ,
bool send_to_network ) ;
void build_escrow_release_templates ( crypto : : hash multisig_id ,
uint64_t fee ,
currency : : transaction & tx_release_template ,
currency : : transaction & tx_burn_template ,
const bc_services : : contract_private_details & ecrow_details ) ;
void build_escrow_cancel_template ( crypto : : hash multisig_id ,
uint64_t expiration_period ,
currency : : transaction & tx_cancel_template ,
const bc_services : : contract_private_details & ecrow_details ) ;
void build_escrow_template ( const bc_services : : contract_private_details & ecrow_detaild ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t expiration_time ,
uint64_t b_release_fee ,
const std : : string & payment_id ,
currency : : transaction & tx ,
std : : vector < uint64_t > & selected_transfers ,
2019-04-03 12:48:09 +03:00
crypto : : secret_key & one_time_key ) ;
2018-12-27 18:50:45 +03:00
2019-08-27 17:36:53 +02:00
void send_escrow_proposal ( const wallet_public : : create_proposal_param & wp ,
currency : : transaction & proposal_tx ,
currency : : transaction & escrow_template_tx ) ;
2018-12-27 18:50:45 +03:00
void send_escrow_proposal ( const bc_services : : contract_private_details & ecrow_detaild ,
size_t fake_outputs_count ,
uint64_t unlock_time ,
uint64_t expiration_period ,
uint64_t fee ,
uint64_t b_release_fee ,
const std : : string & payment_id ,
currency : : transaction & proposal_tx ,
2019-04-03 12:48:09 +03:00
currency : : transaction & escrow_template_tx ) ;
2018-12-27 18:50:45 +03:00
bool check_connection ( ) ;
2022-08-26 18:12:32 +02:00
// PoS mining
2022-09-05 12:30:08 +02:00
void do_pos_mining_prepare_entry ( mining_context & cxt , size_t transfer_index ) ;
bool do_pos_mining_iteration ( mining_context & cxt , size_t transfer_index , uint64_t ts ) ;
2018-12-27 18:50:45 +03:00
template < typename idle_condition_cb_t > //do refresh as external callback
2022-09-05 12:30:08 +02:00
bool scan_pos ( mining_context & cxt , std : : atomic < bool > & stop , idle_condition_cb_t idle_condition_cb , const currency : : core_runtime_config & runtime_config ) ;
2018-12-27 18:50:45 +03:00
bool fill_mining_context ( mining_context & ctx ) ;
2022-08-26 18:12:32 +02:00
2018-12-27 18:50:45 +03:00
void get_transfers ( wallet2 : : transfer_container & incoming_transfers ) const ;
2022-10-20 18:28:47 +02:00
std : : string get_transfers_str ( bool include_spent = true , bool include_unspent = true ) const ;
2019-04-12 09:48:33 +03:00
2018-12-27 18:50:45 +03:00
// Returns all payments by given id in unspecified order
2019-04-03 12:48:09 +03:00
void get_payments ( const std : : string & payment_id , std : : list < payment_details > & payments , uint64_t min_height = 0 ) const ;
2020-04-07 14:28:57 +03:00
// callback: (const wallet_public::wallet_transfer_info& wti) -> bool, true -- continue, false -- stop
template < typename callback_t >
void enumerate_transfers_history ( callback_t cb , bool enumerate_forward ) const ;
// callback: (const wallet_public::wallet_transfer_info& wti) -> bool, true -- continue, false -- stop
template < typename callback_t >
void enumerate_unconfirmed_transfers ( callback_t cb ) const ;
2019-04-03 12:48:09 +03:00
bool is_watch_only ( ) const { return m_watch_only ; }
2020-05-11 21:23:00 +03:00
bool is_auditable ( ) const { return m_account . get_public_address ( ) . is_auditable ( ) ; }
2019-04-03 12:48:09 +03:00
void sign_transfer ( const std : : string & tx_sources_blob , std : : string & signed_tx_blob , currency : : transaction & tx ) ;
2019-04-05 00:42:28 +03:00
void sign_transfer_files ( const std : : string & tx_sources_file , const std : : string & signed_tx_file , currency : : transaction & tx ) ;
void submit_transfer ( const std : : string & signed_tx_blob , currency : : transaction & tx ) ;
void submit_transfer_files ( const std : : string & signed_tx_file , currency : : transaction & tx ) ;
2019-04-03 12:48:09 +03:00
2019-12-14 18:31:19 +03:00
void sweep_below ( size_t fake_outs_count , const currency : : account_public_address & destination_addr , uint64_t threshold_amount , const currency : : payment_id_t & payment_id ,
2022-11-25 23:01:45 +01:00
uint64_t fee , size_t & outs_total , uint64_t & amount_total , size_t & outs_swept , uint64_t & amount_swept , currency : : transaction * p_result_tx = nullptr , std : : string * p_filename_or_unsigned_tx_blob_str = nullptr ) ;
2019-12-14 18:31:19 +03:00
2018-12-27 18:50:45 +03:00
bool get_transfer_address ( const std : : string & adr_str , currency : : account_public_address & addr , std : : string & payment_id ) ;
2020-04-25 00:30:55 +02:00
inline uint64_t get_blockchain_current_size ( ) const {
2020-04-29 01:23:48 +02:00
return m_chain . get_blockchain_current_size ( ) ;
2020-04-24 01:05:36 +02:00
}
2020-04-25 17:23:05 +03:00
2020-04-29 01:23:48 +02:00
uint64_t get_top_block_height ( ) const { return m_chain . get_top_block_height ( ) ; }
2019-04-30 19:00:34 +02:00
2022-05-09 20:28:13 +02:00
2018-12-27 18:50:45 +03:00
template < class t_archive >
2021-06-03 19:00:34 +03:00
inline void serialize ( t_archive & a , const unsigned int ver )
2018-12-27 18:50:45 +03:00
{
2021-05-31 22:24:38 +03:00
if ( t_archive : : is_saving : : value )
{
WLT_LOG_MAGENTA ( " Serializing file with ver: " < < ver , LOG_LEVEL_0 ) ;
}
2019-04-30 19:00:34 +02:00
// do not load wallet if data version is greather than the code version
if ( ver > WALLET_FILE_SERIALIZATION_VERSION )
2019-05-08 00:53:31 +02:00
{
2020-07-08 16:48:57 +03:00
WLT_LOG_MAGENTA ( " Wallet file truncated due to WALLET_FILE_SERIALIZATION_VERSION is more then curren build " , LOG_LEVEL_0 ) ;
2019-05-08 00:53:31 +02:00
return ;
}
2019-07-20 14:36:12 +02:00
if ( ver < 149 )
2019-05-08 00:53:31 +02:00
{
2021-05-31 22:24:38 +03:00
WLT_LOG_MAGENTA ( " Wallet file truncated due to old version. ver: " < < ver < < " , WALLET_FILE_SERIALIZATION_VERSION= " < < WALLET_FILE_SERIALIZATION_VERSION , LOG_LEVEL_0 ) ;
2018-12-27 18:50:45 +03:00
return ;
2019-05-08 00:53:31 +02:00
}
if ( t_archive : : is_saving : : value )
{
uint64_t formation_ver = CURRENCY_FORMATION_VERSION ;
a & formation_ver ;
}
else
{
uint64_t formation_ver = 0 ;
a & formation_ver ;
if ( formation_ver ! = CURRENCY_FORMATION_VERSION )
{
2020-07-08 16:48:57 +03:00
WLT_LOG_MAGENTA ( " Wallet file truncated due to mismatch CURRENCY_FORMATION_VERSION " , LOG_LEVEL_0 ) ;
2019-05-08 00:53:31 +02:00
return ;
}
}
2020-04-24 01:05:36 +02:00
//convert from old version
2020-05-04 17:11:25 +02:00
if ( ver < 150 )
2020-04-24 01:05:36 +02:00
{
2020-07-08 16:48:57 +03:00
WLT_LOG_MAGENTA ( " Converting blockchain into a short form... " , LOG_LEVEL_0 ) ;
2020-05-03 14:59:34 +02:00
std : : vector < crypto : : hash > old_blockchain ;
a & old_blockchain ;
uint64_t count = 0 ;
for ( auto & h : old_blockchain )
{
m_chain . push_new_block_id ( h , count ) ;
2020-05-04 17:11:25 +02:00
count + + ;
2020-05-03 14:59:34 +02:00
}
2020-07-08 16:48:57 +03:00
WLT_LOG_MAGENTA ( " Converting done " , LOG_LEVEL_0 ) ;
2020-04-24 01:05:36 +02:00
}
else
{
2020-04-29 01:23:48 +02:00
a & m_chain ;
2020-05-04 17:11:25 +02:00
a & m_minimum_height ;
2020-04-24 01:05:36 +02:00
}
2020-05-26 13:28:24 +03:00
// v151: m_amount_gindex_to_transfer_id added
if ( ver > = 151 )
a & m_amount_gindex_to_transfer_id ;
2019-04-30 19:00:34 +02:00
2018-12-27 18:50:45 +03:00
a & m_transfers ;
a & m_multisig_transfers ;
2019-05-08 00:53:31 +02:00
a & m_key_images ;
2019-04-30 19:21:59 +02:00
a & m_unconfirmed_txs ;
2018-12-27 18:50:45 +03:00
a & m_unconfirmed_multisig_transfers ;
a & m_payments ;
a & m_transfer_history ;
a & m_unconfirmed_in_transfers ;
a & m_contracts ;
a & m_money_expirations ;
2019-05-08 00:53:31 +02:00
a & m_pending_key_images ;
a & m_tx_keys ;
2019-07-20 14:36:12 +02:00
a & m_last_pow_block_h ;
2019-04-30 19:07:54 +02:00
2020-08-29 01:14:26 +02:00
//after processing
if ( ver < 152 )
{
wipeout_extra_if_needed ( m_transfer_history ) ;
}
2021-01-24 21:00:43 +01:00
if ( ver < 153 )
return ;
a & m_htlcs ;
2021-01-27 22:49:15 +01:00
a & m_active_htlcs ;
2021-01-31 18:05:26 +01:00
a & m_active_htlcs_txid ;
2021-01-24 21:00:43 +01:00
2022-09-27 20:13:49 +02:00
if ( ver < 154 )
return ;
a & m_own_asset_descriptors ;
2022-11-15 21:54:55 +01:00
a & m_custom_assets ;
2018-12-27 18:50:45 +03:00
}
2019-04-30 19:00:34 +02:00
2020-08-29 01:14:26 +02:00
void wipeout_extra_if_needed ( std : : vector < wallet_public : : wallet_transfer_info > & transfer_history ) ;
2018-12-27 18:50:45 +03:00
bool is_transfer_ready_to_go ( const transfer_details & td , uint64_t fake_outputs_count ) ;
bool is_transfer_able_to_go ( const transfer_details & td , uint64_t fake_outputs_count ) ;
uint64_t select_indices_for_transfer ( std : : vector < uint64_t > & ind , free_amounts_cache_type & found_free_amounts , uint64_t needed_money , uint64_t fake_outputs_count ) ;
2022-09-20 22:01:52 +02:00
bool select_indices_for_transfer ( assets_selection_context & needed_money_map , uint64_t fake_outputs_count , std : : vector < uint64_t > & selected_indexes ) ;
2018-12-27 18:50:45 +03:00
//PoS
//synchronous version of function
bool try_mint_pos ( ) ;
2019-12-10 00:50:30 +03:00
bool try_mint_pos ( const currency : : account_public_address & miner_address ) ; // block reward will be sent to miner_address, stake will be returned back to the wallet
2018-12-27 18:50:45 +03:00
//for unit tests
2019-08-03 19:15:56 +02:00
friend class : : test_generator ;
2018-12-27 18:50:45 +03:00
2020-04-25 00:30:55 +02:00
//next functions in public area only becausce of test_generator
2018-12-27 18:50:45 +03:00
//TODO: Need refactoring - remove it back to private zone
void set_genesis ( const crypto : : hash & genesis_hash ) ;
2022-10-20 12:46:41 +02:00
bool prepare_and_sign_pos_block ( const mining_context & cxt , currency : : block & b , const currency : : pos_entry & pe , const crypto : : scalar_t & blinding_masks_sum ) const ;
2018-12-27 18:50:45 +03:00
void process_new_blockchain_entry ( const currency : : block & b ,
const currency : : block_direct_data_entry & bche ,
const crypto : : hash & bl_id ,
uint64_t height ) ;
2021-01-24 21:00:43 +01:00
void process_htlc_triggers_on_block_added ( uint64_t height ) ;
2021-02-28 23:36:38 +01:00
void unprocess_htlc_triggers_on_block_removed ( uint64_t height ) ;
2022-09-05 12:30:08 +02:00
bool get_pos_entries ( std : : vector < currency : : pos_entry > & entries ) ; // TODO: make it const
size_t get_pos_entries_count ( ) ;
2022-10-12 18:02:22 +02:00
bool build_minted_block ( const mining_context & cxt ) ;
bool build_minted_block ( const mining_context & cxt , const currency : : account_public_address & miner_address ) ;
2018-12-27 18:50:45 +03:00
bool reset_history ( ) ;
bool is_transfer_unlocked ( const transfer_details & td ) const ;
2019-07-24 19:14:35 +02:00
bool is_transfer_unlocked ( const transfer_details & td , bool for_pos_mining , uint64_t & stake_lock_time ) const ;
2022-05-14 00:00:34 +02:00
void get_mining_history ( wallet_public : : mining_history & hist , uint64_t timestamp_from = 0 ) ;
2018-12-27 18:50:45 +03:00
void set_core_runtime_config ( const currency : : core_runtime_config & pc ) ;
currency : : core_runtime_config & get_core_runtime_config ( ) ;
bool backup_keys ( const std : : string & path ) ;
bool reset_password ( const std : : string & pass ) ;
bool is_password_valid ( const std : : string & pass ) ;
2019-08-28 22:16:15 +02:00
bool get_actual_offers ( std : : list < bc_services : : offer_details_ex > & offers ) ;
2019-08-27 17:36:53 +02:00
bool process_contract_info ( wallet_public : : wallet_transfer_info & wti , const std : : vector < currency : : payload_items_v > & decrypted_attach ) ;
bool handle_proposal ( wallet_public : : wallet_transfer_info & wti , const bc_services : : proposal_body & prop ) ;
2018-12-27 18:50:45 +03:00
void accept_proposal ( const crypto : : hash & contract_id , uint64_t b_acceptance_fee , currency : : transaction * p_acceptance_tx = nullptr ) ;
void finish_contract ( const crypto : : hash & contract_id , const std : : string & release_type , currency : : transaction * p_release_tx = nullptr ) ;
void request_cancel_contract ( const crypto : : hash & contract_id , uint64_t fee , uint64_t expiration_period , currency : : transaction * p_cancellation_proposal_tx = nullptr ) ;
void accept_cancel_contract ( const crypto : : hash & contract_id , currency : : transaction * p_cancellation_acceptance_tx = nullptr ) ;
void scan_tx_to_key_inputs ( std : : vector < uint64_t > & found_transfers , const currency : : transaction & tx ) ;
void dump_trunsfers ( std : : stringstream & ss , bool verbose = true ) const ;
std : : string dump_trunsfers ( bool verbose = false ) const ;
void dump_key_images ( std : : stringstream & ss ) ;
void get_multisig_transfers ( multisig_transfer_container & ms_transfers ) ;
const multisig_transfer_container & get_multisig_transfers ( ) const { return m_multisig_transfers ; }
void set_miner_text_info ( const std : : string & mti ) { m_miner_text_info = mti ; }
bool get_transfer_info_by_key_image ( const crypto : : key_image & ki , transfer_details & td , size_t & i ) ;
bool get_transfer_info_by_index ( size_t i , transfer_details & td ) ;
size_t scan_for_collisions ( std : : unordered_map < crypto : : key_image , std : : list < size_t > > & key_images ) ;
size_t fix_collisions ( ) ;
size_t scan_for_transaction_entries ( const crypto : : hash & tx_id , const crypto : : key_image & ki , std : : list < transfer_details > & details ) ;
bool get_contracts ( escrow_contracts_container & contracts ) ;
const std : : list < expiration_entry_info > & get_expiration_entries ( ) const { return m_money_expirations ; } ;
2019-04-03 12:48:09 +03:00
bool get_tx_key ( const crypto : : hash & txid , crypto : : secret_key & tx_key ) const ;
2018-12-27 18:50:45 +03:00
2023-03-08 21:19:59 +01:00
void prepare_transaction ( construct_tx_param & ctp , currency : : finalize_tx_param & ftp , const mode_separate_context & emode_separate = mode_separate_context ( ) ) ;
2021-02-04 01:49:38 +01:00
void finalize_transaction ( const currency : : finalize_tx_param & ftp , currency : : transaction & tx , crypto : : secret_key & tx_key , bool broadcast_tx , bool store_tx_secret_key = true ) ;
void finalize_transaction ( const currency : : finalize_tx_param & ftp , currency : : finalized_tx & result , bool broadcast_tx , bool store_tx_secret_key = true ) ;
2018-12-27 18:50:45 +03:00
2019-02-25 17:31:21 +03:00
std : : string get_log_prefix ( ) const { return m_log_prefix ; }
2019-08-03 00:22:04 +02:00
static uint64_t get_max_unlock_time_from_receive_indices ( const currency : : transaction & tx , const money_transfer2_details & td ) ;
2019-12-03 02:18:45 +01:00
bool get_utxo_distribution ( std : : map < uint64_t , uint64_t > & distribution ) ;
2020-01-17 23:44:22 +01:00
uint64_t get_sync_progress ( ) ;
2020-06-03 21:29:43 +02:00
uint64_t get_wallet_file_size ( ) const ;
2020-06-18 20:37:01 +02:00
void set_use_deffered_global_outputs ( bool use ) ;
2021-07-17 00:05:41 +02:00
construct_tx_param get_default_construct_tx_param_inital ( ) ;
2022-03-19 04:12:13 +02:00
void set_disable_tor_relay ( bool disable ) ;
2022-06-16 17:02:00 +02:00
uint64_t get_default_fee ( ) { return TX_DEFAULT_FEE ; }
2021-10-21 07:30:58 +03:00
void export_transaction_history ( std : : ostream & ss , const std : : string & format , bool include_pos_transactions = true ) ;
2022-11-15 21:54:55 +01:00
2022-12-02 15:24:50 +01:00
bool add_custom_asset_id ( const crypto : : hash & asset_id , currency : : asset_descriptor_base & asset_descriptor ) ;
2022-11-16 22:16:15 +01:00
bool delete_custom_asset_id ( const crypto : : hash & asset_id ) ;
2022-11-28 22:10:50 +01:00
bool load_whitelisted_tokens_if_not_loaded ( ) const ;
bool load_whitelisted_tokens ( ) const ;
2022-11-16 22:16:15 +01:00
2021-01-31 23:07:06 +01:00
/*
create_htlc_proposal : if htlc_hash = = null_hash , then this wallet is originator of the atomic process , and
we use deterministic origin , if given some particular htlc_hash , then we use this hash , and this means that
opener - hash will be given by other side
*/
2021-02-15 02:17:59 +01:00
void create_htlc_proposal ( uint64_t amount , const currency : : account_public_address & addr , uint64_t lock_blocks_count , currency : : transaction & tx , const crypto : : hash & htlc_hash , std : : string & origin ) ;
void get_list_of_active_htlc ( std : : list < wallet_public : : htlc_entry_info > & htlcs , bool only_redeem_txs ) ;
2021-02-20 15:54:58 +01:00
void redeem_htlc ( const crypto : : hash & htlc_tx_id , const std : : string & origin , currency : : transaction & result_tx ) ;
void redeem_htlc ( const crypto : : hash & htlc_tx_id , const std : : string & origin ) ;
2021-03-18 22:35:11 +03:00
bool check_htlc_redeemed ( const crypto : : hash & htlc_tx_id , std : : string & origin , crypto : : hash & redeem_tx_id ) ;
2023-02-20 21:39:36 +01:00
// ionic swaps:
2023-03-13 22:14:39 +01:00
bool create_ionic_swap_proposal ( const view : : ionic_swap_proposal_info & proposal , const currency : : account_public_address & destination_addr , transaction & tx_template ) ;
2023-02-23 19:10:22 +01:00
bool build_ionic_swap_template ( const view : : ionic_swap_proposal_info & proposal_detais , const currency : : account_public_address & destination_addr ,
currency : : transaction & template_tx ,
std : : vector < uint64_t > & selected_transfers_for_template ,
crypto : : secret_key & one_time_key ) ;
2023-03-08 21:19:59 +01:00
bool get_ionic_swap_proposal_info ( const std : : string & raw_tx_template , view : : ionic_swap_proposal_info & proposal ) ;
bool get_ionic_swap_proposal_info ( const currency : : transaction tx , view : : ionic_swap_proposal_info & proposal ) ;
2023-03-16 19:15:11 +01:00
bool accept_ionic_swap_proposal ( const std : : string & raw_tx_template , currency : : transaction & result_tx ) ;
bool accept_ionic_swap_proposal ( const currency : : transaction & tx_template , currency : : transaction & result_tx ) ;
2018-12-27 18:50:45 +03:00
private :
2020-04-25 17:23:05 +03:00
2022-03-19 04:12:13 +02:00
// -------- t_transport_state_notifier ------------------------------------------------
virtual void notify_state_change ( const std : : string & state_code , const std : : string & details = std : : string ( ) ) ;
// ------------------------------------------------------------------------------------
2018-12-27 18:50:45 +03:00
void add_transfers_to_expiration_list ( const std : : vector < uint64_t > & selected_transfers , uint64_t expiration , uint64_t change_amount , const crypto : : hash & related_tx_id ) ;
void remove_transfer_from_expiration_list ( uint64_t transfer_index ) ;
2020-07-19 00:31:55 +02:00
void load_keys ( const std : : string & keys_file_name , const std : : string & password , uint64_t file_signature , keys_file_data & kf_data ) ;
2020-06-12 00:32:08 +02:00
void process_new_transaction ( const currency : : transaction & tx , uint64_t height , const currency : : block & b , const std : : vector < uint64_t > * pglobal_indexes ) ;
void fetch_tx_global_indixes ( const currency : : transaction & tx , std : : vector < uint64_t > & goutputs_indexes ) ;
2020-06-12 23:32:06 +02:00
void fetch_tx_global_indixes ( const std : : list < std : : reference_wrapper < const currency : : transaction > > & txs , std : : vector < std : : vector < uint64_t > > & goutputs_indexes ) ;
2020-05-02 22:53:52 +02:00
void detach_blockchain ( uint64_t including_height ) ;
2018-12-27 18:50:45 +03:00
bool extract_offers_from_transfer_entry ( size_t i , std : : unordered_map < crypto : : hash , bc_services : : offer_details_ex > & offers_local ) ;
bool select_my_offers ( std : : list < bc_services : : offer_details_ex > & offers ) ;
bool clear ( ) ;
bool reset_all ( ) ;
bool on_idle ( ) ;
void unserialize_block_complete_entry ( const currency : : COMMAND_RPC_GET_BLOCKS_FAST : : response & serialized ,
currency : : COMMAND_RPC_GET_BLOCKS_DIRECT : : response & unserialized ) ;
void pull_blocks ( size_t & blocks_added , std : : atomic < bool > & stop ) ;
bool prepare_free_transfers_cache ( uint64_t fake_outputs_count ) ;
2022-09-20 22:01:52 +02:00
bool select_transfers ( assets_selection_context & needed_money_map , size_t fake_outputs_count , uint64_t dust , std : : vector < uint64_t > & selected_indicies ) ;
2018-12-27 18:50:45 +03:00
void add_transfers_to_transfers_cache ( const std : : vector < uint64_t > & indexs ) ;
2022-09-20 22:01:52 +02:00
void add_transfer_to_transfers_cache ( uint64_t amount , uint64_t index , const crypto : : hash & asset_id = currency : : null_hash ) ;
2019-04-03 12:48:09 +03:00
bool prepare_file_names ( const std : : wstring & file_path ) ;
2018-12-27 18:50:45 +03:00
void process_unconfirmed ( const currency : : transaction & tx , std : : vector < std : : string > & recipients , std : : vector < std : : string > & recipients_aliases ) ;
void add_sent_unconfirmed_tx ( const currency : : transaction & tx ,
const std : : vector < std : : string > & recipients ,
const std : : vector < uint64_t > & selected_indicies ,
const std : : vector < currency : : tx_destination_entry > & splitted_dsts ) ;
bool read_money_transfer2_details_from_tx ( const currency : : transaction & tx ,
const std : : vector < currency : : tx_destination_entry > & splitted_dsts ,
2019-08-27 17:36:53 +02:00
wallet_public : : wallet_transfer_info_details & wtd ) ;
2018-12-27 18:50:45 +03:00
void update_current_tx_limit ( ) ;
2019-08-27 17:36:53 +02:00
void prepare_wti ( wallet_public : : wallet_transfer_info & wti , uint64_t height , uint64_t timestamp , const currency : : transaction & tx , uint64_t amount , const money_transfer2_details & td ) ;
void prepare_wti_decrypted_attachments ( wallet_public : : wallet_transfer_info & wti , const std : : vector < currency : : payload_items_v > & decrypted_att ) ;
2018-12-27 18:50:45 +03:00
void handle_money_received2 ( const currency : : block & b ,
const currency : : transaction & tx ,
uint64_t amount ,
const money_transfer2_details & td ) ;
void handle_money_spent2 ( const currency : : block & b ,
const currency : : transaction & in_tx ,
uint64_t amount ,
const money_transfer2_details & td ,
const std : : vector < std : : string > & recipients ,
const std : : vector < std : : string > & recipients_aliases ) ;
void handle_pulled_blocks ( size_t & blocks_added , std : : atomic < bool > & stop ,
currency : : COMMAND_RPC_GET_BLOCKS_DIRECT : : response & blocks ) ;
std : : string get_alias_for_address ( const std : : string & addr ) ;
2022-06-16 17:02:00 +02:00
std : : vector < std : : string > get_aliases_for_address ( const std : : string & addr ) ;
2018-12-27 18:50:45 +03:00
bool is_connected_to_net ( ) ;
2022-10-23 23:48:43 +02:00
bool is_transfer_okay_for_pos ( const transfer_details & tr , bool is_zarcanum_hf , uint64_t & stake_unlock_time ) const ;
2018-12-27 18:50:45 +03:00
bool scan_unconfirmed_outdate_tx ( ) ;
const currency : : transaction & get_transaction_by_id ( const crypto : : hash & tx_hash ) ;
2019-08-27 17:36:53 +02:00
void rise_on_transfer2 ( const wallet_public : : wallet_transfer_info & wti ) ;
2018-12-27 18:50:45 +03:00
void process_genesis_if_needed ( const currency : : block & genesis ) ;
bool build_escrow_proposal ( bc_services : : contract_private_details & ecrow_details , uint64_t fee , uint64_t unlock_time , currency : : tx_service_attachment & att , std : : vector < uint64_t > & selected_indicies ) ;
2022-09-21 22:35:24 +02:00
bool prepare_tx_sources ( assets_selection_context & needed_money_map , size_t fake_outputs_count , uint64_t dust_threshold , std : : vector < currency : : tx_source_entry > & sources , std : : vector < uint64_t > & selected_indicies ) ;
2022-09-20 22:01:52 +02:00
bool prepare_tx_sources ( size_t fake_outputs_count , std : : vector < currency : : tx_source_entry > & sources , const std : : vector < uint64_t > & selected_indicies ) ;
2018-12-27 18:50:45 +03:00
bool prepare_tx_sources ( crypto : : hash multisig_id , std : : vector < currency : : tx_source_entry > & sources , uint64_t & found_money ) ;
2021-02-02 19:02:28 +01:00
bool prepare_tx_sources_htlc ( crypto : : hash htlc_tx_id , const std : : string & origin , std : : vector < currency : : tx_source_entry > & sources , uint64_t & found_money ) ;
2019-11-27 03:19:10 +01:00
bool prepare_tx_sources_for_packing ( uint64_t items_to_pack , size_t fake_outputs_count , std : : vector < currency : : tx_source_entry > & sources , std : : vector < uint64_t > & selected_indicies , uint64_t & found_money ) ;
2022-09-21 22:35:24 +02:00
void prefetch_global_indicies_if_needed ( const std : : vector < uint64_t > & selected_indicies ) ;
assets_selection_context get_needed_money ( uint64_t fee , const std : : vector < currency : : tx_destination_entry > & dsts ) ;
2022-09-20 22:01:52 +02:00
void prepare_tx_destinations ( const assets_selection_context & needed_money_map ,
detail : : split_strategy_id_t destination_split_strategy_id ,
const tx_dust_policy & dust_policy ,
const std : : vector < currency : : tx_destination_entry > & dsts ,
2022-10-01 21:17:17 +02:00
std : : vector < currency : : tx_destination_entry > & final_destinations ) ;
2018-12-27 18:50:45 +03:00
void prepare_tx_destinations ( uint64_t needed_money ,
uint64_t found_money ,
2019-04-03 12:48:09 +03:00
detail : : split_strategy_id_t destination_split_strategy_id ,
2018-12-27 18:50:45 +03:00
const tx_dust_policy & dust_policy ,
const std : : vector < currency : : tx_destination_entry > & dsts ,
2022-09-20 22:01:52 +02:00
std : : vector < currency : : tx_destination_entry > & final_detinations , const crypto : : hash & assed_id ) ;
2019-08-27 17:36:53 +02:00
bool handle_contract ( wallet_public : : wallet_transfer_info & wti , const bc_services : : contract_private_details & cntr , const std : : vector < currency : : payload_items_v > & decrypted_attach ) ;
bool handle_release_contract ( wallet_public : : wallet_transfer_info & wti , const std : : string & release_instruction ) ;
bool handle_cancel_proposal ( wallet_public : : wallet_transfer_info & wti , const bc_services : : escrow_cancel_templates_body & ectb , const std : : vector < currency : : payload_items_v > & decrypted_attach ) ;
2018-12-27 18:50:45 +03:00
bool handle_expiration_list ( uint64_t tx_expiration_ts_median ) ;
void handle_contract_expirations ( uint64_t tx_expiration_ts_median ) ;
2022-05-10 23:49:20 +02:00
uint64_t get_current_tx_version ( ) ;
2019-08-27 17:36:53 +02:00
void change_contract_state ( wallet_public : : escrow_contract_details_basic & contract , uint32_t new_state , const crypto : : hash & contract_id , const wallet_public : : wallet_transfer_info & wti ) const ;
void change_contract_state ( wallet_public : : escrow_contract_details_basic & contract , uint32_t new_state , const crypto : : hash & contract_id , const std : : string & reason = " internal intention " ) const ;
2022-09-20 22:01:52 +02:00
bool is_need_to_split_outputs ( ) ;
2022-06-28 22:27:36 +02:00
template < typename input_t >
bool process_input_t ( const input_t & in_t , wallet2 : : process_transaction_context & ptc , const currency : : transaction & tx ) ;
2021-07-17 00:05:41 +02:00
2022-10-13 00:07:40 +02:00
construct_tx_param get_default_construct_tx_param ( ) ;
2019-02-21 21:33:52 +03:00
2018-12-27 18:50:45 +03:00
uint64_t get_tx_expiration_median ( ) const ;
2019-04-08 14:16:11 +03:00
void print_tx_sent_message ( const currency : : transaction & tx , const std : : string & description , uint64_t fee = UINT64_MAX ) ;
2018-12-27 18:50:45 +03:00
// Validates escrow template tx in assumption it's related to wallet's account (wallet's account is either A or B party in escrow process)
2019-08-27 17:36:53 +02:00
bool validate_escrow_proposal ( const wallet_public : : wallet_transfer_info & wti , const bc_services : : proposal_body & prop ,
2018-12-27 18:50:45 +03:00
std : : vector < currency : : payload_items_v > & decrypted_items , crypto : : hash & ms_id , bc_services : : contract_private_details & cpd ) ;
2019-02-21 21:33:52 +03:00
bool validate_escrow_release ( const currency : : transaction & tx , bool release_type_normal , const bc_services : : contract_private_details & cpd ,
const currency : : txout_multisig & source_ms_out , const crypto : : hash & ms_id , size_t source_ms_out_index , const currency : : transaction & source_tx , const currency : : account_keys & a_keys ) const ;
2019-08-27 17:36:53 +02:00
bool validate_escrow_contract ( const wallet_public : : wallet_transfer_info & wti , const bc_services : : contract_private_details & cpd , bool is_a ,
2018-12-27 18:50:45 +03:00
const std : : vector < currency : : payload_items_v > & decrypted_items , crypto : : hash & ms_id , bc_services : : escrow_relese_templates_body & rtb ) ;
2019-08-27 17:36:53 +02:00
bool validate_escrow_cancel_release ( const currency : : transaction & tx , const wallet_public : : wallet_transfer_info & wti , const bc_services : : escrow_cancel_templates_body & ectb ,
2019-02-21 21:33:52 +03:00
const std : : vector < currency : : payload_items_v > & decrypted_items , crypto : : hash & ms_id , bc_services : : contract_private_details & cpd , const currency : : transaction & source_tx ,
size_t source_ms_out_index , const currency : : account_keys & b_keys , uint64_t minimum_release_fee ) const ;
2019-08-27 17:36:53 +02:00
bool validate_escrow_cancel_proposal ( const wallet_public : : wallet_transfer_info & wti , const bc_services : : escrow_cancel_templates_body & ectb ,
2018-12-27 18:50:45 +03:00
const std : : vector < currency : : payload_items_v > & decrypted_items , crypto : : hash & ms_id , bc_services : : contract_private_details & cpd ,
const currency : : transaction & proposal_template_tx ) ;
2019-07-24 19:14:35 +02:00
2019-08-27 17:36:53 +02:00
void fill_transfer_details ( const currency : : transaction & tx , const tools : : money_transfer2_details & td , tools : : wallet_public : : wallet_transfer_info_details & res_td ) const ;
2022-10-01 21:14:32 +02:00
void print_source_entry ( std : : stringstream & output , const currency : : tx_source_entry & src ) const ;
2019-02-21 21:33:52 +03:00
2019-02-27 00:59:02 +03:00
void init_log_prefix ( ) ;
2019-04-03 12:48:09 +03:00
void load_keys2ki ( bool create_if_not_exist , bool & need_to_resync ) ;
2018-12-27 18:50:45 +03:00
void send_transaction_to_network ( const currency : : transaction & tx ) ;
void add_sent_tx_detailed_info ( const currency : : transaction & tx ,
const std : : vector < currency : : tx_destination_entry > & destinations ,
const std : : vector < uint64_t > & selected_indicies ) ;
void mark_transfers_as_spent ( const std : : vector < uint64_t > & selected_transfers , const std : : string & reason = std : : string ( ) ) ;
2019-04-12 09:48:33 +03:00
void mark_transfers_with_flag ( const std : : vector < uint64_t > & selected_transfers , uint32_t flag , const std : : string & reason = std : : string ( ) , bool throw_if_flag_already_set = false ) ;
2019-12-13 18:42:15 +03:00
void clear_transfers_from_flag ( const std : : vector < uint64_t > & selected_transfers , uint32_t flag , const std : : string & reason = std : : string ( ) ) noexcept ;
2018-12-27 18:50:45 +03:00
void exception_handler ( ) ;
2019-04-12 09:48:33 +03:00
void exception_handler ( ) const ;
2018-12-27 18:50:45 +03:00
uint64_t get_minimum_allowed_fee_for_contract ( const crypto : : hash & ms_id ) ;
2019-11-28 23:34:24 +01:00
bool generate_packing_transaction_if_needed ( currency : : transaction & tx , uint64_t fake_outputs_number ) ;
2021-02-04 01:49:38 +01:00
bool store_unsigned_tx_to_file_and_reserve_transfers ( const currency : : finalize_tx_param & ftp , const std : : string & filename , std : : string * p_unsigned_tx_blob_str = nullptr ) ;
2020-01-23 20:24:22 +03:00
void check_and_throw_if_self_directed_tx_with_payment_id_requested ( const construct_tx_param & ctp ) ;
2020-04-24 01:05:36 +02:00
void push_new_block_id ( const crypto : : hash & id , uint64_t height ) ;
2020-04-24 19:18:19 +02:00
bool lookup_item_around ( uint64_t i , std : : pair < uint64_t , crypto : : hash > & result ) ;
2020-05-01 20:39:39 +02:00
//void get_short_chain_history(std::list<crypto::hash>& ids);
//void check_if_block_matched(uint64_t i, const crypto::hash& id, bool& block_found, bool& block_matched, bool& full_reset_needed);
2020-04-25 00:30:55 +02:00
uint64_t detach_from_block_ids ( uint64_t height ) ;
2020-04-28 00:40:31 +02:00
uint64_t get_wallet_minimum_height ( ) ;
2022-06-28 22:27:36 +02:00
uint64_t get_directly_spent_transfer_index_by_input_in_tracking_wallet ( uint64_t amount , const std : : vector < currency : : txout_ref_v > & key_offsets ) ;
uint64_t get_directly_spent_transfer_index_by_input_in_tracking_wallet ( const currency : : txin_to_key & intk ) ;
2022-08-03 14:00:39 +02:00
uint64_t get_directly_spent_transfer_index_by_input_in_tracking_wallet ( const currency : : txin_zc_input & inzc ) ;
2022-10-12 17:54:42 +02:00
bool is_in_hardfork_zone ( uint64_t hardfork_index ) const ;
2022-07-04 15:27:41 +02:00
uint8_t out_get_mixin_attr ( const currency : : tx_out_v & out_t ) ;
2022-07-01 17:19:57 +02:00
const crypto : : public_key & out_get_pub_key ( const currency : : tx_out_v & out_t , std : : list < currency : : htlc_info > & htlc_info_list ) ;
2018-12-27 18:50:45 +03:00
2020-05-20 17:39:42 +03:00
void push_alias_info_to_extra_according_to_hf_status ( const currency : : extra_alias_entry & ai , std : : vector < currency : : extra_v > & extra ) ;
2020-05-25 15:05:25 +03:00
void remove_transfer_from_amount_gindex_map ( uint64_t tid ) ;
2022-06-16 17:02:00 +02:00
uint64_t get_alias_cost ( const std : : string & alias ) ;
2022-09-21 22:35:24 +02:00
detail : : split_strategy_id_t get_current_split_strategy ( ) ;
2020-05-20 17:39:42 +03:00
2021-10-20 21:18:21 +02:00
static void wti_to_csv_entry ( std : : ostream & ss , const wallet_public : : wallet_transfer_info & wti , size_t index ) ;
static void wti_to_txt_line ( std : : ostream & ss , const wallet_public : : wallet_transfer_info & wti , size_t index ) ;
static void wti_to_json_line ( std : : ostream & ss , const wallet_public : : wallet_transfer_info & wti , size_t index ) ;
2018-12-27 18:50:45 +03:00
currency : : account_base m_account ;
2019-04-03 12:48:09 +03:00
bool m_watch_only ;
2019-02-21 21:33:52 +03:00
std : : string m_log_prefix ; // part of pub address, prefix for logging functions
2018-12-27 18:50:45 +03:00
std : : wstring m_wallet_file ;
2019-04-03 12:48:09 +03:00
std : : wstring m_pending_ki_file ;
2018-12-27 18:50:45 +03:00
std : : string m_password ;
2020-04-28 00:40:31 +02:00
uint64_t m_minimum_height ;
2020-04-24 01:05:36 +02:00
2018-12-27 18:50:45 +03:00
std : : atomic < uint64_t > m_last_bc_timestamp ;
bool m_do_rise_transfer ;
2019-11-29 21:43:17 +01:00
uint64_t m_pos_mint_packing_size ;
2018-12-27 18:50:45 +03:00
transfer_container m_transfers ;
multisig_transfer_container m_multisig_transfers ;
2020-05-25 15:05:25 +03:00
amount_gindex_to_transfer_id_container m_amount_gindex_to_transfer_id ;
2018-12-27 18:50:45 +03:00
payment_container m_payments ;
std : : unordered_map < crypto : : key_image , size_t > m_key_images ;
2019-04-03 12:48:09 +03:00
std : : unordered_map < crypto : : public_key , crypto : : key_image > m_pending_key_images ; // (out_pk -> ki) pairs of change outputs to be added in watch-only wallet without spend sec key
pending_ki_file_container_t m_pending_key_images_file_container ;
2018-12-27 18:50:45 +03:00
uint64_t m_upper_transaction_size_limit ; //TODO: auto-calc this value or request from daemon, now use some fixed value
std : : atomic < bool > m_stop ;
2019-08-27 17:36:53 +02:00
std : : vector < wallet_public : : wallet_transfer_info > m_transfer_history ;
2018-12-27 18:50:45 +03:00
std : : unordered_map < crypto : : hash , currency : : transaction > m_unconfirmed_in_transfers ;
2019-08-27 17:36:53 +02:00
std : : unordered_map < crypto : : hash , tools : : wallet_public : : wallet_transfer_info > m_unconfirmed_txs ;
2018-12-27 18:50:45 +03:00
std : : unordered_set < crypto : : hash > m_unconfirmed_multisig_transfers ;
2019-04-03 12:48:09 +03:00
std : : unordered_map < crypto : : hash , crypto : : secret_key > m_tx_keys ;
2022-09-27 20:13:49 +02:00
std : : unordered_map < crypto : : hash , wallet_own_asset_context > m_own_asset_descriptors ;
2022-11-15 21:54:55 +01:00
std : : unordered_map < crypto : : hash , currency : : asset_descriptor_base > m_custom_assets ; //assets that manually added by user
2022-11-28 22:10:50 +01:00
mutable std : : unordered_map < crypto : : hash , currency : : asset_descriptor_base > m_whitelisted_assets ; //assets that whitelisted
2022-11-15 21:54:55 +01:00
2018-12-27 18:50:45 +03:00
2021-01-31 18:05:26 +01:00
std : : multimap < uint64_t , htlc_expiration_trigger > m_htlcs ; //map [expired_if_more_then] -> height of expiration
2021-01-27 22:49:15 +01:00
amount_gindex_to_transfer_id_container m_active_htlcs ; // map [amount; gindex] -> transfer index
std : : unordered_map < crypto : : hash , uint64_t > m_active_htlcs_txid ; // map [txid] -> transfer index, limitation: 1 transactiom -> 1 htlc
2021-01-24 21:00:43 +01:00
2018-12-27 18:50:45 +03:00
std : : shared_ptr < i_core_proxy > m_core_proxy ;
std : : shared_ptr < i_wallet2_callback > m_wcallback ;
uint64_t m_height_of_start_sync ;
2020-01-17 23:44:22 +01:00
std : : atomic < uint64_t > m_last_sync_percent ;
2019-07-20 14:36:12 +02:00
uint64_t m_last_pow_block_h ;
2018-12-27 18:50:45 +03:00
currency : : core_runtime_config m_core_runtime_config ;
escrow_contracts_container m_contracts ;
2020-04-29 01:23:48 +02:00
wallet_chain_shortener m_chain ;
2018-12-27 18:50:45 +03:00
std : : list < expiration_entry_info > m_money_expirations ;
//optimization for big wallets and batch tx
2022-09-20 22:01:52 +02:00
free_assets_amounts_cache_type m_found_free_amounts ;
2018-12-27 18:50:45 +03:00
uint64_t m_fake_outputs_count ;
std : : string m_miner_text_info ;
2020-06-03 21:29:43 +02:00
mutable uint64_t m_current_wallet_file_size ;
2020-06-13 21:04:21 +02:00
bool m_use_deffered_global_outputs ;
2022-03-19 04:12:13 +02:00
bool m_disable_tor_relay ;
2019-08-03 19:15:56 +02:00
//this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions
friend class test_generator ;
2018-12-27 18:50:45 +03:00
2019-04-03 12:48:09 +03:00
} ; // class wallet2
2018-12-27 18:50:45 +03:00
2019-04-03 12:48:09 +03:00
} // namespace tools
2018-12-27 18:50:45 +03:00
BOOST_CLASS_VERSION ( tools : : wallet2 , WALLET_FILE_SERIALIZATION_VERSION )
2022-09-27 20:13:49 +02:00
2022-09-15 22:05:10 +02:00
BOOST_CLASS_VERSION ( tools : : wallet_public : : wallet_transfer_info , 11 )
2021-02-14 00:28:39 +01:00
BOOST_CLASS_VERSION ( tools : : wallet2 : : transfer_details , 3 )
2022-06-30 21:47:59 +02:00
BOOST_CLASS_VERSION ( tools : : wallet2 : : transfer_details_base , 2 )
2018-12-27 18:50:45 +03:00
namespace boost
{
namespace serialization
{
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : transaction_wallet_info & x , const boost : : serialization : : version_type ver )
{
a & x . m_block_height ;
a & x . m_block_timestamp ;
a & x . m_tx ;
}
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : transfer_details_base & x , const boost : : serialization : : version_type ver )
{
a & x . m_ptx_wallet_info ;
a & x . m_internal_output_index ;
a & x . m_flags ;
a & x . m_spent_height ;
2022-06-30 21:47:59 +02:00
if ( ver < 2 )
{
x . m_amount = currency : : get_tx_out_bare_from_out_v ( x . m_ptx_wallet_info - > m_tx . vout [ x . m_internal_output_index ] ) . amount ;
return ;
}
a & x . m_amount ;
2022-09-14 20:54:05 +02:00
a & x . m_opt_blinding_mask ;
a & x . m_asset_id ;
2018-12-27 18:50:45 +03:00
}
2021-02-15 02:17:59 +01:00
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : transfer_details_extra_option_htlc_info & x , const boost : : serialization : : version_type ver )
{
a & x . origin ;
}
2018-12-27 18:50:45 +03:00
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : transfer_details & x , const boost : : serialization : : version_type ver )
{
a & x . m_global_output_index ;
a & x . m_key_image ;
a & static_cast < tools : : wallet2 : : transfer_details_base & > ( x ) ;
2021-02-14 00:28:39 +01:00
if ( ver < 3 )
return ;
a & x . varian_options ;
2018-12-27 18:50:45 +03:00
}
2021-01-31 19:42:02 +01:00
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : htlc_expiration_trigger & x , const boost : : serialization : : version_type ver )
{
a & x . is_wallet_owns_redeem ;
a & x . transfer_index ;
}
2018-12-27 18:50:45 +03:00
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : payment_details & x , const boost : : serialization : : version_type ver )
{
a & x . m_tx_hash ;
a & x . m_amount ;
a & x . m_block_height ;
a & x . m_unlock_time ;
}
template < class Archive >
2019-08-27 17:36:53 +02:00
inline void serialize ( Archive & a , tools : : wallet_public : : wallet_transfer_info_details & x , const boost : : serialization : : version_type ver )
2018-12-27 18:50:45 +03:00
{
a & x . rcv ;
a & x . spn ;
}
template < class Archive >
2019-08-27 17:36:53 +02:00
inline void serialize ( Archive & a , tools : : wallet_public : : wallet_transfer_info & x , const boost : : serialization : : version_type ver )
2018-12-27 18:50:45 +03:00
{
a & x . amount ;
a & x . timestamp ;
a & x . tx_hash ;
a & x . height ;
a & x . tx_blob_size ;
a & x . payment_id ;
a & x . remote_addresses ;
a & x . is_income ;
a & x . td ;
a & x . tx ;
2022-06-16 17:33:37 +02:00
a & x . remote_aliases ;
2018-12-27 18:50:45 +03:00
a & x . comment ;
a & x . contract ;
a & x . selected_indicies ;
2021-06-24 22:10:09 +02:00
a & x . marketplace_entries ;
2019-08-03 00:22:04 +02:00
a & x . unlock_time ;
2021-06-24 22:10:09 +02:00
if ( ver < 10 )
return ;
a & x . service_entries ;
2022-09-15 22:05:10 +02:00
if ( ver < 11 )
return ;
a & x . asset_id ;
2018-12-27 18:50:45 +03:00
}
template < class Archive >
2019-08-27 17:36:53 +02:00
inline void serialize ( Archive & a , tools : : wallet_public : : escrow_contract_details_basic & x , const boost : : serialization : : version_type ver )
2018-12-27 18:50:45 +03:00
{
a & x . state ;
a & x . is_a ;
a & x . private_detailes ;
a & x . expiration_time ;
a & x . cancel_expiration_time ;
a & x . timestamp ;
a & x . height ;
a & x . payment_id ;
//is not kv_serialization map
a & x . proposal ;
a & x . release_body ;
a & x . cancel_body ;
}
template < class Archive >
2019-08-27 17:36:53 +02:00
inline void serialize ( Archive & a , tools : : wallet_public : : escrow_contract_details & x , const boost : : serialization : : version_type ver )
2018-12-27 18:50:45 +03:00
{
2019-08-27 17:36:53 +02:00
a & static_cast < tools : : wallet_public : : escrow_contract_details_basic & > ( x ) ;
2018-12-27 18:50:45 +03:00
a & x . contract_id ;
}
template < class Archive >
inline void serialize ( Archive & a , tools : : wallet2 : : expiration_entry_info & x , const boost : : serialization : : version_type ver )
{
a & x . expiration_time ;
a & x . change_amount ;
a & x . selected_transfers ;
a & x . related_tx_id ;
}
}
}
namespace tools
{
2022-06-28 22:27:36 +02:00
template < typename input_t >
bool wallet2 : : process_input_t ( const input_t & in_t , wallet2 : : process_transaction_context & ptc , const currency : : transaction & tx )
{
// check if this input spends our output
uint64_t tr_index = UINT64_MAX ;
if ( this - > is_auditable ( ) & & this - > is_watch_only ( ) )
{
// tracking wallet, assuming all outputs are spent directly because of mix_attr = 1
tr_index = this - > get_directly_spent_transfer_index_by_input_in_tracking_wallet ( in_t ) ;
}
else
{
// wallet with spend secret key -- we can calculate own key images and then search by them
auto it = m_key_images . find ( in_t . k_image ) ;
if ( it ! = m_key_images . end ( ) )
{
tr_index = it - > second ;
}
}
if ( tr_index ! = UINT64_MAX )
{
transfer_details & td = m_transfers [ tr_index ] ;
ptc . tx_money_spent_in_ins + = td . amount ( ) ;
uint32_t flags_before = td . m_flags ;
td . m_flags | = WALLET_TRANSFER_DETAIL_FLAG_SPENT ;
td . m_spent_height = ptc . height ;
if ( ptc . coin_base_tx & & td . m_flags & WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER )
ptc . is_derived_from_coinbase = true ;
else
ptc . is_derived_from_coinbase = false ;
2022-11-24 21:54:43 +01:00
WLT_LOG_L0 ( " Spent key out, transfer # " < < tr_index < < " , amount: " < < currency : : print_money_brief ( td . amount ( ) ) < < " , with tx: " < < get_transaction_hash ( tx ) < < " , at height " < < ptc . height < <
2022-06-28 22:27:36 +02:00
" ; flags: " < < flags_before < < " -> " < < td . m_flags ) ;
ptc . mtd . spent_indices . push_back ( ptc . i ) ;
remove_transfer_from_expiration_list ( tr_index ) ;
}
2022-06-28 22:29:52 +02:00
return true ;
2022-06-28 22:27:36 +02:00
}
2018-12-27 18:50:45 +03:00
template < typename idle_condition_cb_t > //do refresh as external callback
bool wallet2 : : scan_pos ( mining_context & cxt ,
std : : atomic < bool > & stop ,
idle_condition_cb_t idle_condition_cb ,
const currency : : core_runtime_config & runtime_config )
{
2022-09-09 20:16:14 +02:00
cxt . status = API_RETURN_CODE_NOT_FOUND ;
2018-12-27 18:50:45 +03:00
uint64_t timstamp_last_idle_call = runtime_config . get_core_time ( ) ;
2022-08-29 23:00:34 +02:00
cxt . iterations_processed = 0 ;
2018-12-27 18:50:45 +03:00
2022-09-09 20:16:14 +02:00
uint64_t ts_from = cxt . starter_timestamp ; // median ts of last BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW blocks
2021-10-08 08:08:58 +03:00
ts_from = ts_from - ( ts_from % POS_SCAN_STEP ) + POS_SCAN_STEP ;
uint64_t ts_to = runtime_config . get_core_time ( ) + CURRENCY_POS_BLOCK_FUTURE_TIME_LIMIT - 5 ;
ts_to = ts_to - ( ts_to % POS_SCAN_STEP ) ;
CHECK_AND_ASSERT_MES ( ts_to > ts_from , false , " scan_pos: ts_to <= ts_from: " < < ts_to < < " , " < < ts_from ) ;
uint64_t ts_middle = ( ts_to + ts_from ) / 2 ;
ts_middle - = ts_middle % POS_SCAN_STEP ;
uint64_t ts_window = std : : min ( ts_middle - ts_from , ts_to - ts_middle ) ;
2022-09-05 12:30:08 +02:00
size_t pos_entry_index = 0 ;
for ( size_t transfer_index = 0 ; transfer_index ! = m_transfers . size ( ) ; transfer_index + + )
2018-12-27 18:50:45 +03:00
{
2022-09-05 12:30:08 +02:00
auto & tr = m_transfers [ transfer_index ] ;
uint64_t stake_unlock_time = 0 ;
2022-10-23 23:48:43 +02:00
if ( ! is_transfer_okay_for_pos ( tr , cxt . zarcanum , stake_unlock_time ) )
2022-09-05 12:30:08 +02:00
continue ;
2022-09-05 20:18:27 +02:00
2018-12-27 18:50:45 +03:00
bool go_past = true ;
uint64_t step = 0 ;
auto next_turn = [ & ] ( ) {
if ( ! step )
{
step + = POS_SCAN_STEP ;
}
else if ( go_past )
{
go_past = false ;
}
else
{
go_past = true ;
step + = POS_SCAN_STEP ;
}
} ;
2022-09-05 12:30:08 +02:00
do_pos_mining_prepare_entry ( cxt , transfer_index ) ;
2022-09-06 19:41:20 +02:00
cxt . total_items_checked + + ;
cxt . total_amount_checked + = tr . amount ( ) ;
2021-10-08 08:08:58 +03:00
while ( step < = ts_window )
2018-12-27 18:50:45 +03:00
{
2022-08-26 18:12:32 +02:00
//check every WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL seconds wheither top block changed, if so - break the loop
2018-12-27 18:50:45 +03:00
if ( runtime_config . get_core_time ( ) - timstamp_last_idle_call > WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL )
{
if ( ! idle_condition_cb ( ) )
{
LOG_PRINT_L0 ( " Detected new block, minting interrupted " ) ;
2022-09-09 20:16:14 +02:00
cxt . status = API_RETURN_CODE_NOT_FOUND ;
2018-12-27 18:50:45 +03:00
return false ;
}
timstamp_last_idle_call = runtime_config . get_core_time ( ) ;
}
2021-10-08 08:08:58 +03:00
uint64_t ts = go_past ? ts_middle - step : ts_middle + step ;
if ( ts < ts_from | | ts > ts_to )
2018-12-27 18:50:45 +03:00
{
next_turn ( ) ;
continue ;
}
PROFILE_FUNC ( " general_mining_iteration " ) ;
if ( stop )
return false ;
2022-09-05 20:18:27 +02:00
cxt . iterations_processed + + ;
2022-09-05 12:30:08 +02:00
if ( do_pos_mining_iteration ( cxt , transfer_index , ts ) )
2018-12-27 18:50:45 +03:00
{
2022-09-09 20:16:14 +02:00
cxt . index = transfer_index ;
cxt . stake_unlock_time = stake_unlock_time ;
cxt . status = API_RETURN_CODE_OK ;
2018-12-27 18:50:45 +03:00
return true ;
}
next_turn ( ) ;
}
2022-09-05 12:30:08 +02:00
+ + pos_entry_index ;
2018-12-27 18:50:45 +03:00
}
2022-09-09 20:16:14 +02:00
cxt . status = API_RETURN_CODE_NOT_FOUND ;
2018-12-27 18:50:45 +03:00
return false ;
}
2020-04-07 14:28:57 +03:00
template < typename callback_t >
void wallet2 : : enumerate_transfers_history ( callback_t cb , bool enumerate_forward ) const
{
if ( enumerate_forward )
{
for ( auto it = m_transfer_history . begin ( ) ; it ! = m_transfer_history . end ( ) ; + + it )
if ( ! cb ( * it ) )
break ;
}
else
{
for ( auto it = m_transfer_history . rbegin ( ) ; it ! = m_transfer_history . rend ( ) ; + + it )
if ( ! cb ( * it ) )
break ;
}
}
template < typename callback_t >
void wallet2 : : enumerate_unconfirmed_transfers ( callback_t cb ) const
{
for ( auto & el : m_unconfirmed_txs )
if ( ! cb ( el . second ) )
break ;
}
2019-04-03 12:48:09 +03:00
} // namespace tools
2018-12-27 18:50:45 +03:00
2019-02-21 21:33:52 +03:00
# if !defined(KEEP_WALLET_LOG_MACROS)
2020-08-09 01:30:34 +03:00
# undef WLT_LOG
2019-02-21 21:33:52 +03:00
# undef WLT_LOG_L0
# undef WLT_LOG_L1
# undef WLT_LOG_L2
# undef WLT_LOG_L3
# undef WLT_LOG_L4
# undef WLT_LOG_ERROR
# undef WLT_LOG_BLUE
# undef WLT_LOG_CYAN
# undef WLT_LOG_GREEN
# undef WLT_LOG_MAGENTA
# undef WLT_LOG_RED
# undef WLT_LOG_YELLOW
# undef WLT_CHECK_AND_ASSERT_MES
# undef WLT_CHECK_AND_ASSERT_MES_NO_RET
2020-08-07 17:30:12 +03:00
# undef WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX
# undef WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX
# undef WLT_THROW_IF_FALSE_WALLET_EX_MES
2019-02-21 21:33:52 +03:00
# endif
2018-12-27 18:50:45 +03:00
# undef LOG_DEFAULT_CHANNEL
# define LOG_DEFAULT_CHANNEL "wallet"
2019-02-20 07:19:02 +00:00
ENABLE_CHANNEL_BY_DEFAULT ( " wallet " ) ;