diff options
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 26e3a5b14..e2a4d41c1 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5969,7 +5969,7 @@ uint64_t wallet2::balance(uint32_t index_major, bool strict) const return amount; } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::unlocked_balance(uint32_t index_major, bool strict, uint64_t *blocks_to_unlock, uint64_t *time_to_unlock) const +uint64_t wallet2::unlocked_balance(uint32_t index_major, bool strict, uint64_t *blocks_to_unlock, uint64_t *time_to_unlock) { uint64_t amount = 0; if (blocks_to_unlock) @@ -6021,7 +6021,7 @@ std::map<uint32_t, uint64_t> wallet2::balance_per_subaddress(uint32_t index_majo return amount_per_subaddr; } //---------------------------------------------------------------------------------------------------- -std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> wallet2::unlocked_balance_per_subaddress(uint32_t index_major, bool strict) const +std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> wallet2::unlocked_balance_per_subaddress(uint32_t index_major, bool strict) { std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> amount_per_subaddr; const uint64_t blockchain_height = get_blockchain_current_height(); @@ -6069,7 +6069,7 @@ uint64_t wallet2::balance_all(bool strict) const return r; } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::unlocked_balance_all(bool strict, uint64_t *blocks_to_unlock, uint64_t *time_to_unlock) const +uint64_t wallet2::unlocked_balance_all(bool strict, uint64_t *blocks_to_unlock, uint64_t *time_to_unlock) { uint64_t r = 0; if (blocks_to_unlock) @@ -6234,12 +6234,12 @@ void wallet2::rescan_blockchain(bool hard, bool refresh, bool keep_key_images) finish_rescan_bc_keep_key_images(transfers_cnt, transfers_hash); } //---------------------------------------------------------------------------------------------------- -bool wallet2::is_transfer_unlocked(const transfer_details& td) const +bool wallet2::is_transfer_unlocked(const transfer_details& td) { return is_transfer_unlocked(td.m_tx.unlock_time, td.m_block_height); } //---------------------------------------------------------------------------------------------------- -bool wallet2::is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) const +bool wallet2::is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) { if(!is_tx_spendtime_unlocked(unlock_time, block_height)) return false; @@ -6250,7 +6250,7 @@ bool wallet2::is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) return true; } //---------------------------------------------------------------------------------------------------- -bool wallet2::is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const +bool wallet2::is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) { if(unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER) { @@ -6262,12 +6262,14 @@ bool wallet2::is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_heig }else { //interpret as time - uint64_t current_time = static_cast<uint64_t>(time(NULL)); + uint64_t adjusted_time; + try { adjusted_time = get_daemon_adjusted_time(); } + catch(...) { adjusted_time = time(NULL); } // use local time if no daemon to report blockchain time // XXX: this needs to be fast, so we'd need to get the starting heights // from the daemon to be correct once voting kicks in uint64_t v2height = m_nettype == TESTNET ? 624634 : m_nettype == STAGENET ? 32000 : 1009827; uint64_t leeway = block_height < v2height ? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 : CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2; - if(current_time + leeway >= unlock_time) + if(adjusted_time + leeway >= unlock_time) return true; else return false; @@ -9109,7 +9111,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry LOG_PRINT_L2("transfer_selected_rct done"); } -std::vector<size_t> wallet2::pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) const +std::vector<size_t> wallet2::pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) { std::vector<size_t> picks; float current_output_relatdness = 1.0f; @@ -10780,7 +10782,7 @@ uint64_t wallet2::get_upper_transaction_weight_limit() return full_reward_zone - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; } //---------------------------------------------------------------------------------------------------- -std::vector<size_t> wallet2::select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const +std::vector<size_t> wallet2::select_available_outputs(const std::function<bool(const transfer_details &td)> &f) { std::vector<size_t> outputs; size_t n = 0; @@ -12085,6 +12087,15 @@ uint64_t wallet2::get_daemon_blockchain_height(string &err) return height; } +uint64_t wallet2::get_daemon_adjusted_time() +{ + uint64_t adjusted_time; + + boost::optional<std::string> result = m_node_rpc_proxy.get_adjusted_time(adjusted_time); + THROW_WALLET_EXCEPTION_IF(result, error::wallet_internal_error, "Invalid adjusted time from daemon"); + return adjusted_time; +} + uint64_t wallet2::get_daemon_blockchain_target_height(string &err) { err = ""; |