Skip to content

Commit

Permalink
Support no connection string for channel open
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Mar 13, 2024
1 parent e159244 commit 4c8942e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/LnChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 4c8942e

Please sign in to comment.