Trim whitespace when signing messages
authorMatt Corallo <git@bluematt.me>
Fri, 11 Aug 2023 20:31:49 +0000 (20:31 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 11 Aug 2023 20:34:54 +0000 (20:34 +0000)
Fixes https://github.com/lightningdevkit/rust-lightning/issues/2188

src/cli.rs

index 8e96fd8c26ac95a98ea04bcf07e8075754db7aaa..a53a0200e2b36e448f1a5b0f7ced31cdd08fc1d2 100644 (file)
@@ -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()
                                                )
                                        );