예제 #1
0
def channel_monitor_data(in_mem_chan_keys, holder_commitment_tx):
    shutdown_pk = PublicKey(get_random_pk_bytes())
    on_counterparty_tx_csv = 20
    destination_script = Script(get_random_bytes((40)))
    funding_info = (OutPoint.from_bytes(get_random_bytes(34)), Script(get_random_bytes(50)))
    counterparty_htlc_base_key = PublicKey(get_random_pk_bytes())
    counterparty_delayed_payment_base_key = PublicKey(get_random_pk_bytes())
    on_holder_tx_csv = 30
    funding_redeemscript = Script(get_random_bytes(40))
    channel_value_satoshis = 42
    commitment_transaction_number_obscure_factor = 10

    return {
        "in_mem_chan_keys": in_mem_chan_keys,
        "shutdown_pk": shutdown_pk,
        "on_counterparty_tx_csv": on_counterparty_tx_csv,
        "destination_script": destination_script,
        "funding_info": funding_info,
        "counterparty_htlc_base_key": counterparty_htlc_base_key,
        "counterparty_delayed_payment_base_key": counterparty_delayed_payment_base_key,
        "on_holder_tx_csv": on_holder_tx_csv,
        "funding_redeemscript": funding_redeemscript,
        "channel_value_satoshis": channel_value_satoshis,
        "commitment_transaction_number_obscure_factor": commitment_transaction_number_obscure_factor,
        "holder_commitment_tx": holder_commitment_tx,
    }
예제 #2
0
def test_static_output():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    descriptor = SpendableOutputDescriptor.static_output(outpoint, txout)

    assert isinstance(
        descriptor,
        SpendableOutputDescriptor) and descriptor.type == "StaticOutput"
예제 #3
0
def test_update_channel_unknown_channel(chain_monitor,
                                        channel_monitor_update_data):
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    update = ChannelMonitorUpdate.from_bytes(channel_monitor_update_data)

    # Update without having watched the channel
    with pytest.raises(PermanentChannelMonitorUpdateErr):
        chain_monitor.update_channel(outpoint, update)
예제 #4
0
def test_commitment_tx_broadcasted_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    event = MonitorEvent.commitment_tx_broadcasted(outpoint)

    assert event.type == "CommitmentTxBroadcasted"
    assert event.outpoint == outpoint

    # Check no other getters are available
    check_not_available_getters(event, ["outpoint"], all_attributes)
예제 #5
0
def test_static_output_counterparty_payment():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    key_derivation_params = (get_random_int(8), get_random_int(8))
    descriptor = SpendableOutputDescriptor.static_output_counterparty_payment(
        outpoint, txout, key_derivation_params)

    assert isinstance(
        descriptor, SpendableOutputDescriptor
    ) and descriptor.type == "StaticOutputCounterpartyPayment"
예제 #6
0
def test_update_channel(chain_monitor, channel_monitor,
                        channel_monitor_update_data):
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    update = ChannelMonitorUpdate.from_bytes(channel_monitor_update_data)

    # First watch the channel
    chain_monitor.watch_channel(outpoint, channel_monitor)

    # Then update
    chain_monitor.update_channel(outpoint, update)
예제 #7
0
def test_spendable_outputs_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    output = TxOut(get_random_int(8), Script(get_random_bytes(50)))
    descriptor = SpendableOutputDescriptor.static_output(outpoint, output)
    event = Event.spendable_outputs([descriptor])

    for local_output, binded_output in zip(event.outputs, [descriptor]):
        assert local_output.type == binded_output.type
        assert local_output.outpoint == binded_output.outpoint
        assert local_output.output == binded_output.output
예제 #8
0
def test_funding_broadcasting_safe_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    user_channel_id = get_random_int(8)
    event = Event.funding_broadcasting_safe(outpoint, user_channel_id)

    assert event.funding_txo == outpoint
    assert event.user_channel_id == user_channel_id

    # Check no other getters are available
    local_attributes = ["funding_txo", "user_channel_id"]
    check_not_available_getters(event, local_attributes, all_attributes)
