diff options
author | j-berman <justinberman@protonmail.com> | 2022-09-09 20:34:18 -0600 |
---|---|---|
committer | j-berman <justinberman@protonmail.com> | 2023-06-15 02:21:29 -0700 |
commit | e6b86af931f16291ef0b7083d55816b38be1d3b6 (patch) | |
tree | c98bfdbcbadab6d83401e8f2b12d423028f4abb2 /src/wallet/node_rpc_proxy.cpp | |
parent | Merge pull request #8842 (diff) | |
download | monero-e6b86af931f16291ef0b7083d55816b38be1d3b6.tar.xz |
wallet2: fix rescanning tx via scan_tx
- Detach & re-process txs >= lowest scan height
- ensures that if a user calls scan_tx(tx1) after scanning tx2,
the wallet correctly processes tx1 and tx2
- if a user provides a tx with a height higher than the wallet's
last scanned height, the wallet will scan starting from that tx's
height
- scan_tx requires trusted daemon iff need to re-process existing
txs: in addition to querying a daemon for txids, if a user
provides a txid of a tx with height *lower* than any *already*
scanned txs in the wallet, then the wallet will also query the
daemon for all the *higher* txs as well. This is likely
unexpected behavior to a caller, and so to protect a caller from
revealing txid's to an untrusted daemon in an unexpected way,
require the daemon be trusted.
Diffstat (limited to 'src/wallet/node_rpc_proxy.cpp')
-rw-r--r-- | src/wallet/node_rpc_proxy.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp index dd0f6eb0c..1142e46ce 100644 --- a/src/wallet/node_rpc_proxy.cpp +++ b/src/wallet/node_rpc_proxy.cpp @@ -328,4 +328,23 @@ boost::optional<std::string> NodeRPCProxy::get_transactions(const std::vector<cr return boost::optional<std::string>(); } +boost::optional<std::string> NodeRPCProxy::get_block_header_by_height(uint64_t height, cryptonote::block_header_response &block_header) +{ + if (m_offline) + return boost::optional<std::string>("offline"); + + cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request req_t = AUTO_VAL_INIT(req_t); + cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response resp_t = AUTO_VAL_INIT(resp_t); + req_t.height = height; + + { + const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex}; + bool r = net_utils::invoke_http_json_rpc("/json_rpc", "getblockheaderbyheight", req_t, resp_t, m_http_client, rpc_timeout); + RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "getblockheaderbyheight"); + } + + block_header = std::move(resp_t.block_header); + return boost::optional<std::string>(); +} + } |