aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorJaquee <jaquee.monero@gmail.com>2017-03-24 09:59:26 +0100
committerJaquee <jaquee.monero@gmail.com>2017-03-24 09:59:26 +0100
commita8646b0957aa60ffb8f3c2db820db16e40398c4e (patch)
tree5103806500da4144c8c5778c652513bb87a3a4d8 /src/wallet
parentMerge pull request #1912 (diff)
downloadmonero-a8646b0957aa60ffb8f3c2db820db16e40398c4e.tar.xz
Wallet API: add hard fork info functions
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp12
-rw-r--r--src/wallet/api/wallet.h3
-rw-r--r--src/wallet/api/wallet_manager.cpp20
-rw-r--r--src/wallet/api/wallet_manager.h1
-rw-r--r--src/wallet/wallet2_api.h8
5 files changed, 18 insertions, 26 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index d5c2fbda2..fc2d6e755 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -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;
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 456110908..c376dd6c1 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -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,
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 8e86c87b3..b2f947972 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -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;
diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h
index 677c105fb..033e8108f 100644
--- a/src/wallet/api/wallet_manager.h
+++ b/src/wallet/api/wallet_manager.h
@@ -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);
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index eee1c8d3c..17d0caf7d 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -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;