From: Matt Corallo Date: Sun, 27 Mar 2022 03:32:43 +0000 (+0000) Subject: Avoid panic if chan IDs passed to {force,}closechannel isn't 32 bytes X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=3682dca7abdf49d26f9c57de449e17582004239d;p=ldk-sample Avoid panic if chan IDs passed to {force,}closechannel isn't 32 bytes --- diff --git a/src/cli.rs b/src/cli.rs index 88f8542..3d28fd1 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -320,8 +320,8 @@ pub(crate) async fn poll_for_user_input( continue; } let channel_id_vec = hex_utils::to_vec(channel_id_str.unwrap()); - if channel_id_vec.is_none() { - println!("ERROR: couldn't parse channel_id as hex"); + if channel_id_vec.is_none() || channel_id_vec.as_ref().unwrap().len() != 32 { + println!("ERROR: couldn't parse channel_id"); continue; } let mut channel_id = [0; 32]; @@ -335,8 +335,8 @@ pub(crate) async fn poll_for_user_input( continue; } let channel_id_vec = hex_utils::to_vec(channel_id_str.unwrap()); - if channel_id_vec.is_none() { - println!("ERROR: couldn't parse channel_id as hex"); + if channel_id_vec.is_none() || channel_id_vec.as_ref().unwrap().len() != 32 { + println!("ERROR: couldn't parse channel_id"); continue; } let mut channel_id = [0; 32];