Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit f8f0103

Browse files
Add lightning sweep functionality to fedimint
1 parent 6cd7708 commit f8f0103

File tree

8 files changed

+358
-50
lines changed

8 files changed

+358
-50
lines changed

src/components/BalanceBox.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,37 @@ export function BalanceBox(props: { loading?: boolean }) {
9494
<Show when={state.federations && state.federations.length}>
9595
<Show when={!props.loading} fallback={<LoadingShimmer />}>
9696
<hr class="my-2 border-m-grey-750" />
97-
<div class="flex flex-col gap-1">
98-
<div class="text-2xl">
99-
<AmountSats
100-
amountSats={state.balance?.federation || 0}
101-
icon="community"
102-
denominationSize="lg"
103-
/>
104-
</div>
105-
<div class="text-lg text-white/70">
106-
<AmountFiat
107-
amountSats={state.balance?.federation || 0n}
108-
denominationSize="sm"
109-
/>
97+
<div class="flex justify-between">
98+
<div class="flex flex-col gap-1">
99+
<div class="text-2xl">
100+
<AmountSats
101+
amountSats={
102+
state.balance?.federation || 0
103+
}
104+
icon="community"
105+
denominationSize="lg"
106+
/>
107+
</div>
108+
<div class="text-lg text-white/70">
109+
<AmountFiat
110+
amountSats={
111+
state.balance?.federation || 0n
112+
}
113+
denominationSize="sm"
114+
/>
115+
</div>
110116
</div>
117+
<Show when={state.balance?.federation || 0n > 0n}>
118+
<div class="self-end justify-self-end">
119+
<A href="/swaplightning" class={STYLE}>
120+
<img
121+
src={shuffle}
122+
alt="swaplightning"
123+
class="h-6 w-6"
124+
/>
125+
</A>
126+
</div>
127+
</Show>
111128
</div>
112129
</Show>
113130
</Show>

src/components/Failure.tsx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { MutinyInvoice } from "@mutinywallet/mutiny-wasm";
2+
import { A, useNavigate, useSearchParams } from "@solidjs/router";
3+
import {
4+
createEffect,
5+
createMemo,
6+
createResource,
7+
createSignal,
8+
JSX,
9+
Match,
10+
onMount,
11+
Show,
12+
Suspense,
13+
Switch
14+
} from "solid-js";
15+
16+
import bolt from "~/assets/icons/bolt.svg";
17+
import chain from "~/assets/icons/chain.svg";
18+
import close from "~/assets/icons/close.svg";
19+
import {
20+
ActivityDetailsModal,
21+
AmountEditable,
22+
AmountFiat,
23+
AmountSats,
24+
BackPop,
25+
Button,
26+
DefaultMain,
27+
Fee,
28+
FeeDisplay,
29+
HackActivityType,
30+
InfoBox,
31+
LabelCircle,
32+
LoadingShimmer,
33+
MegaCheck,
34+
MegaClock,
35+
MegaEx,
36+
MethodChoice,
37+
MutinyWalletGuard,
38+
NavBar,
39+
showToast,
40+
SimpleInput,
41+
SmallHeader,
42+
StringShower,
43+
SuccessModal,
44+
UnstyledBackPop,
45+
VStack
46+
} from "~/components";
47+
import { useI18n } from "~/i18n/context";
48+
import { ParsedParams } from "~/logic/waila";
49+
import { useMegaStore } from "~/state/megaStore";
50+
import { eify, vibrateSuccess } from "~/utils";
51+
52+
export function Failure(props: { reason: string }) {
53+
const i18n = useI18n();
54+
55+
return (
56+
<Switch>
57+
<Match when={props.reason === "Payment timed out."}>
58+
<MegaClock />
59+
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
60+
{i18n.t("send.payment_pending")}
61+
</h1>
62+
<InfoBox accent="white">
63+
{i18n.t("send.payment_pending_description")}
64+
</InfoBox>
65+
</Match>
66+
<Match
67+
when={props.reason === "Channel reserve amount is too high."}
68+
>
69+
<MegaEx />
70+
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
71+
{i18n.t("send.error_channel_reserves")}
72+
</h1>
73+
<InfoBox accent="white">
74+
{i18n.t("send.error_channel_reserves_explained")}{" "}
75+
<A href="/settings/channels">{i18n.t("common.why")}</A>
76+
</InfoBox>
77+
</Match>
78+
<Match when={true}>
79+
<MegaEx />
80+
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
81+
{props.reason}
82+
</h1>
83+
</Match>
84+
</Switch>
85+
);
86+
}

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export * from "./Restart";
3636
export * from "./ResyncOnchain";
3737
export * from "./SeedWords";
3838
export * from "./SetupErrorDisplay";
39+
export * from "./Failure";
3940
export * from "./ShareCard";
4041
export * from "./Toaster";
4142
export * from "./NostrActivity";

src/i18n/en/translations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,14 @@ export default {
595595
connecting: "Connecting...",
596596
confirm_swap: "Confirm Swap"
597597
},
598+
swap_lightning: {
599+
insufficient_funds: "You don't have enough funds to swap to lightning",
600+
header: "Swap to Lightning",
601+
initiated: "Swap Initiated",
602+
sats_added: "+{{amount}} sats will be added to your Lightning balance",
603+
sats_fee: "+{{amount}} sats fee",
604+
confirm_swap: "Confirm Swap"
605+
},
598606
reload: {
599607
mutiny_update: "Mutiny Update",
600608
new_version_description:

src/router.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
Scanner,
1616
Search,
1717
Send,
18-
Swap
18+
Swap,
19+
SwapLightning
1920
} from "~/routes";
2021
import {
2122
Admin,
@@ -101,6 +102,7 @@ export function Router() {
101102
<Route path="/scanner" component={Scanner} />
102103
<Route path="/send" component={Send} />
103104
<Route path="/swap" component={Swap} />
105+
<Route path="/swaplightning" component={SwapLightning} />
104106
<Route path="/search" component={Search} />
105107
<Route path="/settings">
106108
<Route path="/" component={Settings} />

src/routes/Send.tsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
BackPop,
2525
Button,
2626
DefaultMain,
27+
Failure,
2728
Fee,
2829
FeeDisplay,
2930
HackActivityType,
@@ -206,42 +207,6 @@ function DestinationItem(props: {
206207
);
207208
}
208209

209-
function Failure(props: { reason: string }) {
210-
const i18n = useI18n();
211-
212-
return (
213-
<Switch>
214-
<Match when={props.reason === "Payment timed out."}>
215-
<MegaClock />
216-
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
217-
{i18n.t("send.payment_pending")}
218-
</h1>
219-
<InfoBox accent="white">
220-
{i18n.t("send.payment_pending_description")}
221-
</InfoBox>
222-
</Match>
223-
<Match
224-
when={props.reason === "Channel reserve amount is too high."}
225-
>
226-
<MegaEx />
227-
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
228-
{i18n.t("send.error_channel_reserves")}
229-
</h1>
230-
<InfoBox accent="white">
231-
{i18n.t("send.error_channel_reserves_explained")}{" "}
232-
<A href="/settings/channels">{i18n.t("common.why")}</A>
233-
</InfoBox>
234-
</Match>
235-
<Match when={true}>
236-
<MegaEx />
237-
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
238-
{props.reason}
239-
</h1>
240-
</Match>
241-
</Switch>
242-
);
243-
}
244-
245210
export function Send() {
246211
const [state, actions] = useMegaStore();
247212
const navigate = useNavigate();

0 commit comments

Comments
 (0)