Skip to content

Commit

Permalink
fix query, add keysend log
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Jul 28, 2023
1 parent e7fcf3f commit 7f873c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions reconciliation_lost_invoices/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"time"

"github.com/getAlby/lndhub.go/common"
"github.com/getAlby/lndhub.go/db"
"github.com/getAlby/lndhub.go/db/models"
"github.com/getAlby/lndhub.go/lib"
Expand Down Expand Up @@ -109,11 +110,11 @@ func main() {
// - get payment hash and do a db query
var dbInvoice models.Invoice

err := svc.DB.NewSelect().Model(&dbInvoice).Where("invoice.r_hash = ?", hex.EncodeToString(lndInvoice.RHash)).Limit(1).Scan(ctx)
err := svc.DB.NewSelect().Model(&dbInvoice).Where("invoice.r_hash = ? AND state = ?", 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) {
fmt.Printf("hex: %s\n", hex.EncodeToString(lndInvoice.RHash))
fmt.Printf("keysend: %t hex: %s\n", lndInvoice.IsKeysend, hex.EncodeToString(lndInvoice.RHash))
marshalled, err := json.Marshal(lndInvoice)
if err != nil {
svc.Logger.Fatal(err)
Expand Down

0 comments on commit 7f873c3

Please sign in to comment.