From c8602e0fbd016614196b29842f3cc1430be4573b Mon Sep 17 00:00:00 2001 From: Padreug Date: Sat, 23 May 2026 22:45:59 +0200 Subject: [PATCH] fix: every ticket row gets a fresh short-hash id (no payment_hash reuse) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous commit reused the LNbits invoice payment_hash as the first row's id, so a 3-ticket purchase ended up with one 64-hex id and two short-hash ids — inconsistent and noisy in My Tickets. Switch every row to urlsafe_short_hash. The shared payment_hash column is the join key for invoice lookups (poll endpoint, ws notifier, on_invoice_paid); rows never need to BE the payment hash, they only need to point at it. Co-Authored-By: Claude Opus 4.7 (1M context) --- views_api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/views_api.py b/views_api.py index c288c20..e7c118f 100644 --- a/views_api.py +++ b/views_api.py @@ -612,15 +612,15 @@ async def api_ticket_create( extra=extra, ), ) - # Multi-ticket purchases land as N rows sharing the LNbits invoice - # payment_hash but with distinct `id`s — one independently - # scannable QR per attendee. The first row reuses payment_hash as - # its id so the legacy single-purchase invariant - # (`id == payment_hash`) still holds for quantity == 1 callers. + # Each row gets a fresh urlsafe_short_hash id so single- and + # multi-ticket purchases stay shape-consistent — every scannable + # ticket id is a short hash, never the long bolt11 payment_hash. + # The shared `payment_hash` column is the join key for invoice + # lookup (poll endpoint, ws notifier, set_ticket_paid loop). ticket_ids: list[str] = [] sats_per_ticket = payment.sat // quantity if quantity else payment.sat - for index in range(quantity): - row_id = payment.payment_hash if index == 0 else urlsafe_short_hash() + for _ in range(quantity): + row_id = urlsafe_short_hash() await create_ticket( payment_hash=payment.payment_hash, wallet=event.wallet,