Skip to content

Commit

Permalink
Merge pull request #2828 from myxmaster/lnurlpay_minsendablesats_hand…
Browse files Browse the repository at this point in the history
…ling

improve minSendableSats handling
  • Loading branch information
kaloudis authored Feb 11, 2025
2 parents d5a1c72 + 855e654 commit e3b611e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions views/LnurlPay/LnurlPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import LoadingIndicator from '../../components/LoadingIndicator';

import InvoicesStore from '../../stores/InvoicesStore';
import LnurlPayStore from '../../stores/LnurlPayStore';
import UnitsStore from '../../stores/UnitsStore';

import LnurlPayMetadata from './Metadata';

Expand All @@ -29,6 +30,7 @@ interface LnurlPayProps {
navigation: StackNavigationProp<any, any>;
InvoicesStore: InvoicesStore;
LnurlPayStore: LnurlPayStore;
UnitsStore: UnitsStore;
route: Route<'LnurlPay', { lnurlParams: any; amount: any; satAmount: any }>;
}

Expand All @@ -40,7 +42,7 @@ interface LnurlPayState {
loading: boolean;
}

@inject('InvoicesStore', 'LnurlPayStore')
@inject('InvoicesStore', 'LnurlPayStore', 'UnitsStore')
@observer
export default class LnurlPay extends React.Component<
LnurlPayProps,
Expand Down Expand Up @@ -73,15 +75,17 @@ export default class LnurlPay extends React.Component<
}

stateFromProps(props: LnurlPayProps) {
const { route } = props;
const { route, UnitsStore } = props;
const { lnurlParams: lnurl, amount, satAmount } = route.params ?? {};

const minSendableSats = Math.floor(lnurl.minSendable / 1000);

const { amount: unformattedAmount } =
UnitsStore.getUnformattedAmount(minSendableSats);

return {
amount:
amount && amount != 0
? amount
: Math.floor(lnurl.minSendable / 1000).toString(),
satAmount: satAmount ? satAmount : '',
amount: amount && amount != 0 ? amount : unformattedAmount,
satAmount: satAmount ? satAmount : minSendableSats,
domain: lnurl.domain,
comment: ''
};
Expand Down

0 comments on commit e3b611e

Please sign in to comment.