Add a helper that finds the sale

This commit is contained in:
ai-bot committed 2026-11-16 19:33:24 +00:00
1 parent e1b0b9b568
commit e50fa28143
1 file changed
+14
+14
View File
@@ -130,6 +130,20 @@ def consumptions(tx_id):
conn.close()
def sale_id(market_id):
"""The one transaction of an account that gives sats away."""
conn = database.connect()
try:
row = conn.execute(
"SELECT id FROM transactions WHERE market_id = ? AND leg_out_sats IS NOT NULL"
" ORDER BY id LIMIT 1",
(market_id,),
).fetchone()
return row["id"]
finally:
conn.close()
def snapshot():
conn = database.connect()
try: