Merge pull request #55 from TheBlueMatt/2022-03-node-alias
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 29 Mar 2022 23:13:30 +0000 (23:13 +0000)
committerGitHub <noreply@github.com>
Tue, 29 Mar 2022 23:13:30 +0000 (23:13 +0000)
src/cli.rs
src/hex_utils.rs

index d6ffa5d96f2edf818bd7fcfee07bc9aa42413c8a..681714f17936093dc218c4411df1bce0b27b5b97 100644 (file)
@@ -321,8 +321,8 @@ pub(crate) async fn poll_for_user_input<E: EventHandler>(
                                                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];
@@ -336,8 +336,8 @@ pub(crate) async fn poll_for_user_input<E: EventHandler>(
                                                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];
index 70fe28b13f30d8c5cf13ae3c6257bc3f3ece701c..0eee5af03beaa7938f8fd60a54765a79362d6b6b 100644 (file)
@@ -31,6 +31,9 @@ pub fn hex_str(value: &[u8]) -> String {
 }
 
 pub fn to_compressed_pubkey(hex: &str) -> Option<PublicKey> {
+       if hex.len() != 33 * 2 {
+               return None;
+       }
        let data = match to_vec(&hex[0..33 * 2]) {
                Some(bytes) => bytes,
                None => return None,