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,
    }
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"
Exemple #3
0
    def get_utxo(self, genesis_hash, short_channel_id):
        if genesis_hash == BlockHash(bytes(32)):
            raise UnknownChain()
        if short_channel_id % 2:
            raise UnknownTx()

        value = pow(2, 64) - 15
        script_pubkey = Script(get_random_bytes(80))
        return TxOut(value, script_pubkey)
Exemple #4
0
def test_funding_generation_ready():
    temporary_channel_id = get_random_bytes(32)
    channel_value_satoshis = 42
    output_script = Script(get_random_bytes(50))
    user_channel_id = get_random_int(8)
    event = Event.funding_generation_ready(temporary_channel_id,
                                           channel_value_satoshis,
                                           output_script, user_channel_id)
    assert isinstance(event, Event) and event.type == "FundingGenerationReady"
Exemple #5
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
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"
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)
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"
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)
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
Exemple #11
0
def test_funding_generation_ready_getters():
    temporary_channel_id = get_random_bytes(32)
    channel_value_satoshis = 42
    output_script = Script(get_random_bytes(50))
    user_channel_id = get_random_int(8)
    event = Event.funding_generation_ready(temporary_channel_id,
                                           channel_value_satoshis,
                                           output_script, user_channel_id)

    assert event.temporary_channel_id == temporary_channel_id
    assert event.channel_value_satoshis == channel_value_satoshis
    assert event.output_script == output_script
    assert event.user_channel_id == user_channel_id

    # Check no other getters are available
    local_attributes = [
        "temporary_channel_id", "channel_value_satoshis", "output_script",
        "user_channel_id"
    ]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemple #12
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)
Exemple #13
0
def test_register_tx():
    f = Filter(F())
    txid = TxId(get_random_bytes(32))
    script = Script(get_random_bytes(50))
    f.register_tx(txid, script)
Exemple #14
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"