Merge pull request #1915

a8646b09 Wallet API: add hard fork info functions (Jaquee)
This commit is contained in:
Riccardo Spagni 2017-03-24 14:34:55 +02:00
commit 92c2d79d10
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
5 changed files with 18 additions and 26 deletions

View file

@ -1413,6 +1413,18 @@ bool WalletImpl::rescanSpent()
}
return true;
}
void WalletImpl::hardForkInfo(uint8_t &version, uint64_t &earliest_height) const
{
m_wallet->get_hard_fork_info(version, earliest_height);
}
bool WalletImpl::useForkRules(uint8_t version, int64_t early_blocks) const
{
return m_wallet->use_fork_rules(version,early_blocks);
}
} // namespace
namespace Bitmonero = Monero;

View file

@ -99,7 +99,8 @@ public:
bool watchOnly() const;
bool rescanSpent();
bool testnet() const {return m_wallet->testnet();}
void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const;
bool useForkRules(uint8_t version, int64_t early_blocks) const;
PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
optional<uint64_t> amount, uint32_t mixin_count,

View file

@ -377,26 +377,6 @@ double WalletManagerImpl::miningHashRate() const
return mres.speed;
}
void WalletManagerImpl::hardForkInfo(uint8_t &version, uint64_t &earliest_height) const
{
epee::json_rpc::request<cryptonote::COMMAND_RPC_HARD_FORK_INFO::request> req_t = AUTO_VAL_INIT(req_t);
epee::json_rpc::response<cryptonote::COMMAND_RPC_HARD_FORK_INFO::response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
version = 0;
earliest_height = 0;
epee::net_utils::http::http_simple_client http_client;
req_t.jsonrpc = "2.0";
req_t.id = epee::serialization::storage_entry(0);
req_t.method = "hard_fork_info";
req_t.params.version = 0;
bool r = connect_and_invoke(m_daemonAddress, "/json_rpc", req_t, resp_t);
if (!r || resp_t.result.status != CORE_RPC_STATUS_OK)
return;
version = resp_t.result.version;
earliest_height = resp_t.result.earliest_height;
}
uint64_t WalletManagerImpl::blockTarget() const
{
cryptonote::COMMAND_RPC_GET_INFO::request ireq;

View file

@ -59,7 +59,6 @@ public:
uint64_t blockchainTargetHeight() const;
uint64_t networkDifficulty() const;
double miningHashRate() const;
void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const;
uint64_t blockTarget() const;
bool isMining() const;
bool startMining(const std::string &address, uint32_t threads = 1, bool background_mining = false, bool ignore_battery = true);

View file

@ -296,7 +296,10 @@ struct Wallet
virtual std::string address() const = 0;
virtual std::string path() const = 0;
virtual bool testnet() const = 0;
//! returns current hard fork info
virtual void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const = 0;
//! check if hard fork rules should be used
virtual bool useForkRules(uint8_t version, int64_t early_blocks) const = 0;
/*!
* \brief integratedAddress - returns integrated address for current wallet address and given payment_id.
* if passed "payment_id" param is an empty string or not-valid payment id string
@ -686,9 +689,6 @@ struct WalletManager
//! returns current mining hash rate (0 if not mining)
virtual double miningHashRate() const = 0;
//! returns current hard fork info
virtual void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const = 0;
//! returns current block target
virtual uint64_t blockTarget() const = 0;