From fb7fbae6992e0c4e9aa53d8a32edd6dd61328322 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 26 Nov 2023 23:53:35 +0100 Subject: [PATCH] Fix invoice polling finds no rows --- server/router/handler/market.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/router/handler/market.go b/server/router/handler/market.go index c883cdc..c81531a 100644 --- a/server/router/handler/market.go +++ b/server/router/handler/market.go @@ -92,14 +92,16 @@ func HandleCreateMarket(sc context.ServerContext) echo.HandlerFunc { tx.Rollback() return err } - go sc.Lnd.CheckInvoice(sc.Db, hash) - m.InvoiceId = invoice.Id if err := sc.Db.CreateMarket(tx, ctx, &m); err != nil { tx.Rollback() return err } + // need to commit before starting to poll invoice status + tx.Commit() + go sc.Lnd.CheckInvoice(sc.Db, hash) + data = map[string]any{ "id": invoice.Id, "bolt11": invoice.PaymentRequest, @@ -179,7 +181,8 @@ func HandleOrder(sc context.ServerContext) echo.HandlerFunc { return err } - // Start goroutine to poll status and update invoice in background + // need to commit before startign to poll invoice status + tx.Commit() go sc.Lnd.CheckInvoice(sc.Db, hash) // TODO: find matching orders