Skip to content

Commit

Permalink
don't call ProcessInvoice but PublishPayload manually
Browse files Browse the repository at this point in the history
  • Loading branch information
frnandu committed Dec 29, 2023
1 parent 8edf916 commit f2604d5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,27 @@ func (svc *Service) RepublishInvoice(ctx context.Context, paymentHash *lnrpc.Pay
logrus.Error("Invoice NOT FOUND ", paymentHash, err)
return
}
err = svc.ProcessInvoice(ctx, invoice)
if err != nil {
sentry.CaptureException(err)
logrus.Error("ERROR while trying to republish invoice ", paymentHash, err)
} else {
logrus.Info("Invoice Republished ", paymentHash, err)
if ShouldPublishInvoice(invoice) {
startTime := time.Now()
err := svc.PublishPayload(ctx, invoice, LNDInvoiceExchange, LNDInvoiceRoutingKey)
if err != nil {
sentry.CaptureException(err)
logrus.WithFields(
logrus.Fields{
"payload_type": "invoice",
"payment_hash": hex.EncodeToString(invoice.RHash),
}).WithError(err).Error("error publishing invoice")
return
}
logrus.WithFields(
logrus.Fields{
"payload_type": "invoice",
"rabbitmq_latency": time.Since(startTime).Seconds(),
"amount": invoice.AmtPaidSat,
"keysend": invoice.IsKeysend,
"add_index": invoice.AddIndex,
"settle_date": invoice.SettleDate,
"payment_hash": hex.EncodeToString(invoice.RHash),
}).Info("published invoice")
}
}

0 comments on commit f2604d5

Please sign in to comment.