Force close channel if offline

This commit is contained in:
benthecarman
2024-04-27 22:56:29 -05:00
committed by Tony Giorgio
parent 98c1cdc780
commit 39a7e4d9bf
2 changed files with 17 additions and 4 deletions

View File

@@ -343,7 +343,8 @@
"close_channel": "Close", "close_channel": "Close",
"online_channels": "Online Channels", "online_channels": "Online Channels",
"offline_channels": "Offline 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": { "connections": {
"title": "Wallet Connections", "title": "Wallet Connections",

View File

@@ -98,7 +98,7 @@ function splitChannelNumbers(channel: MutinyChannel): {
}; };
} }
function SingleChannelItem(props: { channel: MutinyChannel }) { function SingleChannelItem(props: { channel: MutinyChannel; online: boolean }) {
const i18n = useI18n(); const i18n = useI18n();
const [state, _actions] = useMegaStore(); const [state, _actions] = useMegaStore();
const network = state.mutiny_wallet?.get_network() as Network; const network = state.mutiny_wallet?.get_network() as Network;
@@ -114,9 +114,10 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
try { try {
if (!props.channel.outpoint) return; if (!props.channel.outpoint) return;
setConfirmLoading(true); setConfirmLoading(true);
const forceClose = !props.online;
await state.mutiny_wallet?.close_channel( await state.mutiny_wallet?.close_channel(
props.channel.outpoint, props.channel.outpoint,
false, forceClose,
false false
); );
} catch (e) { } catch (e) {
@@ -161,7 +162,16 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
onConfirm={closeChannel} onConfirm={closeChannel}
onCancel={() => setConfirmOpen(false)} 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> </ConfirmDialog>
</VStack> </VStack>
</Card> </Card>
@@ -259,6 +269,7 @@ function LiquidityMonitor() {
{(channel) => ( {(channel) => (
<SingleChannelItem <SingleChannelItem
channel={channel} channel={channel}
online={true}
/> />
)} )}
</For> </For>
@@ -279,6 +290,7 @@ function LiquidityMonitor() {
{(channel) => ( {(channel) => (
<SingleChannelItem <SingleChannelItem
channel={channel} channel={channel}
online={false}
/> />
)} )}
</For> </For>