Exemple #1
0
def pubkey_hash_to_address(pubkey_hash, net, version=None):
    if version == None:
        version = net.ADDRESS_VERSION

    if version == 0:
        return segwit_addr.encode(net.HUMAN_READABLE_PART, 0, [int(x) for x in bytearray.fromhex(hex(pubkey_hash)[2:-1])])
    return base58_encode(human_address_type.pack(dict(version=version, pubkey_hash=pubkey_hash)))
Exemple #2
0
def pubkey_hash_to_address(pubkey_hash, addr_ver, bech32_ver, net):
    if addr_ver == -1:
        if hasattr(net, 'padding_bugfix') and net.padding_bugfix:
            thash = '{:040x}'.format(pubkey_hash)
        else:
            thash = '{:x}'.format(pubkey_hash)
            if len(thash) % 2 == 1:
                thash = '0%s' % thash
        data = [int(x) for x in bytearray.fromhex(thash)]
        if net.SYMBOL.lower() in ['bch', 'tbch', 'bsv', 'tbsv']:
            return cash_addr.encode(net.HUMAN_READABLE_PART, bech32_ver, data)
        else:
            return segwit_addr.encode(net.HUMAN_READABLE_PART, bech32_ver, data)
    return base58_encode(human_address_type.pack(dict(version=addr_ver, pubkey_hash=pubkey_hash)))