From fd6c9063cfdd4684b22e64c62d23ba036d131a87 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 5 Sep 2023 11:28:07 +0200 Subject: [PATCH] accounts: don't error out on payment not initiated It can happen that we see the payment request for a payment coming in, register it, but then it is failed on the lnd level and basically never exists in the DB. In that case we can just stop tracking the payment. --- accounts/service.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/accounts/service.go b/accounts/service.go index 3f6f77812..a229d831c 100644 --- a/accounts/service.go +++ b/accounts/service.go @@ -2,12 +2,14 @@ package accounts import ( "context" + "errors" "fmt" "sync" "time" "github.com/btcsuite/btcd/chaincfg" "github.com/lightninglabs/lndclient" + "github.com/lightningnetwork/lnd/channeldb" invpkg "github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lntypes" @@ -501,6 +503,22 @@ func (s *InterceptorService) TrackPayment(id AccountID, hash lntypes.Hash, } case err := <-errChan: + // If the payment wasn't initiated, we can't + // track it really. We'll try again on next + // startup, to make sure we don't miss any + // payments. + if errors.Is( + err, channeldb.ErrPaymentNotInitiated, + ) { + log.Debugf("Payment %v not initiated, "+ + "stopping tracking", hash) + + return + } + + log.Errorf("Received error from TrackPayment "+ + "RPC for payment %v: %v", hash, err) + if err != nil { select { case s.mainErrChan <- err: