Fix invoice polling finds no rows

This commit is contained in:
ekzyis 2023-11-26 23:53:35 +01:00
parent aa6db6a5e1
commit fb7fbae699
1 changed files with 6 additions and 3 deletions

View File

@ -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