@ -2035,6 +2035,7 @@ void wallet2::update_pool_state(bool refreshed)
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( p . first ) ) ;
MDEBUG ( " asking for " < < txids . size ( ) < < " transactions " ) ;
req . decode_as_json = false ;
req . prune = false ;
m_daemon_rpc_mutex . lock ( ) ;
bool r = epee : : net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client , rpc_timeout ) ;
m_daemon_rpc_mutex . unlock ( ) ;
@ -5633,39 +5634,49 @@ bool wallet2::find_and_save_rings(bool force)
MDEBUG ( " Finding and saving rings... " ) ;
// get payments we made
std : : vector < crypto : : hash > txs_hashes ;
std : : list < std : : pair < crypto : : hash , wallet2 : : confirmed_transfer_details > > payments ;
get_payments_out ( payments , 0 , std : : numeric_limits < uint64_t > : : max ( ) , boost : : none , std : : set < uint32_t > ( ) ) ;
for ( const std : : pair < crypto : : hash , wallet2 : : confirmed_transfer_details > & entry : payments )
{
const crypto : : hash & txid = entry . first ;
req. txs_hashes. push_back ( epee: : string_tools : : pod_to_hex ( txid) ) ;
txs_hashes. push_back ( txid) ;
}
MDEBUG ( " Found " < < std : : to_string ( req . txs_hashes . size ( ) ) < < " transactions " ) ;
// get those transactions from the daemon
req . decode_as_json = false ;
bool r ;
{
const boost : : lock_guard < boost : : mutex > lock { m_daemon_rpc_mutex } ;
r = epee : : net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client , rpc_timeout ) ;
}
THROW_WALLET_EXCEPTION_IF ( ! r , error : : no_connection_to_daemon , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . status = = CORE_RPC_STATUS_BUSY , error : : daemon_busy , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . status ! = CORE_RPC_STATUS_OK , error : : wallet_internal_error , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . txs . size ( ) ! = req . txs_hashes . size ( ) , error : : wallet_internal_error ,
" daemon returned wrong response for gettransactions, wrong txs count = " +
std : : to_string ( res . txs . size ( ) ) + " , expected " + std : : to_string ( req . txs_hashes . size ( ) ) ) ;
MDEBUG ( " Scanning " < < res . txs . size ( ) < < " transactions " ) ;
MDEBUG ( " Found " < < std : : to_string ( txs_hashes . size ( ) ) < < " transactions " ) ;
crypto : : chacha_key key ;
generate_chacha_key_from_secret_keys ( key ) ;
auto it = req . txs_hashes . begin ( ) ;
for ( size_t i = 0 ; i < res . txs . size ( ) ; + + i , + + it )
// get those transactions from the daemon
static const size_t SLICE_SIZE = 200 ;
for ( size_t slice = 0 ; slice < txs_hashes . size ( ) ; slice + = SLICE_SIZE )
{
req . decode_as_json = false ;
req . prune = true ;
req . txs_hashes . clear ( ) ;
size_t ntxes = slice + SLICE_SIZE > txs_hashes . size ( ) ? txs_hashes . size ( ) - slice : SLICE_SIZE ;
for ( size_t s = slice ; s < slice + ntxes ; + + s )
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txs_hashes [ s ] ) ) ;
bool r ;
{
const boost : : lock_guard < boost : : mutex > lock { m_daemon_rpc_mutex } ;
r = epee : : net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client , rpc_timeout ) ;
}
THROW_WALLET_EXCEPTION_IF ( ! r , error : : no_connection_to_daemon , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . status = = CORE_RPC_STATUS_BUSY , error : : daemon_busy , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . status ! = CORE_RPC_STATUS_OK , error : : wallet_internal_error , " gettransactions " ) ;
THROW_WALLET_EXCEPTION_IF ( res . txs . size ( ) ! = req . txs_hashes . size ( ) , error : : wallet_internal_error ,
" daemon returned wrong response for gettransactions, wrong txs count = " +
std : : to_string ( res . txs . size ( ) ) + " , expected " + std : : to_string ( req . txs_hashes . size ( ) ) ) ;
MDEBUG ( " Scanning " < < res . txs . size ( ) < < " transactions " ) ;
THROW_WALLET_EXCEPTION_IF ( slice + res . txs . size ( ) > txs_hashes . size ( ) , error : : wallet_internal_error , " Unexpected tx array size " ) ;
auto it = req . txs_hashes . begin ( ) ;
for ( size_t i = 0 ; i < res . txs . size ( ) ; + + i , + + it )
{
const auto & tx_info = res . txs [ i ] ;
THROW_WALLET_EXCEPTION_IF ( tx_info . tx_hash ! = epee : : string_tools : : pod_to_hex ( txs_hashes [ slice + i ] ) , error : : wallet_internal_error , " Wrong txid received " ) ;
THROW_WALLET_EXCEPTION_IF ( tx_info . tx_hash ! = * it , error : : wallet_internal_error , " Wrong txid received " ) ;
cryptonote : : blobdata bd ;
THROW_WALLET_EXCEPTION_IF ( ! epee : : string_tools : : parse_hexstr_to_binbuff ( tx_info . as_hex , bd ) , error : : wallet_internal_error , " failed to parse tx from hexstr " ) ;
@ -5674,9 +5685,10 @@ bool wallet2::find_and_save_rings(bool force)
THROW_WALLET_EXCEPTION_IF ( ! cryptonote : : parse_and_validate_tx_from_blob ( bd , tx , tx_hash , tx_prefix_hash ) , error : : wallet_internal_error , " failed to parse tx from blob " ) ;
THROW_WALLET_EXCEPTION_IF ( epee : : string_tools : : pod_to_hex ( tx_hash ) ! = tx_info . tx_hash , error : : wallet_internal_error , " txid mismatch " ) ;
THROW_WALLET_EXCEPTION_IF ( ! add_rings ( key , tx ) , error : : wallet_internal_error , " Failed to save ring " ) ;
}
}
MINFO ( " Found and saved rings for " < < res. txs. size ( ) < < " transactions " ) ;
MINFO ( " Found and saved rings for " < < txs_hashe s. size ( ) < < " transactions " ) ;
m_ring_history_saved = true ;
return true ;
}
@ -8242,6 +8254,7 @@ std::string wallet2::get_spend_proof(const crypto::hash &txid, const std::string
COMMAND_RPC_GET_TRANSACTIONS : : request req = AUTO_VAL_INIT ( req ) ;
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txid ) ) ;
req . decode_as_json = false ;
req . prune = false ;
COMMAND_RPC_GET_TRANSACTIONS : : response res = AUTO_VAL_INIT ( res ) ;
bool r ;
{
@ -8361,6 +8374,7 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
COMMAND_RPC_GET_TRANSACTIONS : : request req = AUTO_VAL_INIT ( req ) ;
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txid ) ) ;
req . decode_as_json = false ;
req . prune = false ;
COMMAND_RPC_GET_TRANSACTIONS : : response res = AUTO_VAL_INIT ( res ) ;
bool r ;
{
@ -8483,6 +8497,8 @@ void wallet2::check_tx_key_helper(const crypto::hash &txid, const crypto::key_de
COMMAND_RPC_GET_TRANSACTIONS : : request req ;
COMMAND_RPC_GET_TRANSACTIONS : : response res ;
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txid ) ) ;
req . decode_as_json = false ;
req . prune = false ;
m_daemon_rpc_mutex . lock ( ) ;
bool ok = epee : : net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client ) ;
m_daemon_rpc_mutex . unlock ( ) ;
@ -8619,6 +8635,8 @@ std::string wallet2::get_tx_proof(const crypto::hash &txid, const cryptonote::ac
COMMAND_RPC_GET_TRANSACTIONS : : request req ;
COMMAND_RPC_GET_TRANSACTIONS : : response res ;
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txid ) ) ;
req . decode_as_json = false ;
req . prune = false ;
m_daemon_rpc_mutex . lock ( ) ;
bool ok = net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client ) ;
m_daemon_rpc_mutex . unlock ( ) ;
@ -8729,6 +8747,8 @@ bool wallet2::check_tx_proof(const crypto::hash &txid, const cryptonote::account
COMMAND_RPC_GET_TRANSACTIONS : : request req ;
COMMAND_RPC_GET_TRANSACTIONS : : response res ;
req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( txid ) ) ;
req . decode_as_json = false ;
req . prune = false ;
m_daemon_rpc_mutex . lock ( ) ;
bool ok = net_utils : : invoke_http_json ( " /gettransactions " , req , res , m_http_client ) ;
m_daemon_rpc_mutex . unlock ( ) ;
@ -8962,6 +8982,8 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
COMMAND_RPC_GET_TRANSACTIONS : : response gettx_res ;
for ( size_t i = 0 ; i < proofs . size ( ) ; + + i )
gettx_req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( proofs [ i ] . txid ) ) ;
gettx_req . decode_as_json = false ;
gettx_req . prune = false ;
m_daemon_rpc_mutex . lock ( ) ;
bool ok = net_utils : : invoke_http_json ( " /gettransactions " , gettx_req , gettx_res , m_http_client ) ;
m_daemon_rpc_mutex . unlock ( ) ;
@ -9536,6 +9558,7 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
COMMAND_RPC_GET_TRANSACTIONS : : request gettxs_req ;
COMMAND_RPC_GET_TRANSACTIONS : : response gettxs_res ;
gettxs_req . decode_as_json = false ;
gettxs_req . prune = false ;
for ( const crypto : : hash & spent_txid : spent_txids )
gettxs_req . txs_hashes . push_back ( epee : : string_tools : : pod_to_hex ( spent_txid ) ) ;
m_daemon_rpc_mutex . lock ( ) ;