Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tx_signer: include signer's public key in transaction #148

Merged
merged 1 commit into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ impl KeyRing {
}
}

/// Get ECDSA public key bytes for a given account ID
pub fn get_account_pubkey(&self, account_id: account::Id) -> Option<tendermint::PublicKey> {
for key in self.ecdsa_keys.keys() {
if let TendermintKey::AccountKey(pk) = key {
if account_id == account::Id::from(*pk) {
return Some(*pk);
}
}
}

None
}

/// Sign a message using ECDSA
pub fn sign_ecdsa(
&self,
Expand Down
8 changes: 7 additions & 1 deletion src/tx_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,15 @@ impl TxSigner {

let account_id = tendermint::account::Id::new(self.address.0);

let signature =
let mut signature =
StdSignature::from(chain.keyring.sign_ecdsa(account_id, sign_msg.as_bytes())?);

signature.pub_key = chain
.keyring
.get_account_pubkey(account_id)
.expect("missing account key")
.as_bytes();

let msg_type_info = msg_types
.iter()
.map(|ty| ty.to_string())
Expand Down