Skip to content

Commit

Permalink
Force close channel if offline
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and AnthonyRonning committed Apr 29, 2024
1 parent 98c1cdc commit 39a7e4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@
"close_channel": "Close",
"online_channels": "Online Channels",
"offline_channels": "Offline Channels",
"close_channel_confirm": "Closing this channel will move the balance on-chain and incur an on-chain fee."
"close_channel_confirm": "Closing this channel will move the balance on-chain and incur an on-chain fee.",
"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."
},
"connections": {
"title": "Wallet Connections",
Expand Down
18 changes: 15 additions & 3 deletions src/routes/settings/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function splitChannelNumbers(channel: MutinyChannel): {
};
}

function SingleChannelItem(props: { channel: MutinyChannel }) {
function SingleChannelItem(props: { channel: MutinyChannel; online: boolean }) {
const i18n = useI18n();
const [state, _actions] = useMegaStore();
const network = state.mutiny_wallet?.get_network() as Network;
Expand All @@ -114,9 +114,10 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
try {
if (!props.channel.outpoint) return;
setConfirmLoading(true);
const forceClose = !props.online;
await state.mutiny_wallet?.close_channel(
props.channel.outpoint,
false,
forceClose,
false
);
} catch (e) {
Expand Down Expand Up @@ -161,7 +162,16 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
onConfirm={closeChannel}
onCancel={() => setConfirmOpen(false)}
>
{i18n.t("settings.channels.close_channel_confirm")}
<Switch>
<Match when={!props.online}>
{i18n.t(
"settings.channels.force_close_channel_confirm"
)}
</Match>
<Match when={true}>
{i18n.t("settings.channels.close_channel_confirm")}
</Match>
</Switch>
</ConfirmDialog>
</VStack>
</Card>
Expand Down Expand Up @@ -259,6 +269,7 @@ function LiquidityMonitor() {
{(channel) => (
<SingleChannelItem
channel={channel}
online={true}
/>
)}
</For>
Expand All @@ -279,6 +290,7 @@ function LiquidityMonitor() {
{(channel) => (
<SingleChannelItem
channel={channel}
online={false}
/>
)}
</For>
Expand Down

0 comments on commit 39a7e4d

Please sign in to comment.