Skip to content

Commit

Permalink
Hide forceClosePendingChannel in recovery mode
Browse files Browse the repository at this point in the history
  • Loading branch information
niteshbalusu11 authored Jan 28, 2023
1 parent 2d415c1 commit a34be99
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/components/PendingChannelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { useTranslation } from "react-i18next";
import { namespaces } from "../i18n/i18n.constants";
import { Alert } from "../utils/alert";

const dataLossChannelState = 'ChanStatusLocalDataLoss|ChanStatusRestored';

export interface IPendingChannelCardProps {
type: "OPEN" | "CLOSING" | "FORCE_CLOSING" | "WAITING_CLOSE";
channel: lnrpc.PendingChannelsResponse.IPendingOpenChannel
Expand All @@ -39,8 +41,16 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
if (!channel.channel) {
return (<Text>Error</Text>);
}
const closingChannel = channel as lnrpc.PendingChannelsResponse.IWaitingCloseChannel;

const isForceClosableChannel = (channel.channel?.chanStatusFlags === dataLossChannelState) || !!closingChannel.closingTxid ? false : true

const forceClose = (channel: lnrpc.PendingChannelsResponse.IWaitingCloseChannel) => {
if (channel.channel?.chanStatusFlags === dataLossChannelState) {
Alert.alert("Cannot Force Close A Channel In Recovery State");
return;
}

if (!!channel.closingTxid || channel.closingTxid !== '') {
Alert.alert("Closing Tx Has Already Been Broadcasted");
return;
Expand Down Expand Up @@ -237,13 +247,17 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
</CopyText>
</Right>
</Row>
<Row style={{ width: "100%" }}>
<Left>
<Button style={{ marginTop: 14 }} danger={true} small={true} onPress={() => forceClose(channel)}>
<Text style={{ fontSize: 8 }}>{t("channel.forceClosePendingChannel")}</Text>
</Button>
</Left>
</Row>
{
isForceClosableChannel ? (
<Row style={{ width: "100%" }}>
<Left>
<Button style={{ marginTop: 14 }} danger={true} small={true} onPress={() => forceClose(channel)}>
<Text style={{ fontSize: 8 }}>{t("channel.forceClosePendingChannel")}</Text>
</Button>
</Left>
</Row>
) : null
}
</>
}
{type === "FORCE_CLOSING" &&
Expand Down

1 comment on commit a34be99

@vercel
Copy link

@vercel vercel bot commented on a34be99 Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blixt-wallet – ./

blixt-wallet-git-master-hsjoberg.vercel.app
blixt-wallet-hsjoberg.vercel.app

Please sign in to comment.