Skip to content

Commit

Permalink
Apply federation to lightning balances if available
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Dec 21, 2023
1 parent e1cfae2 commit 3bd1d03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/routes/Gift.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function InboundWarning() {
const network = state.mutiny_wallet?.get_network() as Network;

const threshold = network === "bitcoin" ? 100000 : 10000;
const balance = state.balance?.lightning || 0n;
const balance =
(state.balance?.lightning || 0n) +
(state.balance?.federation || 0n);

if (balance === 0n && amount < threshold) {
return i18n.t("settings.gift.receive_too_small", {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export function MethodChooser(props: {
const [store, _actions] = useMegaStore();

const methods = createMemo(() => {
const lnBalance = store.balance?.lightning || 0n;
const lnBalance =
(store.balance?.lightning || 0n) +
(store.balance?.federation || 0n);
const onchainBalance =
(store.balance?.confirmed || 0n) +
(store.balance?.unconfirmed || 0n);
Expand Down
6 changes: 5 additions & 1 deletion src/routes/settings/Plus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ function PlusCTA() {

const hasEnough = () => {
if (!planDetails()) return false;
return (state.balance?.lightning || 0n) > planDetails().amount_sat;
return (
(state.balance?.lightning || 0n) +
(state.balance?.federation || 0n) >
planDetails().amount_sat
);
};

return (
Expand Down

0 comments on commit 3bd1d03

Please sign in to comment.