Skip to content

Commit

Permalink
fix: show error when trying to create LN invoice with amount > remote…
Browse files Browse the repository at this point in the history
…Balance
  • Loading branch information
limpbrains committed May 28, 2024
1 parent ef7996d commit aef1417
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/screens/Wallets/Receive/ReceiveQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { receiveSelector } from '../../../store/reselect/receive';
import { ReceiveScreenProps } from '../../../navigation/types';
import { isGeoBlockedSelector } from '../../../store/reselect/user';
import { getWalletStore } from '../../../store/helpers';
import { showToast } from '../../../utils/notifications';

type Slide = () => ReactElement;

Expand Down Expand Up @@ -113,11 +114,17 @@ const ReceiveQR = ({
}, [jitInvoice, lightningBalance.remoteBalance]);

const getLightningInvoice = useCallback(async (): Promise<void> => {
if (
!receiveNavigationIsOpen ||
!lightningBalance.remoteBalance ||
lightningBalance.remoteBalance < amount
) {
if (!receiveNavigationIsOpen || !lightningBalance.remoteBalance) {
return;
}

if (lightningBalance.remoteBalance < amount) {
setLightningInvoice('');
showToast({
type: 'error',
title: t('receive_insufficient_title'),
description: t('receive_insufficient_text'),
});
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/utils/i18n/locales/en/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,7 @@
"refresh_error_title": "Refresh Failed",
"refresh_error_throttle_title": "Connection Throttled",
"refresh_error_throttle_description": "Electrum server connection is throttled. Please wait several minutes before trying again.",
"ldk_sync_error_title": "Lightning Sync Error"
"ldk_sync_error_title": "Lightning Sync Error",
"receive_insufficient_title": "Insufficient receiving balance.",
"receive_insufficient_text": "Insufficient receiving capacity to receive this amount over Lightning."
}

0 comments on commit aef1417

Please sign in to comment.