utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:two1-python 作者: 21dotco 项目源码 文件源码
def key_hash_to_address(hash160, version=0x0):
    """Convert RIPEMD-160 hash to bitcoin address.

    Args:
        hash160 (bytes/str): bitcoin hash160 to decode
        version (int): The version prefix

    Returns:
        (bitcoin address): base58 encoded bitcoin address
    """
    if isinstance(hash160, str):
        # if 0x in string, strip it
        if "0x" in hash160:
            h160 = hex_str_to_bytes(hash160[2:])
        else:
            h160 = hex_str_to_bytes(hash160)
    elif isinstance(hash160, bytes):
        h160 = hash160

    address = base58.b58encode_check(bytes([version]) + h160)
    return address
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号