def test_base58_encode(): assert base58_encode(bytearray([0])) == b"1" assert base58_encode(bytearray([1])) == b"2" assert base58_encode(bytearray([58])) == b"21" assert base58_encode(bytearray([13, 36])) == b"211" assert base58_encode(bytearray([0, 13, 36])) == b"1211" assert base58_encode(bytearray([0, 0, 0, 0, 13, 36])) == b"1111211" assert base58check_encode(bytearray(unhexlify(b"00f8917303bfa8ef24f292e8fa1419b20460ba064d"))) \ == b"1PfJpZsjreyVrqeoAfabrRwwjQyoSQMmHH"
def to_base58check(self) -> bytes: return base58check_encode(self.to_bytearray())
def test_base58_roundtrip(): s = b"xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs" v = base58check_decode(s) assert base58check_encode(v) == s assert base58check_decode(base58check_encode(v)) == v
def to_base58check(self, secp: Secp256k1) -> bytes: return base58check_encode(self.to_bytearray(secp))