diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index 30b75b7e2..9cdcacb7d 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -1424,6 +1425,9 @@ struct WalletManager //! returns current blockchain target height virtual uint64_t blockchainTargetHeight() = 0; + //! returns current blockchain and target height + virtual std::pair blockchainAndTargetHeight() = 0; + //! returns current network difficulty virtual uint64_t networkDifficulty() = 0; diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp index c79fe25d6..8b5802ec8 100644 --- a/src/wallet/api/wallet_manager.cpp +++ b/src/wallet/api/wallet_manager.cpp @@ -280,6 +280,18 @@ uint64_t WalletManagerImpl::blockchainTargetHeight() return ires.target_height >= ires.height ? ires.target_height : ires.height; } +std::pair WalletManagerImpl::blockchainAndTargetHeight() +{ + cryptonote::COMMAND_RPC_GET_INFO::request ireq; + cryptonote::COMMAND_RPC_GET_INFO::response ires; + + if (!epee::net_utils::invoke_http_json("/getinfo", ireq, ires, m_http_client)) + return std::make_pair(0, 0); + uint64_t height = ires.height; + uint64_t target_height = ires.target_height >= ires.height ? ires.target_height : ires.height; + return std::make_pair(height, target_height); +} + uint64_t WalletManagerImpl::networkDifficulty() { cryptonote::COMMAND_RPC_GET_INFO::request ireq; diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h index 28fcd36c9..456093fec 100644 --- a/src/wallet/api/wallet_manager.h +++ b/src/wallet/api/wallet_manager.h @@ -95,6 +95,7 @@ public: bool connected(uint32_t *version = NULL) override; uint64_t blockchainHeight() override; uint64_t blockchainTargetHeight() override; + std::pair blockchainAndTargetHeight() override; uint64_t networkDifficulty() override; double miningHashRate() override; uint64_t blockTarget() override;