feat(signer): expose Wallet::sign_hash

This commit is contained in:
Georgios Konstantopoulos 2021-10-25 16:45:39 +03:00
parent c3dec4a798
commit 5ab0b7e0f4
1 changed files with 4 additions and 2 deletions

View File

@ -118,13 +118,15 @@ impl<D: Sync + Send + DigestSigner<Sha256Proxy, RecoverableSignature>> Signer fo
} }
impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> { impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> {
/// Synchronously signs the provided transaction.
pub fn sign_transaction_sync(&self, tx: &TypedTransaction) -> Signature { pub fn sign_transaction_sync(&self, tx: &TypedTransaction) -> Signature {
let sighash = tx.sighash(self.chain_id); let sighash = tx.sighash(self.chain_id);
self.sign_hash(sighash, true) self.sign_hash(sighash, true)
} }
fn sign_hash(&self, hash: H256, eip155: bool) -> Signature { /// Signs the provided hash and proceeds to normalize the `v` value of the
/// signature with EIP-155 if the flag is set to true.
pub fn sign_hash(&self, hash: H256, eip155: bool) -> Signature {
let recoverable_sig: RecoverableSignature = let recoverable_sig: RecoverableSignature =
self.signer.sign_digest(Sha256Proxy::from(hash)); self.signer.sign_digest(Sha256Proxy::from(hash));