示例#1
0
def _channel_and_transfer(num_pending_locks):
    our_model, _ = create_model(700)
    partner_model, privkey = create_model(700, num_pending_locks)
    reverse_channel_state = create_channel_from_models(partner_model,
                                                       our_model, privkey)

    lock_secret = sha3(b"some secret seed")
    lock = HashTimeLockState(30, 10, sha256(lock_secret).digest())

    mediated_transfer = make_receive_transfer_mediated(
        reverse_channel_state,
        privkey,
        nonce=partner_model.next_nonce,
        transferred_amount=0,
        lock=lock,
        pending_locks=PendingLocksState(partner_model.pending_locks +
                                        [bytes(lock.encoded)]),
        locked_amount=lock.amount,
    )

    channel_state = deepcopy(reverse_channel_state)
    channel_state.our_state = reverse_channel_state.partner_state
    channel_state.partner_state = reverse_channel_state.our_state

    return channel_state, mediated_transfer
示例#2
0
def _channel_and_transfer(merkletree_width):

    our_model, _ = create_model(700)
    partner_model, privkey = create_model(700, merkletree_width)
    reverse_channel_state = create_channel_from_models(partner_model,
                                                       our_model)

    lock_secret = sha3(b"some secret")
    lock = HashTimeLockState(30, 10, sha3(lock_secret))

    mediated_transfer = make_receive_transfer_mediated(
        reverse_channel_state,
        privkey,
        nonce=1,
        transferred_amount=0,
        lock=lock,
        merkletree_leaves=partner_model.merkletree_leaves + [lock.lockhash],
        locked_amount=lock.amount,
    )

    channel_state = deepcopy(reverse_channel_state)
    channel_state.our_state = reverse_channel_state.partner_state
    channel_state.partner_state = reverse_channel_state.our_state

    return channel_state, mediated_transfer
示例#3
0
def _channel_and_transfer(merkletree_width):

    our_model, _ = create_model(700)
    partner_model, privkey = create_model(700, merkletree_width)
    reverse_channel_state = create_channel_from_models(partner_model, our_model)

    lock_secret = sha3(b'some secret')
    lock = HashTimeLockState(30, 10, sha3(lock_secret))

    mediated_transfer = make_receive_transfer_mediated(
        reverse_channel_state,
        privkey,
        nonce=1,
        transferred_amount=0,
        lock=lock,
        merkletree_leaves=partner_model.merkletree_leaves + [lock.lockhash],
        locked_amount=lock.amount,
    )

    channel_state = deepcopy(reverse_channel_state)
    channel_state.our_state = reverse_channel_state.partner_state
    channel_state.partner_state = reverse_channel_state.our_state

    return channel_state, mediated_transfer