def DecodeBase58Check(psz): """Decodes a Base58-encoded string and verifies its checksum.""" vchRet = b58decode(psz, None) key = vchRet[0:-4] csum = vchRet[-4:] hash = base58_hash(key) cs32 = hash[0:4] if cs32 != csum: return None else: return key
def EncodeBase58Check(vchIn): """Encodes a string of bytes in Base58 encoding with a checksum.""" hash = base58_hash(vchIn) return b58encode(vchIn + hash[0:4])
def hash_160_to_bc_address(h160, addrtype = 0): vh160 = chr(addrtype) + h160 h = base58_hash(vh160) addr = vh160 + h[0:4] return b58encode(addr)
def hash_160_to_bc_address(h160, addrtype=0): vh160 = chr(addrtype) + h160 h = base58_hash(vh160) addr = vh160 + h[0:4] return b58encode(addr)