Skip to content

Commit

Permalink
[rooch-networkgh-2381] add msg prefix to the account sign command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Sep 5, 2024
1 parent 57ebcfd commit fef6ad6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/rooch/src/commands/account/commands/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use rooch_types::{
error::{RoochError, RoochResult},
};

struct AuthPayload {
message_prefix: Vec<u8>,
}

/// Sign an msg with current account private key (sign_hashed)
///
/// This operation must be specified with -a or
Expand Down Expand Up @@ -43,10 +47,18 @@ impl CommandAction<Option<AccountSignView>> for SignCommand {
RoochError::CommandArgumentError(format!("Invalid Rooch address String: {}", e))
})?;

let auth_payload = AuthPayload {
message_prefix: "Bitcoin Signed Message:\n".into()
};

let mut msg_body = Vec::<u8>::new();
msg_body.copy_from_slice(&auth_payload.message_prefix);
msg_body.copy_from_slice(&self.msg.clone().into_bytes());

let signature =
context
.keystore
.sign_hashed(&addrss, &self.msg.clone().into_bytes(), password)?;
.sign_hashed(&addrss, &msg_body, password)?;

if self.json {
Ok(Some(AccountSignView::new(
Expand Down

0 comments on commit fef6ad6

Please sign in to comment.