From 0c273d35717efacdd36dddea95b12fc6cea1ec71 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Mon, 10 Nov 2025 12:28:41 +0000 Subject: [PATCH] possible fix for STAKE amount in GUI app - thanks, Tiamak --- src/wallet/api/transaction_history.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/wallet/api/transaction_history.cpp b/src/wallet/api/transaction_history.cpp index badd7f06c..7d3dc15b5 100644 --- a/src/wallet/api/transaction_history.cpp +++ b/src/wallet/api/transaction_history.cpp @@ -175,7 +175,13 @@ void TransactionHistoryImpl::refresh() uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known uint64_t fee = pd.m_amount_in - pd.m_amount_out; - + uint64_t amount = pd.m_amount_in - change - fee; + if (ptx.tx.type == cryptonote::transaction_type::AUDIT || + ptx.tx.type == cryptonote::transaction_type::BURN || + ptx.tx.type == cryptonote::transaction_type::STAKE) { + amount = pd.m_tx.amount_burnt; + if (fee > amount) fee -= amount; + } std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) @@ -184,7 +190,7 @@ void TransactionHistoryImpl::refresh() TransactionInfoImpl * ti = new TransactionInfoImpl(); ti->m_paymentid = payment_id; - ti->m_amount = pd.m_amount_in - change - fee; + ti->m_amount = amount; ti->m_fee = fee; ti->m_direction = TransactionInfo::Direction_Out; ti->m_hash = string_tools::pod_to_hex(hash); @@ -212,8 +218,16 @@ void TransactionHistoryImpl::refresh() for (std::list>::const_iterator i = upayments_out.begin(); i != upayments_out.end(); ++i) { const tools::wallet2::unconfirmed_transfer_details &pd = i->second; const crypto::hash &hash = i->first; - uint64_t amount = pd.m_amount_in; - uint64_t fee = amount - pd.m_amount_out; + uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known + uint64_t fee = pd.m_amount_in - pd.m_amount_out; + uint64_t amount = pd.m_amount_in - change - fee; + if (ptx.tx.type == cryptonote::transaction_type::AUDIT || + ptx.tx.type == cryptonote::transaction_type::BURN || + ptx.tx.type == cryptonote::transaction_type::STAKE) { + amount = pd.m_tx.amount_burnt; + if (fee > amount) fee -= amount; + } + std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); if (payment_id.substr(16).find_first_not_of('0') == std::string::npos) payment_id = payment_id.substr(0,16); @@ -221,7 +235,7 @@ void TransactionHistoryImpl::refresh() TransactionInfoImpl * ti = new TransactionInfoImpl(); ti->m_paymentid = payment_id; - ti->m_amount = amount - pd.m_change - fee; + ti->m_amount = amount; ti->m_fee = fee; ti->m_direction = TransactionInfo::Direction_Out; ti->m_failed = is_failed;