From 32e2b0030ec451968aa943adac9211fc4f8d9f87 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 4 Aug 2017 23:00:25 +0200 Subject: [PATCH] wallet2: add lightwallet exceptions to common functions --- src/wallet/wallet2.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 7c2d1b115..263042a24 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2648,6 +2648,12 @@ bool wallet2::check_connection(uint32_t *version, uint32_t timeout) boost::lock_guard lock(m_daemon_rpc_mutex); + // TODO: Add light wallet version check. + if(m_light_wallet) { + version = 0; + return m_light_wallet_connected; + } + if(!m_http_client.is_connected()) { m_node_rpc_proxy.invalidate(); @@ -2941,6 +2947,8 @@ void wallet2::store_to(const std::string &path, const std::string &password) uint64_t wallet2::balance(uint32_t index_major) const { uint64_t amount = 0; + if(m_light_wallet) + return m_light_wallet_unlocked_balance; for (const auto& i : balance_per_subaddress(index_major)) amount += i.second; return amount; @@ -2949,6 +2957,8 @@ uint64_t wallet2::balance(uint32_t index_major) const uint64_t wallet2::unlocked_balance(uint32_t index_major) const { uint64_t amount = 0; + if(m_light_wallet) + return m_light_wallet_balance; for (const auto& i : unlocked_balance_per_subaddress(index_major)) amount += i.second; return amount; @@ -3822,6 +3832,8 @@ uint64_t wallet2::get_dynamic_per_kb_fee_estimate() //---------------------------------------------------------------------------------------------------- uint64_t wallet2::get_per_kb_fee() { + if(m_light_wallet) + return m_light_wallet_per_kb_fee; bool use_dyn_fee = use_fork_rules(HF_VERSION_DYNAMIC_FEE, -720 * 1); if (!use_dyn_fee) return FEE_PER_KB; @@ -5733,6 +5745,9 @@ void wallet2::get_hard_fork_info(uint8_t version, uint64_t &earliest_height) //---------------------------------------------------------------------------------------------------- bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) { + // TODO: How to get fork rule info from light wallet node? + if(m_light_wallet) + return true; uint64_t height, earliest_height; boost::optional result = m_node_rpc_proxy.get_height(height); throw_on_rpc_response_error(result, "get_info");