Skip to content

Commit

Permalink
fix: throw error if LNURL withdraw min > max
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Aug 9, 2023
1 parent 2c35cb2 commit 6d1c915
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/i18n/locales/en/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"lnurl_withdr_error_no_capacity": "Not enough inbound/receiving capacity to complete lnurl-withdraw request.",
"lnurl_withdr_error_create_invoice": "Unable to successfully create invoice for lnurl-withdraw.",
"lnurl_withdr_error_connect": "Unable to connect to LNURL withdraw server.",
"lnurl_withdr_error_minmax": "Wrong LNURL withdraw params, min/max not set correctly.",
"lnurl_withdr_success_title": "Withdraw Requested",
"lnurl_withdr_success_msg": "LNURL Withdraw was successfully requested.",
"bt_error_retrieve": "Unable To Retrieve Order Information",
Expand Down
11 changes: 11 additions & 0 deletions src/utils/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,17 @@ export const handleData = async ({
params.minWithdrawable = Math.floor(params.minWithdrawable / 1000);
params.maxWithdrawable = Math.floor(params.maxWithdrawable / 1000);

if (params.minWithdrawable > params.maxWithdrawable) {
showToast({
type: 'error',
title: i18n.t('other:lnurl_withdr_error'),
description: i18n.t('other:lnurl_withdr_error_minmax'),
});
return err(
'Wrong lnurl-withdraw params: minWithdrawable > maxWithdrawable.',
);
}

// Determine if we have enough receiving capacity before proceeding.
const lightningBalance = getLightningBalance({
selectedWallet,
Expand Down

0 comments on commit 6d1c915

Please sign in to comment.