forked from such-gitea/wownero-lws
Fix locked_funds computation (#200)
This commit is contained in:
committed by
Lee *!* Clagett
parent
26a882965f
commit
0caec18f84
@@ -75,6 +75,9 @@ namespace db
|
|||||||
};
|
};
|
||||||
WIRE_AS_INTEGER(block_id);
|
WIRE_AS_INTEGER(block_id);
|
||||||
|
|
||||||
|
inline constexpr std::uint64_t to_uint(const block_id src) noexcept
|
||||||
|
{ return std::uint64_t(src); }
|
||||||
|
|
||||||
//! References a global output number, as determined by the public chain
|
//! References a global output number, as determined by the public chain
|
||||||
struct output_id
|
struct output_id
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,11 +196,13 @@ namespace lws
|
|||||||
};
|
};
|
||||||
using async_complete = void(expect<copyable_slice>);
|
using async_complete = void(expect<copyable_slice>);
|
||||||
|
|
||||||
bool is_locked(std::uint64_t unlock_time, db::block_id last) noexcept
|
bool is_locked(std::uint64_t unlock_time, db::block_id last, db::block_id tx_height) noexcept
|
||||||
{
|
{
|
||||||
if (unlock_time > CRYPTONOTE_MAX_BLOCK_NUMBER)
|
if (unlock_time > CRYPTONOTE_MAX_BLOCK_NUMBER)
|
||||||
return std::chrono::seconds{unlock_time} > std::chrono::system_clock::now().time_since_epoch();
|
return std::chrono::seconds{unlock_time} > std::chrono::system_clock::now().time_since_epoch() + std::chrono::seconds{CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2};
|
||||||
return db::block_id(unlock_time) > last;
|
if (unlock_time > to_uint(last) - 1 + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS)
|
||||||
|
return true;
|
||||||
|
return to_uint(tx_height) + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE > to_uint(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<db::output::spend_meta_>::const_iterator
|
std::vector<db::output::spend_meta_>::const_iterator
|
||||||
@@ -534,7 +536,7 @@ namespace lws
|
|||||||
metas.insert(find_metadata(metas, meta.id), meta);
|
metas.insert(find_metadata(metas, meta.id), meta);
|
||||||
|
|
||||||
resp.total_received = rpc::safe_uint64(std::uint64_t(resp.total_received) + meta.amount);
|
resp.total_received = rpc::safe_uint64(std::uint64_t(resp.total_received) + meta.amount);
|
||||||
if (is_locked(output.get_value<MONERO_FIELD(db::output, unlock_time)>(), last->id))
|
if (is_locked(output.get_value<MONERO_FIELD(db::output, unlock_time)>(), last->id, output.get_value<MONERO_FIELD(db::output, link)>().height))
|
||||||
resp.locked_funds = rpc::safe_uint64(std::uint64_t(resp.locked_funds) + meta.amount);
|
resp.locked_funds = rpc::safe_uint64(std::uint64_t(resp.locked_funds) + meta.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user