Skip to content

Commit 65cbf12

Browse files
authored
Merge pull request #146 from joostjager/cli-connect-peer-pubkey-at-address-format
2 parents a4da3ef + 4e98301 commit 65cbf12

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

ldk-server-cli/src/main.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ enum Commands {
364364
},
365365
#[command(about = "Connect to a peer on the Lightning Network without opening a channel")]
366366
ConnectPeer {
367-
#[arg(help = "The hex-encoded public key of the node to connect to")]
367+
#[arg(
368+
help = "The peer to connect to in pubkey@address format, or just the pubkey if address is provided separately"
369+
)]
368370
node_pubkey: String,
369371
#[arg(
370-
help = "Address to connect to remote peer (IPv4:port, IPv6:port, OnionV3:port, or hostname:port)"
372+
help = "Address to connect to remote peer (IPv4:port, IPv6:port, OnionV3:port, or hostname:port). Optional if address is included in pubkey via @ separator."
371373
)]
372-
address: String,
374+
address: Option<String>,
373375
#[arg(
374376
long,
375377
default_value_t = false,
@@ -799,6 +801,14 @@ async fn main() {
799801
);
800802
},
801803
Commands::ConnectPeer { node_pubkey, address, persist } => {
804+
let (node_pubkey, address) = if let Some(address) = address {
805+
(node_pubkey, address)
806+
} else if let Some((pubkey, addr)) = node_pubkey.split_once('@') {
807+
(pubkey.to_string(), addr.to_string())
808+
} else {
809+
eprintln!("Error: address is required. Provide it as pubkey@address or as a separate argument.");
810+
std::process::exit(1);
811+
};
802812
handle_response_result::<_, ConnectPeerResponse>(
803813
client.connect_peer(ConnectPeerRequest { node_pubkey, address, persist }).await,
804814
);

0 commit comments

Comments
 (0)