def to_b58_address(hex_address: str) -> str: try: bytes_address = bytes.fromhex(hex_address) except ValueError as e: raise SDKException(ErrorCode.other_error(e.args[0])) address = Address(bytes_address) return address.b58encode()
def test_b58decode(self): length = 20 rand_code = utils.get_random_bytes(length) address = Address(rand_code) b58_address = address.b58encode() zero = Address.b58decode(b58_address).to_bytes() self.assertEqual(rand_code, zero) decode_address = Address.b58decode(b58_address).to_bytes() self.assertEqual(rand_code, decode_address)