Skip to content

Commit

Permalink
Wrap channel close code in try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Jun 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 58bd43a commit 7ed262a
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions src/components/ChannelCard.tsx
Original file line number Diff line number Diff line change
@@ -80,34 +80,43 @@ export function ChannelCard({ channel, alias }: IChannelCardProps) {
style: "default",
text: "Yes",
onPress: async () => {
const result = await closeChannel({
fundingTx: channel.channelPoint!.split(":")[0],
outputIndex: Number.parseInt(channel.channelPoint!.split(":")[1], 10),
force,
deliveryAddress: address,
});
console.log(result);
try {
const result = await closeChannel({
fundingTx: channel.channelPoint!.split(":")[0],
outputIndex: Number.parseInt(channel.channelPoint!.split(":")[1], 10),
force,
deliveryAddress: address,
});
console.log(result);

setTimeout(async () => {
await getChannels(undefined);
}, 3000);
setTimeout(async () => {
await getChannels(undefined);
}, 3000);

if (autopilotEnabled) {
Alert.alert(
"Autopilot",
"Automatic channel opening is enabled, " +
"new on-chain funds will automatically go to a new channel unless you disable it.\n\n" +
"Do you wish to disable automatic channel opening?",
[
{ text: "No" },
{
text: "Yes",
onPress: async () => {
changeAutopilotEnabled(false);
setupAutopilot(false);
if (autopilotEnabled) {
Alert.alert(
"Autopilot",
"Automatic channel opening is enabled, " +
"new on-chain funds will automatically go to a new channel unless you disable it.\n\n" +
"Do you wish to disable automatic channel opening?",
[
{ text: "No" },
{
text: "Yes",
onPress: async () => {
changeAutopilotEnabled(false);
setupAutopilot(false);
},
},
},
],
],
);
}
} catch (error: any) {
toast(
t("msg.error", { ns: namespaces.common }) + ": " + error.message,
0,
"danger",
"OK",
);
}
},

0 comments on commit 7ed262a

Please sign in to comment.