From 4c8942e774cb3ab35804f7694738d75eba9c1eb9 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 13 Mar 2024 12:08:14 +0000 Subject: [PATCH] Support no connection string for channel open --- src/components/LnChannel.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/LnChannel.tsx b/src/components/LnChannel.tsx index c49c98e..2847445 100644 --- a/src/components/LnChannel.tsx +++ b/src/components/LnChannel.tsx @@ -56,9 +56,22 @@ export function LnChannel() { const [sendResult, { Form }] = createRouteAction( async (formData: FormData) => { const connectionString = formData.get("connectionString")?.toString(); - const [pubkey, host] = connectionString?.split("@") || []; - if (!pubkey || !host) { + if (!connectionString) { + throw new Error("Invalid connection string"); + } + + let pubkey: string; + let host: string | undefined; + if (connectionString?.includes("@")) { + const [pk, h] = connectionString?.split("@") || []; + pubkey = pk; + host = h; + } else { + pubkey = connectionString; + } + + if (!pubkey) { throw new Error("Invalid connection string"); }