Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

Commit 76e08b0

Browse files
authored
Merge pull request #1344 from synonymdev/close-channel-fix
fix(lightning): only close channel when ready to avoid ldk hang bug
2 parents f70bff0 + 024096b commit 76e08b0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/utils/lightning/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,23 @@ export const closeChannel = async ({
14181418
try {
14191419
// Ensure we're fully up-to-date.
14201420
await refreshLdk();
1421+
1422+
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TODO remove after LDK updated to 0.0.118
1423+
const getChannelsResponse = await getLightningChannels();
1424+
if (getChannelsResponse.isErr()) {
1425+
return err(getChannelsResponse.error.message);
1426+
}
1427+
1428+
const channelToClose = getChannelsResponse.value.find(
1429+
(c) => c.channel_id === channelId,
1430+
);
1431+
if (!channelToClose?.is_channel_ready || !channelToClose.is_usable) {
1432+
return err(
1433+
'Channel temporarily unavailable for closing. Please try again in a few moments.',
1434+
);
1435+
}
1436+
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< TODO remove after LDK updated to 0.0.118
1437+
14211438
return await ldk.closeChannel({ channelId, counterPartyNodeId, force });
14221439
} catch (e) {
14231440
console.log(e);

0 commit comments

Comments
 (0)