Skip to content

Commit fd6c906

Browse files
committed
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.
1 parent a942af6 commit fd6c906

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

accounts/service.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package accounts
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"sync"
78
"time"
89

910
"github.com/btcsuite/btcd/chaincfg"
1011
"github.com/lightninglabs/lndclient"
12+
"github.com/lightningnetwork/lnd/channeldb"
1113
invpkg "github.com/lightningnetwork/lnd/invoices"
1214
"github.com/lightningnetwork/lnd/lnrpc"
1315
"github.com/lightningnetwork/lnd/lntypes"
@@ -501,6 +503,22 @@ func (s *InterceptorService) TrackPayment(id AccountID, hash lntypes.Hash,
501503
}
502504

503505
case err := <-errChan:
506+
// If the payment wasn't initiated, we can't
507+
// track it really. We'll try again on next
508+
// startup, to make sure we don't miss any
509+
// payments.
510+
if errors.Is(
511+
err, channeldb.ErrPaymentNotInitiated,
512+
) {
513+
log.Debugf("Payment %v not initiated, "+
514+
"stopping tracking", hash)
515+
516+
return
517+
}
518+
519+
log.Errorf("Received error from TrackPayment "+
520+
"RPC for payment %v: %v", hash, err)
521+
504522
if err != nil {
505523
select {
506524
case s.mainErrChan <- err:

0 commit comments

Comments
 (0)