]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Correctly parse args without port but with net
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Thu, 26 Aug 2021 04:17:59 +0000 (04:17 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 27 Aug 2021 02:03:23 +0000 (02:03 +0000)
Fixes #33.

src/cli.rs

index d4d7e9ed4263079d84f3e3e42d1efc269f8f5404..476ea81efd6803e393f237bd5965333767b00bc2 100644 (file)
@@ -70,7 +70,10 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
        let mut ldk_peer_port_set = true;
        let ldk_peer_listening_port: u16 = match env::args().skip(3).next().map(|p| p.parse()) {
                Some(Ok(p)) => p,
-               Some(Err(e)) => panic!("{}", e),
+               Some(Err(_)) => {
+                       ldk_peer_port_set = false;
+                       9735
+               }
                None => {
                        ldk_peer_port_set = false;
                        9735
@@ -84,7 +87,9 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
        let network: Network = match env::args().skip(arg_idx).next().as_ref().map(String::as_str) {
                Some("testnet") => Network::Testnet,
                Some("regtest") => Network::Regtest,
-               Some(_) => panic!("Unsupported network provided. Options are: `regtest`, `testnet`"),
+               Some(net) => {
+                       panic!("Unsupported network provided. Options are: `regtest`, `testnet`. Got {}", net);
+               }
                None => Network::Testnet,
        };