mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user