def test_both(self):
        pubkey = unhexlify('dfcc77d08588601702e02de2dc603f5c5281bea23baa894ae3b3b4778e5bbe40')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)

        pubkey = unhexlify('53214e6155469c32fb882b1b1d94930d5445a78202867b7ddc6a33ad42ff4464')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)

        pubkey = unhexlify('5ed4690134e5ef79b290ea1e7a4b8f3b6b3bcf287463c18bfe36baa030e7efbd')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)
    def test_address_to_pubkey(self):
        self.assertEqual(
            public_key_from_address(
                'GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V'),
            unhexlify(
                '5d55642466b185b843152e9e219151dbc5892027ec40101a517bed5ca030c2e0'
            ))

        self.assertEqual(
            public_key_from_address(
                'GCN2K2HG53AWX2SP5UHRPMJUUHLJF2XBTGSXROTPWRGAYJCDDP63J2U6'),
            unhexlify(
                '9ba568e6eec16bea4fed0f17b134a1d692eae199a578ba6fb44c0c24431bfdb4'
            ))
Ejemplo n.º 3
0
async def _init(ctx, w: bytearray, pubkey: bytes, msg: StellarSignTx):
    network_passphrase_hash = sha256(msg.network_passphrase).digest()
    writers.write_bytes(w, network_passphrase_hash)
    writers.write_bytes(w, consts.TX_TYPE)

    address = helpers.address_from_public_key(pubkey)
    writers.write_pubkey(w, address)
    if helpers.public_key_from_address(msg.source_account) != pubkey:
        raise ProcessError("Stellar: source account does not match address_n")
    writers.write_uint32(w, msg.fee)
    writers.write_uint64(w, msg.sequence_number)

    # confirm init
    await layout.require_confirm_init(ctx, address, msg.network_passphrase)
 def test_invalid_address(self):
     with self.assertRaises(ProcessError):
         public_key_from_address(
             'GCN2K2HG53AWX2SP5UHRPMJUUHLJF2XBTGSXROTPWRGAYJCDDP63J2AA'
         )  # invalid checksum