예제 #9
0
def test_static_output_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    descriptor = SpendableOutputDescriptor.static_output(outpoint, txout)

    assert descriptor.outpoint == outpoint
    assert descriptor.output == txout

    # Check no other getters are available
    local_attributes = ["outpoint", "output"]

    check_not_available_getters(descriptor, local_attributes, all_attributes)
예제 #10
0
def test_dynamic_output_pwsh():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    per_commitment_point = PublicKey(get_random_pk_bytes())
    to_self_delay = 20
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    key_derivation_params = (get_random_int(8), get_random_int(8))
    revocation_pubkey = PublicKey(get_random_pk_bytes())
    descriptor = SpendableOutputDescriptor.dynamic_output_pwsh(
        outpoint, per_commitment_point, to_self_delay, txout,
        key_derivation_params, revocation_pubkey)

    assert isinstance(
        descriptor,
        SpendableOutputDescriptor) and descriptor.type == "DynamicOutputP2WSH"
예제 #11
0
def test_static_output_counterparty_payment_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    key_derivation_params = (get_random_int(8), get_random_int(8))
    descriptor = SpendableOutputDescriptor.static_output_counterparty_payment(
        outpoint, txout, key_derivation_params)

    assert descriptor.outpoint == outpoint
    assert descriptor.output == txout
    assert descriptor.key_derivation_params == key_derivation_params

    # Check no other getters are available
    local_attributes = ["outpoint", "output", "key_derivation_params"]

    check_not_available_getters(descriptor, local_attributes, all_attributes)
예제 #12
0
def test_dynamic_output_pwsh_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    per_commitment_point = PublicKey(get_random_pk_bytes())
    to_self_delay = 20
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    key_derivation_params = (get_random_int(8), get_random_int(8))
    revocation_pubkey = PublicKey(get_random_pk_bytes())
    descriptor = SpendableOutputDescriptor.dynamic_output_pwsh(
        outpoint, per_commitment_point, to_self_delay, txout,
        key_derivation_params, revocation_pubkey)

    assert descriptor.outpoint == outpoint
    assert descriptor.per_commitment_point == per_commitment_point
    assert descriptor.to_self_delay == to_self_delay
    assert descriptor.output == txout
    assert descriptor.key_derivation_params == key_derivation_params
    assert descriptor.revocation_pubkey == revocation_pubkey
예제 #13
0
def test_persist_new_channel(channel_monitor):
    persister = Persist(Persister())
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    persister.persist_new_channel(outpoint, channel_monitor)
예제 #14
0
def test_commitment_tx_broadcasted():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    assert isinstance(MonitorEvent.commitment_tx_broadcasted(outpoint), MonitorEvent)
예제 #15
0
def test_register_output():
    f = Filter(F())
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    script = Script(get_random_bytes(50))
    f.register_output(outpoint, script)
예제 #16
0
def test_watch_channel(chain_monitor, channel_monitor):
    outpoint = OutPoint.from_bytes(get_random_bytes(34))

    chain_monitor.watch_channel(outpoint, channel_monitor)
예제 #17
0
def test_update_channel(channel_monitor_update_data):
    watcher = Watch(W())
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    update = ChannelMonitorUpdate.from_bytes(channel_monitor_update_data)

    watcher.update_channel(outpoint, update)
예제 #18
0
def test_watch_channel(channel_monitor):
    watcher = Watch(W())
    outpoint = OutPoint.from_bytes(get_random_bytes(34))

    watcher.watch_channel(outpoint, channel_monitor)
예제 #19
0
def test_update_persisted_channel(channel_monitor, channel_monitor_update_data):
    persister = Persist(Persister())
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    update = ChannelMonitorUpdate.from_bytes(channel_monitor_update_data)
    persister.update_persisted_channel(outpoint, update, channel_monitor)
예제 #20
0
def test_funding_broadcasting_safe():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    user_channel_id = get_random_int(8)
    event = Event.funding_broadcasting_safe(outpoint, user_channel_id)
    assert isinstance(event, Event) and event.type == "FundingBroadcastSafe"
예제 #21
0
def test_spendable_outputs():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    output = TxOut(get_random_int(8), Script(get_random_bytes(50)))
    descriptor = SpendableOutputDescriptor.static_output(outpoint, output)
    event = Event.spendable_outputs([descriptor])
    assert isinstance(event, Event) and event.type == "SpendableOutputs"