diff --git a/apps/frontend/src/components/cln/ChannelDetails/ChannelDetails.tsx b/apps/frontend/src/components/cln/ChannelDetails/ChannelDetails.tsx index ec41265d..8a82e639 100755 --- a/apps/frontend/src/components/cln/ChannelDetails/ChannelDetails.tsx +++ b/apps/frontend/src/components/cln/ChannelDetails/ChannelDetails.tsx @@ -24,7 +24,7 @@ const ChannelDetails = (props) => { const nodeInfo = useSelector(selectNodeInfo); const showToast = useSelector(selectShowToast); const [showToastState, setShowToastState] = useState(false); - const [channelClosed, setChannelClosed] = useState(props.selChannel.current_state !== 'ACTIVE'); + const [channelClosed, setChannelClosed] = useState(props.selChannel.current_state !== 'ACTIVE' && props.selChannel.state !== 'CHANNELD_NORMAL'); const [responseStatus, setResponseStatus] = useState(CallStatus.NONE); const [responseMessage, setResponseMessage] = useState(''); @@ -72,14 +72,17 @@ const ChannelDetails = (props) => { if (response) { setResponseStatus(CallStatus.PENDING); setResponseMessage('Closing Channel...'); - CLNService.closeChannel(props.selChannel.channel_id) + CLNService.closeChannel(props.selChannel.channel_id, props.selChannel.current_state === 'INACTIVE') .then((response: any) => { logger.info(response); if (response.type) { - props.selChannel.current_state = 'PENDING'; + props.onChannelStateChange('PENDING'); setChannelClosed(true); setResponseStatus(CallStatus.SUCCESS); - setResponseMessage('Channel ' + response.type + ' closed' + (response.txid ? (' with transaction id ' + response.txid) : '')); + setResponseMessage('Channel ' + response.type + ' closed' + + (response.txid ? (' with transaction id ' + response.txid) : + response.txids && response.txids.length > 0 ? (' with transaction id ' + response.txids[0]) : '') + ); delayedClearStatusAlert(); } else { setResponseStatus(CallStatus.ERROR); @@ -190,113 +193,6 @@ const ChannelDetails = (props) => { - - - Withdrawal Timelock - - - {props.selChannel.their_to_self_delay} Blocks - - - - - Opened By - - - {titleCase(props.selChannel.opener)} - - - - - Channel Type - - - {props.selChannel.private ? 'Private' : 'Public'} - - - - - Dust Limit - - - {formatCurrency( - props.selChannel.dust_limit_msat, - Units.MSATS, - uiConfigUnit, - false, - 8, - 'string', - )}{' '} - {uiConfigUnit} - - - - - Spendable - - - {formatCurrency( - props.selChannel.spendable_msat, - Units.MSATS, - uiConfigUnit, - false, - 8, - 'string', - )}{' '} - {uiConfigUnit} - - - - - Receivable - - - {formatCurrency( - props.selChannel.receivable_msat, - Units.MSATS, - uiConfigUnit, - false, - 8, - 'string', - )}{' '} - {uiConfigUnit} - - - - - Channel ID - - - {props.selChannel.channel_id} - - - - - - - - Funding ID - - - {props.selChannel.funding_txid} - - - - - - - - { className="btn-rounded bg-primary" disabled={responseStatus === CallStatus.PENDING} > - Close Channel + {props.selChannel.current_state === 'INACTIVE' ? 'Force Close Channel' : 'Close Channel'} {responseStatus === CallStatus.PENDING ? ( ) : ( diff --git a/apps/frontend/src/components/cln/ChannelsCard/ChannelsCard.tsx b/apps/frontend/src/components/cln/ChannelsCard/ChannelsCard.tsx index e16d19be..d53af4da 100755 --- a/apps/frontend/src/components/cln/ChannelsCard/ChannelsCard.tsx +++ b/apps/frontend/src/components/cln/ChannelsCard/ChannelsCard.tsx @@ -36,7 +36,13 @@ const ChannelsCard = () => { {selChannelCard === 'open' ? ( ) : selChannelCard === 'details' ? ( - setSelChannelCard('channels')} selChannel={selChannel} /> + setSelChannelCard('channels')} + selChannel={selChannel} + onChannelStateChange={(newState) => setSelChannel(prev => + prev ? { ...prev, current_state: newState } as PeerChannel : null + )} + /> ) : (