Skip to content

Commit

Permalink
don't process unsettled invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Jul 28, 2023
1 parent 7f873c3 commit 7b88e40
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion reconciliation_lost_invoices/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ func main() {
if creationDate.Before(time.Now().Add(-1 * time.Duration(rc.NumDays) * 24 * time.Hour)) {
return
}
//non-settled invoices don't matter
if !lndInvoice.Settled {
continue
}
// - get payment hash and do a db query
var dbInvoice models.Invoice

err := svc.DB.NewSelect().Model(&dbInvoice).Where("invoice.r_hash = ? AND state = ?", hex.EncodeToString(lndInvoice.RHash), common.InvoiceStateSettled).Limit(1).Scan(ctx)
err := svc.DB.NewSelect().Model(&dbInvoice).Where("type = ? AND invoice.r_hash = ? AND state = ?", common.InvoiceTypeIncoming, hex.EncodeToString(lndInvoice.RHash), common.InvoiceStateSettled).Limit(1).Scan(ctx)
if err != nil {
// - if not found, dump invoice json
if errors.Is(err, sql.ErrNoRows) {
Expand Down

0 comments on commit 7b88e40

Please sign in to comment.