wallet2: add lightwallet exceptions to common functions

This commit is contained in:
Jaquee 2017-08-04 23:00:25 +02:00
parent 2e692fc05a
commit 32e2b0030e
1 changed files with 15 additions and 0 deletions

View File

@ -2648,6 +2648,12 @@ bool wallet2::check_connection(uint32_t *version, uint32_t timeout)
boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex); boost::lock_guard<boost::mutex> 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()) if(!m_http_client.is_connected())
{ {
m_node_rpc_proxy.invalidate(); 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 wallet2::balance(uint32_t index_major) const
{ {
uint64_t amount = 0; uint64_t amount = 0;
if(m_light_wallet)
return m_light_wallet_unlocked_balance;
for (const auto& i : balance_per_subaddress(index_major)) for (const auto& i : balance_per_subaddress(index_major))
amount += i.second; amount += i.second;
return amount; 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 wallet2::unlocked_balance(uint32_t index_major) const
{ {
uint64_t amount = 0; uint64_t amount = 0;
if(m_light_wallet)
return m_light_wallet_balance;
for (const auto& i : unlocked_balance_per_subaddress(index_major)) for (const auto& i : unlocked_balance_per_subaddress(index_major))
amount += i.second; amount += i.second;
return amount; return amount;
@ -3822,6 +3832,8 @@ uint64_t wallet2::get_dynamic_per_kb_fee_estimate()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
uint64_t wallet2::get_per_kb_fee() 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); bool use_dyn_fee = use_fork_rules(HF_VERSION_DYNAMIC_FEE, -720 * 1);
if (!use_dyn_fee) if (!use_dyn_fee)
return FEE_PER_KB; 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) 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; uint64_t height, earliest_height;
boost::optional<std::string> result = m_node_rpc_proxy.get_height(height); boost::optional<std::string> result = m_node_rpc_proxy.get_height(height);
throw_on_rpc_response_error(result, "get_info"); throw_on_rpc_response_error(result, "get_info");