From 55dc47ff1c12f05c524fab2a191999dfe5e4fb8b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 11 Aug 2023 20:31:49 +0000 Subject: [PATCH] Trim whitespace when signing messages Fixes https://github.com/lightningdevkit/rust-lightning/issues/2188 --- src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 8e96fd8..a53a020 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -368,14 +368,14 @@ pub(crate) async fn poll_for_user_input( "listpeers" => list_peers(peer_manager.clone()), "signmessage" => { const MSG_STARTPOS: usize = "signmessage".len() + 1; - if line.as_bytes().len() <= MSG_STARTPOS { + if line.trim().as_bytes().len() <= MSG_STARTPOS { println!("ERROR: signmsg requires a message"); continue; } println!( "{:?}", lightning::util::message_signing::sign( - &line.as_bytes()[MSG_STARTPOS..], + &line.trim().as_bytes()[MSG_STARTPOS..], &keys_manager.get_node_secret_key() ) ); -- 2.39.5