sign_transaction_sync (#388)

This commit is contained in:
Marc Enriquez 2021-08-18 15:02:57 +02:00 committed by GitHub
parent 7d9dfcb53c
commit 621882053c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -79,8 +79,7 @@ impl<D: Sync + Send + DigestSigner<Sha256Proxy, RecoverableSignature>> Signer fo
} }
async fn sign_transaction(&self, tx: &TypedTransaction) -> Result<Signature, Self::Error> { async fn sign_transaction(&self, tx: &TypedTransaction) -> Result<Signature, Self::Error> {
let sighash = tx.sighash(self.chain_id); Ok(self.sign_transaction_sync(tx))
Ok(self.sign_hash(sighash, true))
} }
fn address(&self) -> Address { fn address(&self) -> Address {
@ -104,6 +103,12 @@ impl<D: Sync + Send + DigestSigner<Sha256Proxy, RecoverableSignature>> Signer fo
} }
impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> { impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> {
pub fn sign_transaction_sync(&self, tx: &TypedTransaction) -> Signature {
let sighash = tx.sighash(self.chain_id);
self.sign_hash(sighash, true)
}
fn sign_hash(&self, hash: H256, eip155: bool) -> Signature { 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));