From 7ac1db42c2787605688d3a7bac8308286617ecfe Mon Sep 17 00:00:00 2001 From: luigi1111 Date: Sat, 5 Mar 2016 13:30:48 -0600 Subject: get_payments short ID Add support for short/integrated/encrypted IDs to get_payments RPC --- src/wallet/wallet_rpc_server.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index e8e062e95..ac13d8021 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -461,6 +461,7 @@ namespace tools bool wallet_rpc_server::on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er) { crypto::hash payment_id; + crypto::hash8 payment_id8; cryptonote::blobdata payment_id_blob; if(!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id_blob)) { @@ -469,14 +470,22 @@ namespace tools return false; } - if(sizeof(payment_id) != payment_id_blob.size()) - { - er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; - er.message = "Payment ID has invalid size"; - return false; - } - - payment_id = *reinterpret_cast(payment_id_blob.data()); + if(sizeof(payment_id) == payment_id_blob.size()) + { + payment_id = *reinterpret_cast(payment_id_blob.data()); + } + else if(sizeof(payment_id8) == payment_id_blob.size()) + { + payment_id8 = *reinterpret_cast(payment_id_blob.data()); + memcpy(payment_id.data, payment_id8.data, 8); + memset(payment_id.data + 8, 0, 24); + } + else + { + er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; + er.message = "Payment ID has invalid size: " + req.payment_id; + return false; + } res.payments.clear(); std::list payment_list; -- cgit v1.2.3 From 590c43988c1c69ea046cefd8125aae00cc2cccca Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 29 Apr 2016 06:21:08 +0100 Subject: Make fast_refresh interruptible --- src/wallet/wallet2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 53ce23490..1656089c8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -796,7 +796,8 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, { std::list hashes; size_t current_index = m_blockchain.size(); - while(current_index < stop_height) + + while(m_run.load(std::memory_order_relaxed) && current_index < stop_height) { pull_hashes(0, blocks_start_height, short_chain_history, hashes); if (hashes.size() < 3) @@ -860,6 +861,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re // pull the first set of blocks get_short_chain_history(short_chain_history); + m_run.store(true, std::memory_order_relaxed); if (start_height > m_blockchain.size() || m_refresh_from_block_height > m_blockchain.size()) { if (!start_height) start_height = m_refresh_from_block_height; @@ -877,7 +879,6 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re // subsequent pulls in this refresh. start_height = 0; - m_run.store(true, std::memory_order_relaxed); while(m_run.load(std::memory_order_relaxed)) { try -- cgit v1.2.3 From cebb97c9132f8666059980f2c140b29c30436691 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 29 Apr 2016 15:17:12 +0100 Subject: Move refresh height to keys file from cache file --- src/wallet/wallet2.cpp | 6 ++++++ src/wallet/wallet2.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1656089c8..80b8da1f9 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1058,6 +1058,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p value2.SetInt(m_refresh_type); json.AddMember("refresh_type", value2, json.GetAllocator()); + value2.SetUint64(m_refresh_from_block_height); + json.AddMember("refresh_height", value2, json.GetAllocator()); + // Serialize the JSON object rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); @@ -1164,6 +1167,9 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa else LOG_PRINT_L0("Unknown refresh-type value (" << field_refresh_type << "), using default"); } + GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false); + if (field_refresh_height_found) + m_refresh_from_block_height = field_refresh_height; } const cryptonote::account_keys& keys = m_account.get_keys(); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 846a86ef8..c2d387acd 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -308,6 +308,7 @@ namespace tools template inline void serialize(t_archive &a, const unsigned int ver) { + uint64_t dummy_refresh_height = 0; // moved to keys file if(ver < 5) return; a & m_blockchain; @@ -328,7 +329,7 @@ namespace tools a & m_confirmed_txs; if(ver < 11) return; - a & m_refresh_from_block_height; + a & dummy_refresh_height; if(ver < 12) return; a & m_tx_notes; -- cgit v1.2.3 From f1e70d15ca2ed63f6bdd84a8f4726c22c97f480b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 29 Apr 2016 16:50:51 +0100 Subject: Only log 1/N skipped blocks --- src/wallet/wallet2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 80b8da1f9..a9a646b74 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -519,7 +519,8 @@ void wallet2::process_new_blockchain_entry(const cryptonote::block& b, const cry LOG_PRINT_L2("Processed block: " << bl_id << ", height " << height << ", " << miner_tx_handle_time + txs_handle_time << "(" << miner_tx_handle_time << "/" << txs_handle_time <<")ms"); }else { - LOG_PRINT_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime()); + if (!(height % 100)) + LOG_PRINT_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime()); } m_blockchain.push_back(bl_id); ++m_local_bc_height; @@ -824,7 +825,8 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, { if(current_index >= m_blockchain.size()) { - LOG_PRINT_L2( "Skipped block by height: " << current_index); + if (!(current_index % 1000)) + LOG_PRINT_L2( "Skipped block by height: " << current_index); m_blockchain.push_back(bl_id); ++m_local_bc_height; -- cgit v1.2.3