コード例 #1
0
    def test_verify_challenge_tx_contains_infinite_timebounds(self):
        server_kp = Keypair.random()
        client_kp = Keypair.random()
        timeout = 600
        network = 'TESTNET'
        archor_name = 'sdf'

        challenge = Builder(server_kp.seed().decode(),
                            network=network,
                            sequence=-1,
                            fee=100)
        now = int(time.time())
        challenge.add_time_bounds({'minTime': now, 'maxTime': 0})
        nonce = os.urandom(64)
        challenge.append_manage_data_op(
            data_name='{} auth'.format(archor_name),
            data_value=nonce,
            source=client_kp.address().decode())
        challenge.sign()
        challenge_tx_server_signed = challenge.gen_xdr()

        transaction = Builder(client_kp.seed().decode(),
                              network='TESTNET',
                              sequence=0,
                              fee=100)
        transaction.import_from_xdr(challenge_tx_server_signed)
        transaction.sign()
        challenge_tx = transaction.gen_xdr()
        with pytest.raises(
                InvalidSep10ChallengeError,
                match="Transaction requires non-infinite timebounds."):
            Builder.verify_challenge_tx(challenge_tx,
                                        server_kp.address().decode(),
                                        'TESTNET')
コード例 #2
0
    def test_verify_challenge_tx_donot_contain_managedata_operation(self):
        server_kp = Keypair.random()
        client_kp = Keypair.random()
        timeout = 600
        network = 'TESTNET'

        challenge = Builder(server_kp.seed().decode(),
                            network=network,
                            sequence=-1,
                            fee=100)
        now = int(time.time())
        challenge.add_time_bounds({'minTime': now, 'maxTime': now + timeout})
        challenge.append_bump_sequence_op(12,
                                          source=client_kp.address().decode())
        challenge.sign()
        challenge_tx_server_signed = challenge.gen_xdr()

        transaction = Builder(client_kp.seed().decode(),
                              network='TESTNET',
                              sequence=0,
                              fee=100)

        transaction.import_from_xdr(challenge_tx_server_signed)
        transaction.sign()
        challenge_tx = transaction.gen_xdr()
        with pytest.raises(InvalidSep10ChallengeError,
                           match="Operation type should be ManageData."):
            Builder.verify_challenge_tx(challenge_tx,
                                        server_kp.address().decode(),
                                        'TESTNET')
コード例 #3
0
    def call(self):
        keypair = self.keypair()

        builder = Builder(address=keypair.address().decode(),
                          sequence=self.random_sequence(),
                          secret=keypair.seed())

        builder.sign()

        builder.add_memo(self.memo())
        builder.add_time_bounds(self.build_time_bounds())

        builder.append_payment_op(source=Keypair.random(),
                                  destination=keypair.address().decode(),
                                  amount='0.000001')
        builder.sign()

        te = builder.gen_te()

        return te.xdr()
コード例 #4
0
    def test_verify_challenge_tx_operation_value_is_not_a_64_bytes_base64_string(
            self):
        server_kp = Keypair.random()
        client_kp = Keypair.random()
        timeout = 600
        network = 'TESTNET'
        archor_name = 'sdf'

        challenge = Builder(server_kp.seed().decode(),
                            network=network,
                            sequence=-1,
                            fee=100)
        now = int(time.time())
        challenge.add_time_bounds({'minTime': now, 'maxTime': now + timeout})
        nonce = os.urandom(32)
        challenge.append_manage_data_op(
            data_name='{} auth'.format(archor_name),
            data_value=nonce,
            source=client_kp.address().decode())
        challenge.sign()
        challenge_tx_server_signed = challenge.gen_xdr()

        transaction = Builder(client_kp.seed().decode(),
                              network='TESTNET',
                              sequence=0,
                              fee=100)

        transaction.import_from_xdr(challenge_tx_server_signed)
        transaction.sign()
        challenge_tx = transaction.gen_xdr()
        with pytest.raises(
                InvalidSep10ChallengeError,
                match=
                "Operation value should be a 64 bytes base64 random string."):
            Builder.verify_challenge_tx(challenge_tx,
                                        server_kp.address().decode(),
                                        'TESTNET')
コード例 #5
0
tau = datetime.datetime.now() + datetime.timedelta(seconds=30)
tau_unix = int(time.mktime(tau.timetuple()))
tau_plus_delta = tau + datetime.timedelta(seconds=DELTA)
tau_plus_delta_unix = int(time.mktime(tau_plus_delta.timetuple()))
tx_timebound = TimeBounds(
    minTime=tau_unix, maxTime=tau_plus_delta_unix)
counter_tx_timebound = TimeBounds(minTime=0, maxTime=tau_unix)

builder_t_1_1 = Builder(secret=kp_a_1_seed,
                        sequence=starting_sequence_a_1+1)
builder_t_1_1.append_payment_op(
    kp_alice.address().decode(), PRIZE, 'XLM')
builder_t_1_1.append_payment_op(
    kp_carol.address().decode(), PAWN, 'XLM')
builder_t_1_1.add_time_bounds(tx_timebound)
t_1_1 = builder_t_1_1.gen_tx()
hash_t_1_1 = builder_t_1_1.gen_te().hash_meta()

builder_t_1_2 = Builder(secret=kp_a_1_seed,
                        sequence=starting_sequence_a_1+1)
builder_t_1_2.append_payment_op(
    kp_bob.address().decode(), COUNTERPRIZE, 'XLM')
builder_t_1_2.add_time_bounds(counter_tx_timebound)
t_1_2 = builder_t_1_2.gen_tx()
hash_t_1_2 = builder_t_1_2.gen_te().hash_meta()

builder_t_2_2 = Builder(secret=kp_a_2_seed,
                        sequence=starting_sequence_a_2+1)
builder_t_2_2.append_payment_op(
    kp_bob.address().decode(), PRIZE, 'XLM')