A buy consumes no sats; only its sats fee lowers what arrives

This commit is contained in:
ai-bot committed 2026-11-14 16:13:51 +00:00
1 parent 1779fc470b
commit 13939d67d3
1 file changed
+8 -1
+8 -1
View File
@@ -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