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:
@@ -349,6 +349,15 @@ bool parseTransactionRecord(const json& value,
|
||||
output.amount += parsedOutput.value;
|
||||
output.outgoingMetadata.push_back(std::move(parsedOutput));
|
||||
}
|
||||
// A send this wallet did not author (seed restore / other device) has empty outgoing_metadata,
|
||||
// so the sum is 0. Fall back to the record's net 'amount' magnitude (includes the fee) so Sent
|
||||
// totals aren't understated. Display-only; tolerant of a missing/odd field.
|
||||
if (output.amount == 0 && value.contains("amount") && !value.at("amount").is_null()) {
|
||||
std::int64_t net = 0;
|
||||
if (jsonToSigned(value.at("amount"), net) && net != std::numeric_limits<std::int64_t>::min()) {
|
||||
output.amount = net < 0 ? -net : net;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user