multi: introduce new paymentsDB package

We introduce a new package paymentsDB and start by moving the
payment specifc errors from the channeldb package to the
paymentsDB package. We also fix linter issues which showed up
due to changing this code part.
This commit is contained in:
ziggie committed 2025-08-11 16:44:14 +02:00
1 parent db2c50a599
commit 18afd4442d
12 files changed
+279 -261

No files matched your search

+8 -7
View File
@@ -22,6 +22,7 @@ import (
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/macaroons"
paymentsdb "github.com/lightningnetwork/lnd/payments/db"
"github.com/lightningnetwork/lnd/routing"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/zpay32"
@@ -373,9 +374,9 @@ func (s *Server) SendPaymentV2(req *SendPaymentRequest,
payment.Identifier(), err)
// Transform user errors to grpc code.
if errors.Is(err, channeldb.ErrPaymentExists) ||
errors.Is(err, channeldb.ErrPaymentInFlight) ||
errors.Is(err, channeldb.ErrAlreadyPaid) {
if errors.Is(err, paymentsdb.ErrPaymentExists) ||
errors.Is(err, paymentsdb.ErrPaymentInFlight) ||
errors.Is(err, paymentsdb.ErrAlreadyPaid) {
return status.Error(
codes.AlreadyExists, err.Error(),
@@ -955,13 +956,13 @@ func (s *Server) SendToRouteV2(ctx context.Context,
// Transform user errors to grpc code.
switch {
case errors.Is(err, channeldb.ErrPaymentExists):
case errors.Is(err, paymentsdb.ErrPaymentExists):
fallthrough
case errors.Is(err, channeldb.ErrPaymentInFlight):
case errors.Is(err, paymentsdb.ErrPaymentInFlight):
fallthrough
case errors.Is(err, channeldb.ErrAlreadyPaid):
case errors.Is(err, paymentsdb.ErrAlreadyPaid):
return nil, status.Error(
codes.AlreadyExists, err.Error(),
)
@@ -1368,7 +1369,7 @@ func (s *Server) subscribePayment(identifier lntypes.Hash) (
sub, err := router.Tower.SubscribePayment(identifier)
switch {
case errors.Is(err, channeldb.ErrPaymentNotInitiated):
case errors.Is(err, paymentsdb.ErrPaymentNotInitiated):
return nil, status.Error(codes.NotFound, err.Error())
case err != nil: