@@ -3437,23 +3437,23 @@ bool wallet2::bump_refresh_start_height(const uint64_t init_start_height, const
34373437 // Get the corresponding hash from the daemon
34383438 crypto::hash granularized_init_hash;
34393439 {
3440- cryptonote::COMMAND_RPC_GETBLOCKHASH ::request req = AUTO_VAL_INIT(req);
3441- cryptonote::COMMAND_RPC_GETBLOCKHASH ::response res = AUTO_VAL_INIT(res);
3440+ cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT ::request req = AUTO_VAL_INIT(req);
3441+ cryptonote::COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT ::response res = AUTO_VAL_INIT(res);
34423442 epee::json_rpc::error error;
34433443 error.code = 0;
3444- req.push_back( granularized_init_block_idx) ;
3444+ req.height = granularized_init_block_idx;
34453445
34463446 const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
3447- bool r = net_utils::invoke_http_json_rpc("/json_rpc", "on_get_block_hash ", req, res, error, *m_http_client, rpc_timeout);
3447+ bool r = net_utils::invoke_http_json_rpc("/json_rpc", "getblockheaderbyheight ", req, res, error, *m_http_client, rpc_timeout);
34483448 if (error.code == CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT) {
34493449 // We don't need to sync if start height is higher than the daemon height
34503450 MWARNING("Refresh start height is higher than the current chain tip, not syncing");
34513451 return false;
34523452 }
3453- THROW_WALLET_EXCEPTION_IF(!r || error.code != 0, error::get_block_hash_error , error.message);
3454- THROW_WALLET_EXCEPTION_IF(res.size() != 64, error::get_block_hash_error , "Hash is not 32 bytes as expected");
3455- r = epee::string_tools::hex_to_pod(res, granularized_init_hash);
3456- THROW_WALLET_EXCEPTION_IF(!r, error::get_block_hash_error , "Failed to parse getblockhash hash");
3453+ THROW_WALLET_EXCEPTION_IF(!r || error.code != 0, error::block_header_by_height , error.message);
3454+ THROW_WALLET_EXCEPTION_IF(res.block_header.hash. size() != 64, error::block_header_by_height , "Hash is not 32 bytes as expected");
3455+ r = epee::string_tools::hex_to_pod(res.block_header.hash , granularized_init_hash);
3456+ THROW_WALLET_EXCEPTION_IF(!r, error::block_header_by_height , "Failed to parse getblockheaderbyheight hash");
34573457 }
34583458
34593459 MINFO("Starting scanner on top of block " << granularized_init_block_idx << " , hash " << granularized_init_hash);
@@ -6660,90 +6660,14 @@ bool wallet2::check_version(uint32_t *version, bool *wallet_is_outdated, bool *d
66606660 // check wallet compatibility with daemon's hard fork version
66616661 if (!m_allow_mismatched_daemon_version)
66626662 {
6663- if (rpc_version < MAKE_CORE_RPC_VERSION(3, 17))
6664- {
6665- // Wallet cannot init FCMP++ tree while syncing if pointing to an older daemon
6666- if (daemon_is_outdated)
6667- *daemon_is_outdated = true;
6668- return false;
6669- }
6670-
6671- // check wallet compatibility with daemon's hard fork version
6672- if (!check_hard_fork_version(m_nettype, daemon_hard_forks, height, target_height, wallet_is_outdated, daemon_is_outdated))
6663+ if (!check_fork_version_compatibility(m_nettype, daemon_hard_forks, height, target_height, wallet_is_outdated, daemon_is_outdated))
66736664 return false;
66746665 }
66756666
66766667 m_rpc_version = rpc_version;
66776668 return true;
66786669}
66796670//----------------------------------------------------------------------------------------------------
6680- bool wallet2::check_hard_fork_version(cryptonote::network_type nettype, const std::vector<std::pair<uint8_t, uint64_t>> &daemon_hard_forks, const uint64_t height, const uint64_t target_height, bool *wallet_is_outdated, bool *daemon_is_outdated)
6681- {
6682- const size_t wallet_num_hard_forks = nettype == TESTNET ? num_testnet_hard_forks
6683- : nettype == STAGENET ? num_stagenet_hard_forks : num_mainnet_hard_forks;
6684- const hardfork_t *wallet_hard_forks = nettype == TESTNET ? testnet_hard_forks
6685- : nettype == STAGENET ? stagenet_hard_forks : mainnet_hard_forks;
6686-
6687- // First check if wallet or daemon is outdated (whether either are unaware of
6688- // a hard fork). Then check if fork has passed rendering versions incompatible
6689- if (daemon_hard_forks.size() > 0)
6690- {
6691- bool daemon_outdated = daemon_hard_forks.size() < wallet_num_hard_forks;
6692- bool wallet_outdated = daemon_hard_forks.size() > wallet_num_hard_forks;
6693-
6694- if (daemon_is_outdated)
6695- *daemon_is_outdated = daemon_outdated;
6696- if (wallet_is_outdated)
6697- *wallet_is_outdated = wallet_outdated;
6698-
6699- if (daemon_outdated)
6700- {
6701- uint64_t daemon_missed_fork_height = wallet_hard_forks[daemon_hard_forks.size()].height;
6702-
6703- // If the daemon missed the fork, then technically it is no longer part of
6704- // the Monero network. Don't connect.
6705- bool daemon_missed_fork = height >= daemon_missed_fork_height || target_height >= daemon_missed_fork_height;
6706- if (daemon_missed_fork)
6707- return false;
6708- }
6709- else if (wallet_outdated)
6710- {
6711- uint64_t wallet_missed_fork_height = daemon_hard_forks[wallet_num_hard_forks].second;
6712-
6713- // If the wallet missed the fork, then technically it is no longer able
6714- // to communicate with the Monero network. Don't connect.
6715- bool wallet_missed_fork = height >= wallet_missed_fork_height || target_height >= wallet_missed_fork_height;
6716- if (wallet_missed_fork)
6717- return false;
6718- }
6719- }
6720- else
6721- {
6722- // Non-updated daemons won't return daemon_hard_forks in response to
6723- // get_version. Fall back to extra call to get_hard_fork_info by version.
6724- uint64_t daemon_fork_height;
6725- get_hard_fork_info(wallet_num_hard_forks-1/* wallet expects "double fork" pattern */, daemon_fork_height);
6726- bool daemon_outdated = daemon_fork_height == std::numeric_limits<uint64_t>::max();
6727-
6728- if (daemon_is_outdated)
6729- *daemon_is_outdated = daemon_outdated;
6730-
6731- if (daemon_outdated)
6732- {
6733- uint64_t daemon_missed_fork_height = wallet_hard_forks[wallet_num_hard_forks-2].height;
6734- bool daemon_missed_fork = height >= daemon_missed_fork_height || target_height >= daemon_missed_fork_height;
6735- if (daemon_missed_fork)
6736- return false;
6737- }
6738-
6739- // Don't need to check if wallet is outdated here because the daemons updated
6740- // for a future hard fork will serve daemon_hard_forks above. The check for
6741- // an outdated wallet is done above using daemon_hard_forks.
6742- }
6743-
6744- return true;
6745- }
6746- //----------------------------------------------------------------------------------------------------
67476671void wallet2::set_offline(bool offline)
67486672{
67496673 m_offline = offline;
0 commit comments