From: Matt Corallo Date: Fri, 11 Aug 2023 20:31:49 +0000 (+0000) Subject: Trim whitespace when signing messages X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=55dc47ff1c12f05c524fab2a191999dfe5e4fb8b;p=ldk-sample Trim whitespace when signing messages Fixes https://github.com/lightningdevkit/rust-lightning/issues/2188 --- 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() ) );