def pub(self): setup_btcpy('mainnet') sppk = b'\x03\xfe\xe2V' return b58encode_check(sppk + self.key.key.pub().serialize())
def pkh(self): setup_btcpy('mainnet') tz2 = b'\x06\xa1\xa1' pkh = blake2b(data=self.key.key.pub().serialize(), digest_size=20).digest() return b58encode_check(tz2 + pkh)
def prv(self): setup_btcpy('mainnet') spsk = b'\x11\xa2\xe0\xc9' return b58encode_check(spsk + self.key.key.serialize())
def priv2pub(priv): setup_btcpy('mainnet') priv_hex = hexlify(b58decode_check(priv)[4:]) pk = PrivateKey.unhexlify(priv_hex) sppk = b'\x03\xfe\xe2V' return b58encode_check(sppk + pk.pub().serialize())
def b58_sig(sig): return b58encode_check(b'\rse\x13?' + unhexlify(sig))
def to_wif(self, network): decoded = bytearray([network.wif_prefix]) + self.key if self.public_compressed: decoded.append(0x01) return b58encode_check(bytes(decoded))
def test_b58encode_check(self): for hexa, encoded in b58chk: self.assertEqual(b58encode_check(unhexlify(hexa)), encoded)