fix compatibility with modern hashlib

ripemd160 has been removed from hashlib, we have to mend it with
other implementation for now
This commit is contained in:
caryoscelus 2022-05-12 20:43:49 +04:00
parent 961cc5361d
commit 3e4f61e1a8
1 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from coincurve import PrivateKey, PublicKey
from base58 import b58encode_check, b58decode_check
from hmac import compare_digest
from util.Electrum import format as zero_format
from ..sslcrypto._ecc import ripemd160
RECID_MIN = 0
RECID_MAX = 3
@ -41,7 +42,7 @@ def compute_secret_address(secretkey):
def public_digest(publickey, compressed=False):
"""Convert a public key to ripemd160(sha256()) digest."""
publickey_hex = publickey.format(compressed=compressed)
return hashlib.new('ripemd160', hashlib.sha256(publickey_hex).digest()).digest()
return ripemd160(hashlib.sha256(publickey_hex).digest()).digest()
def address_public_digest(address):
"""Convert a public Bitcoin address to ripemd160(sha256()) digest."""