From 13939d67d3c6cecaa36250ff1358260b2719a449 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sat, 14 Nov 2026 16:13:51 +0000 Subject: [PATCH] A buy consumes no sats; only its sats fee lowers what arrives --- ledger.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ledger.py b/ledger.py index f4e17ee..0b8315c 100644 --- a/ledger.py +++ b/ledger.py @@ -98,10 +98,17 @@ def _lot_by_origin(conn, market_id, origin_tx_id, origin_seq): def _sats_to_consume(tx): - """How many sats a transaction takes out of its account.""" + """How many sats a transaction takes out of its account. + + A trade consumes only when BTC leaves the account (a sale). A buy carries + its sats fee on the incoming leg, where it lowers the sats received, so it + must not consume anything. + """ if tx["type"] not in CONSUMING_TYPES: return 0 sats = tx["leg_out_sats"] or 0 + if sats <= 0: + return 0 if tx["type"] in FEE_ADDS_TO_CONSUMPTION: sats += tx["fee_sats"] or 0 return sats