use bun.Tx to avoid db locked err

This commit is contained in:
kiwiidb
2022-01-22 10:33:54 +01:00
parent 613a485d7e
commit 366f66a2e2

View File

@@ -72,7 +72,7 @@ func (svc *LndhubService) SendInternalPayment(tx *bun.Tx, invoice *models.Invoic
incomingInvoice.Internal = true // mark incoming invoice as internal, just for documentation/debugging
incomingInvoice.State = "settled"
incomingInvoice.SettledAt = schema.NullTime{Time: time.Now()}
_, err = svc.DB.NewUpdate().Model(&incomingInvoice).WherePK().Exec(context.TODO())
_, err = tx.NewUpdate().Model(&incomingInvoice).WherePK().Exec(context.TODO())
if err != nil {
// could not save the invoice of the recipient
return sendPaymentResponse, err