1
0

Revert "remove python implementation of ripemd160"

This reverts commit 56c4a8746f.
This commit is contained in:
ThomasV
2017-08-26 06:48:16 +02:00
parent d531fe59b2
commit 126bbff948
2 changed files with 408 additions and 8 deletions

View File

@@ -275,14 +275,15 @@ def i2o_ECPublicKey(pubkey, compressed=False):
############ functions from pywallet #####################
def hash_160(public_key):
if 'ANDROID_DATA' in os.environ:
from Crypto.Hash import RIPEMD
md = RIPEMD.new()
else:
md = hashlib.new('ripemd')
public_key = to_bytes(public_key, 'ascii')
md.update(sha256(public_key))
return md.digest()
try:
md = hashlib.new('ripemd160')
md.update(sha256(public_key))
return md.digest()
except Exception:
# not available in Android SL4a
import ripemd
md = ripemd.new(sha256(public_key))
return md.digest()
def hash_160_to_bc_address(h160, addrtype, witness_program_version=1):