From bc10fe025b53ab1dcbb2316214feb6a0700f54df Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 26 Nov 2023 18:34:24 +0100 Subject: [PATCH] First create order then invoice This should prevent that we poll for invoices that had an error during order creation. I should probably fix this with the context package. --- server/router/handler/market.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/router/handler/market.go b/server/router/handler/market.go index 5aef84f..20f92bb 100644 --- a/server/router/handler/market.go +++ b/server/router/handler/market.go @@ -142,15 +142,15 @@ func HandleOrder(sc context.ServerContext) echo.HandlerFunc { return err } - // Start goroutine to poll status and update invoice in background - go sc.Lnd.CheckInvoice(sc.Db, hash) - // Create (unconfirmed) order o.InvoiceId = invoice.Id if err := sc.Db.CreateOrder(&o); err != nil { return err } + // Start goroutine to poll status and update invoice in background + go sc.Lnd.CheckInvoice(sc.Db, hash) + // TODO: find matching orders data = map[string]any{