Skip to content

Commit

Permalink
chore(core): add 'feature pair exists' error to lnd handling (#3836)
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard authored Jan 15, 2024
1 parent acd2f48 commit 6f23ab8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
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 @@ -47,6 +47,7 @@ export class PaymentInTransitionError extends LightningServiceError {}
export class TemporaryChannelFailureError extends LightningServiceError {}
export class TemporaryNodeFailureError extends LightningServiceError {}
export class DestinationMissingDependentFeatureError extends LightningServiceError {}
export class InvalidFeatureBitsForLndInvoiceError extends LightningServiceError {}
export class LookupPaymentTimedOutError extends LightningServiceError {
level = ErrorLevel.Critical
}
Expand Down
4 changes: 4 additions & 0 deletions core/api/src/graphql/error-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ export const mapError = (error: ApplicationError): CustomGraphQLError => {
message = "Issue with lightning payment, please try again."
return new LightningPaymentError({ message, logger: baseLogger })

case "InvalidFeatureBitsForLndInvoiceError":
message = "Invoice may have invalid feature bits set, please check again."
return new LightningPaymentError({ message, logger: baseLogger })

case "UsernameNotAvailableError":
message = "username not available"
return new UsernameError({ 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 @@ -20,6 +20,7 @@ export const KnownLndErrorDetails = {
TemporaryNodeFailure: /TemporaryNodeFailure/,
InvoiceAlreadySettled: /invoice already settled/,
MissingDependentFeature: /missing dependent feature/,
FeaturePairExists: /feature pair exists/,

// On-chain
InsufficientFunds: /insufficient funds available to construct transaction/,
Expand Down
6 changes: 6 additions & 0 deletions core/api/src/services/lnd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
DestinationMissingDependentFeatureError,
InsufficientBalanceForLnPaymentError,
InsufficientBalanceForRoutingError,
InvalidFeatureBitsForLndInvoiceError,
InvoiceExpiredOrBadPaymentHashError,
InvoiceNotFoundError,
LightningServiceError,
Expand Down Expand Up @@ -1211,6 +1212,8 @@ const handleSendPaymentLndErrors = ({
return new TemporaryNodeFailureError(paymentHash)
case match(KnownLndErrorDetails.InsufficientBalanceToAttemptPayment):
return new InsufficientBalanceForLnPaymentError()
case match(KnownLndErrorDetails.FeaturePairExists):
return new InvalidFeatureBitsForLndInvoiceError()

default:
return handleCommonLightningServiceErrors(err)
Expand Down Expand Up @@ -1245,6 +1248,9 @@ const handleCommonRouteNotFoundErrors = (err: Error | unknown) => {
case match(KnownLndErrorDetails.MissingDependentFeature):
return new DestinationMissingDependentFeatureError()

case match(KnownLndErrorDetails.FeaturePairExists):
return new InvalidFeatureBitsForLndInvoiceError()

default:
return new UnknownRouteNotFoundError(msgForUnknown(err as LnError))
}
Expand Down

0 comments on commit 6f23ab8

Please sign in to comment.