Ejemplo n.º 1
0
def create_channel_state(funding_txid, funding_index, funding_sat, is_initiator,
                         local_amount, remote_amount, privkeys, other_pubkeys,
                         seed, cur, nex, other_node_id, l_dust, r_dust, l_csv,
                         r_csv):
    assert local_amount > 0
    assert remote_amount > 0
    channel_id, _ = lnpeer.channel_id_from_funding_tx(funding_txid, funding_index)
    state = {
            "channel_id":channel_id.hex(),
            "short_channel_id":channel_id[:8],
            "funding_outpoint":lnpeer.Outpoint(funding_txid, funding_index),
            "remote_config":lnpeer.RemoteConfig(
                payment_basepoint=other_pubkeys[0],
                multisig_key=other_pubkeys[1],
                htlc_basepoint=other_pubkeys[2],
                delayed_basepoint=other_pubkeys[3],
                revocation_basepoint=other_pubkeys[4],
                to_self_delay=r_csv,
                dust_limit_sat=r_dust,
                max_htlc_value_in_flight_msat=one_bitcoin_in_msat * 5,
                max_accepted_htlcs=5,
                initial_msat=remote_amount,
                reserve_sat=0,
                htlc_minimum_msat=1,
                next_per_commitment_point=nex,
                current_per_commitment_point=cur,
                upfront_shutdown_script=b'',
            ),
            "local_config":lnpeer.LocalConfig(
                channel_seed = None,
                payment_basepoint=privkeys[0],
                multisig_key=privkeys[1],
                htlc_basepoint=privkeys[2],
                delayed_basepoint=privkeys[3],
                revocation_basepoint=privkeys[4],
                to_self_delay=l_csv,
                dust_limit_sat=l_dust,
                max_htlc_value_in_flight_msat=one_bitcoin_in_msat * 5,
                max_accepted_htlcs=5,
                initial_msat=local_amount,
                reserve_sat=0,
                per_commitment_secret_seed=seed,
                funding_locked_received=True,
                was_announced=False,
                current_commitment_signature=None,
                current_htlc_signatures=None,
                htlc_minimum_msat=1,
                upfront_shutdown_script=b'',
            ),
            "constraints":lnpeer.ChannelConstraints(
                capacity=funding_sat,
                is_initiator=is_initiator,
                funding_txn_minimum_depth=3,
            ),
            "node_id":other_node_id.hex(),
            'onion_keys': {},
            'data_loss_protect_remote_pcp': {},
            'state': 'PREOPENING',
            'log': {},
            'fail_htlc_reasons': {},
            'unfulfilled_htlcs': {},
            'revocation_store': {},
            'channel_type': lnutil.ChannelType.OPTION_STATIC_REMOTEKEY
    }
    return StoredDict(state, None, [])
Ejemplo n.º 2
0
def create_channel_state(funding_txid, funding_index, funding_sat,
                         is_initiator, local_amount, remote_amount, privkeys,
                         other_pubkeys, seed, cur, nex, other_node_id, l_dust,
                         r_dust, l_csv, r_csv):
    assert local_amount > 0
    assert remote_amount > 0
    channel_id, _ = lnpeer.channel_id_from_funding_tx(funding_txid,
                                                      funding_index)
    their_revocation_store = lnpeer.RevocationStore()

    return {
        "channel_id":
        channel_id,
        "short_channel_id":
        channel_id[:8],
        "funding_outpoint":
        lnpeer.Outpoint(funding_txid, funding_index),
        "remote_config":
        lnpeer.RemoteConfig(
            payment_basepoint=other_pubkeys[0],
            multisig_key=other_pubkeys[1],
            htlc_basepoint=other_pubkeys[2],
            delayed_basepoint=other_pubkeys[3],
            revocation_basepoint=other_pubkeys[4],
            to_self_delay=r_csv,
            dust_limit_sat=r_dust,
            max_htlc_value_in_flight_msat=one_bitcoin_in_msat * 5,
            max_accepted_htlcs=5,
            initial_msat=remote_amount,
            reserve_sat=0,
            htlc_minimum_msat=1,
            next_per_commitment_point=nex,
            current_per_commitment_point=cur,
            revocation_store=their_revocation_store,
        ),
        "local_config":
        lnpeer.LocalConfig(
            payment_basepoint=privkeys[0],
            multisig_key=privkeys[1],
            htlc_basepoint=privkeys[2],
            delayed_basepoint=privkeys[3],
            revocation_basepoint=privkeys[4],
            to_self_delay=l_csv,
            dust_limit_sat=l_dust,
            max_htlc_value_in_flight_msat=one_bitcoin_in_msat * 5,
            max_accepted_htlcs=5,
            initial_msat=local_amount,
            reserve_sat=0,
            per_commitment_secret_seed=seed,
            funding_locked_received=True,
            was_announced=False,
            current_commitment_signature=None,
            current_htlc_signatures=None,
        ),
        "constraints":
        lnpeer.ChannelConstraints(
            capacity=funding_sat,
            is_initiator=is_initiator,
            funding_txn_minimum_depth=3,
        ),
        "node_id":
        other_node_id,
        'onion_keys': {},
    }