Skip to content

Commit

Permalink
[rooch-networkgh-2381] fix some issues of the account sign command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Sep 8, 2024
1 parent 8065a6b commit 3789d1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions crates/rooch-types/src/framework/auth_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ impl AuthPayload {
}
}

pub fn new_without_tx_hash(sign_data: SignData, signature: Signature, bitcoin_address: String) -> Self {
debug_assert_eq!(signature.scheme(), SignatureScheme::Secp256k1);
AuthPayload {
signature: signature.signature_bytes().to_vec(),
message_prefix: sign_data.message_prefix,
message_info: sign_data.message_info,
public_key: signature.public_key_bytes().to_vec(),
from_address: bitcoin_address.into_bytes(),
}
}

pub fn verify(&self, tx_data: &RoochTransactionData) -> Result<()> {
let pk = Secp256k1PublicKey::from_bytes(&self.public_key)?;
let sign_data = SignData::new(
Expand Down
4 changes: 2 additions & 2 deletions crates/rooch/src/commands/account/commands/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rooch_types::{
function_arg::{parse_function_arg, FunctionArg, ParsedFunctionId},
};

/// Sign a tx with an account
/// Sign a message with the bitcoin address
#[derive(Debug, Parser)]
pub struct SignCommand {
// the address to be used
Expand Down Expand Up @@ -52,7 +52,7 @@ impl CommandAction<Option<String>> for SignCommand {
password,
)?;

let auth_payload = AuthPayload::new(sign_data, signature, self.bitcoin_address.to_string());
let auth_payload = AuthPayload::new_without_tx_hash(sign_data, signature, self.bitcoin_address.to_string());
let auth_payload_hex = auth_payload.to_bytes().encode_hex();

if self.json {
Expand Down

0 comments on commit 3789d1f

Please sign in to comment.