Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): add lnd FeeInsufficient error validation #4572

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api/src/domain/bitcoin/lightning/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class RouteNotFoundError extends LightningServiceError {}
export class UnknownNextPeerError extends LightningServiceError {}
export class InsufficientBalanceForRoutingError extends LightningServiceError {}
export class InsufficientBalanceForLnPaymentError extends LightningServiceError {}
export class InsufficientFeeForLnPaymentError extends LightningServiceError {}
export class InvoiceExpiredOrBadPaymentHashError extends LightningServiceError {}
export class PaymentRejectedByDestinationError extends LightningServiceError {}
export class PaymentAttemptsTimedOutError extends LightningServiceError {}
Expand Down
5 changes: 5 additions & 0 deletions core/api/src/graphql/error-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ export const mapError = (error: ApplicationError): CustomGraphQLError => {
message = error.message
return new InsufficientBalanceError({ message, logger: baseLogger })

case "InsufficientFeeForLnPaymentError":
message =
"Payment failed due to an insufficient fee, please try again later or contact support if the problem persists."
return new ValidationInternalError({ message, logger: baseLogger })

case "CaptchaUserFailToPassError":
message = "Captcha validation failed."
return new ValidationInternalError({ message, logger: baseLogger })
Expand Down
1 change: 1 addition & 0 deletions core/api/src/services/lnd/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const KnownLndErrorDetails = {
// Off-chain
InsufficientBalance: /insufficient local balance/,
InsufficientBalanceToAttemptPayment: /InsufficientBalanceToAttemptPayment/,
InsufficientFee: /FeeInsufficient/,
InvoiceNotFound: /unable to locate invoice/,
InvoiceAlreadyPaid: /invoice is already paid/,
UnableToFindRoute: /PaymentPathfindingFailedToFindPossibleRoute/,
Expand Down
3 changes: 3 additions & 0 deletions core/api/src/services/lnd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
decodeInvoice,
InvalidInvoiceAmountError,
InvoiceAlreadySettledError,
InsufficientFeeForLnPaymentError,
} from "@/domain/bitcoin/lightning"
import { CacheKeys } from "@/domain/cache"
import { LnFees } from "@/domain/payments"
Expand Down Expand Up @@ -1208,6 +1209,8 @@ const handleSendPaymentLndErrors = ({
return new InsufficientBalanceForLnPaymentError()
case match(KnownLndErrorDetails.FeaturePairExists):
return new InvalidFeatureBitsForLndInvoiceError()
case match(KnownLndErrorDetails.InsufficientFee):
return new InsufficientFeeForLnPaymentError()

default:
return handleCommonLightningServiceErrors(err)
Expand Down
Loading