fix(lite): render a lite send as a negative debit, not a green "+"; recover unauthored-send amounts
Lite-parity audit, two History-correctness findings (display/parse only — no send/broadcast call touched): - A lite send carried a POSITIVE tx.amount, so History, the Details dialog and CSV export rendered an outgoing payment as a green "+" receipt (the full node uses a negative debit). The mapper already computes signedAmountZatoshis (negative for sends, positive for receives); applyLiteRefreshModelToWalletState now uses it for tx.amount, so the shared UI shows a red "-" and CSV a negative value. The summary cards use std::abs and are unaffected. - A send this wallet did not author (seed restore / another device) has empty outgoing_metadata, so the parser summed it to 0 and showed amount 0 with a blank address, understating Sent totals. parseTransactionRecord now falls back to |record.amount| (the net debit, incl. fee) when the metadata sum is 0, tolerant of a missing/odd field; explicit outgoing_metadata still wins. Tests: testLiteSendAmountIsNegative (send maps to <0, receive stays >0) and testLiteForeignSendFallsBackToRecordAmount. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -435,7 +435,9 @@ void applyLiteRefreshModelToWalletState(const LiteWalletAppRefreshModel& model,
|
||||
} else {
|
||||
tx.type = record.signedAmountZatoshis < 0 ? "send" : "receive";
|
||||
}
|
||||
tx.amount = static_cast<double>(record.amountZatoshis) / kZatoshisPerCoin;
|
||||
// Signed like the full node: a send is a negative debit, a receive positive. Consumers
|
||||
// (History/Details/CSV) pick sign + colour from this; the summary cards use std::abs.
|
||||
tx.amount = static_cast<double>(record.signedAmountZatoshis) / kZatoshisPerCoin;
|
||||
tx.timestamp = record.timestamp;
|
||||
tx.address = record.address;
|
||||
tx.memo = record.memo;
|
||||
|
||||
Reference in New Issue
Block a user