Merge pull request #43 from salvium/wallet-balance-stake-fix
This commit is contained in:
@@ -2704,6 +2704,37 @@ void wallet2::process_new_scanned_transaction(
|
||||
// update m_transfer_indices
|
||||
m_transfers_indices[enote_scan_info->asset_type].insert(m_transfers.size()-1);
|
||||
|
||||
// Check for STAKE / AUDIT TX payouts
|
||||
if (tx.type == cryptonote::transaction_type::PROTOCOL && td.m_td_origin_idx != std::numeric_limits<uint64_t>::max()) {
|
||||
|
||||
// Attempt to get the origin TX
|
||||
THROW_WALLET_EXCEPTION_IF(td.m_td_origin_idx >= get_num_transfer_details(),
|
||||
error::wallet_internal_error,
|
||||
"cannot locate return_payment TX origin in m_transfers");
|
||||
const transfer_details &td_origin = m_transfers[td.m_td_origin_idx];
|
||||
THROW_WALLET_EXCEPTION_IF(td_origin.m_tx.type != cryptonote::transaction_type::AUDIT && td_origin.m_tx.type != cryptonote::transaction_type::STAKE,
|
||||
error::wallet_internal_error,
|
||||
"incorrect TX type for protocol_tx origin in m_transfers");
|
||||
|
||||
// Get the output key for the change entry
|
||||
crypto::public_key pk_locked_coins = crypto::null_pkey;
|
||||
THROW_WALLET_EXCEPTION_IF(!get_output_public_key(td_origin.m_tx.vout[td_origin.m_internal_output_index], pk_locked_coins),
|
||||
error::wallet_internal_error,
|
||||
"Failed to get output public key for locked coins");
|
||||
|
||||
// At this point, we need to clear the "locked coins" count, because otherwise we will be counting yield stakes twice in our balance
|
||||
if (!m_locked_coins.erase(pk_locked_coins)) {
|
||||
LOG_ERROR("Failed to remove protocol_tx entry from m_locked_coins - possible duplicate output key detected");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for STAKE / AUDIT TXs
|
||||
if (tx.type == cryptonote::transaction_type::AUDIT || tx.type == cryptonote::transaction_type::STAKE) {
|
||||
|
||||
// Add a "locked coins" entry so users don't freak out when they STAKE/AUDITOA
|
||||
m_locked_coins.insert({onetime_address, {0, tx.amount_burnt, tx.source_asset_type}});
|
||||
}
|
||||
|
||||
// update multisig info
|
||||
if (m_multisig)
|
||||
{
|
||||
@@ -7420,6 +7451,14 @@ bool wallet2::is_transfer_unlocked(const transfer_details& td)
|
||||
uint64_t unlock_time = 0;
|
||||
if (!cryptonote::get_output_unlock_time(td.m_tx.vout[td.m_internal_output_index], unlock_time))
|
||||
return false;
|
||||
if (unlock_time == 0) {
|
||||
if (td.m_tx.type == cryptonote::transaction_type::MINER || td.m_tx.type == cryptonote::transaction_type::PROTOCOL) {
|
||||
unlock_time = CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
||||
} else {
|
||||
unlock_time = CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_transfer_unlocked(unlock_time, td.m_block_height);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user