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",
"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",

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 [state, _actions] = useMegaStore();
const network = state.mutiny_wallet?.get_network() as Network;
@@ -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) {
@@ -161,7 +162,16 @@ function SingleChannelItem(props: { channel: MutinyChannel }) {
onConfirm={closeChannel}
onCancel={() => setConfirmOpen(false)}
>
<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>
@@ -259,6 +269,7 @@ function LiquidityMonitor() {
{(channel) => (
<SingleChannelItem
channel={channel}
online={true}
/>
)}
</For>
@@ -279,6 +290,7 @@ function LiquidityMonitor() {
{(channel) => (
<SingleChannelItem
channel={channel}
online={false}
/>
)}
</For>