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

Commit 39a7e4d

Browse files
benthecarmanAnthonyRonning
authored andcommitted
Force close channel if offline
1 parent 98c1cdc commit 39a7e4d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

public/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@
343343
"close_channel": "Close",
344344
"online_channels": "Online Channels",
345345
"offline_channels": "Offline Channels",
346-
"close_channel_confirm": "Closing this channel will move the balance on-chain and incur an on-chain fee."
346+
"close_channel_confirm": "Closing this channel will move the balance on-chain and incur an on-chain fee.",
347+
"force_close_channel_confirm": "This channel is offline. Force closing this channel will move the balance on-chain, incur an on-chain fee, and may take a few days to settle."
347348
},
348349
"connections": {
349350
"title": "Wallet Connections",

src/routes/settings/Channels.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function splitChannelNumbers(channel: MutinyChannel): {
9898
};
9999
}
100100

101-
function SingleChannelItem(props: { channel: MutinyChannel }) {
101+
function SingleChannelItem(props: { channel: MutinyChannel; online: boolean }) {
102102
const i18n = useI18n();
103103
const [state, _actions] = useMegaStore();
104104
const network = state.mutiny_wallet?.get_network() as Network;
@@ -114,9 +114,10 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
114114
try {
115115
if (!props.channel.outpoint) return;
116116
setConfirmLoading(true);
117+
const forceClose = !props.online;
117118
await state.mutiny_wallet?.close_channel(
118119
props.channel.outpoint,
119-
false,
120+
forceClose,
120121
false
121122
);
122123
} catch (e) {
@@ -161,7 +162,16 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
161162
onConfirm={closeChannel}
162163
onCancel={() => setConfirmOpen(false)}
163164
>
164-
{i18n.t("settings.channels.close_channel_confirm")}
165+
<Switch>
166+
<Match when={!props.online}>
167+
{i18n.t(
168+
"settings.channels.force_close_channel_confirm"
169+
)}
170+
</Match>
171+
<Match when={true}>
172+
{i18n.t("settings.channels.close_channel_confirm")}
173+
</Match>
174+
</Switch>
165175
</ConfirmDialog>
166176
</VStack>
167177
</Card>
@@ -259,6 +269,7 @@ function LiquidityMonitor() {
259269
{(channel) => (
260270
<SingleChannelItem
261271
channel={channel}
272+
online={true}
262273
/>
263274
)}
264275
</For>
@@ -279,6 +290,7 @@ function LiquidityMonitor() {
279290
{(channel) => (
280291
<SingleChannelItem
281292
channel={channel}
293+
online={false}
282294
/>
283295
)}
284296
</For>

0 commit comments

Comments
 (0)