Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Restructure crate #48

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
//! [`LiquidityManager::get_and_clear_pending_events`] to receive events.
//!
//! [`LiquidityManager::get_and_clear_pending_events`]: crate::LiquidityManager::get_and_clear_pending_events
use crate::jit_channel;
/// [`crate::LiquidityManager::get_and_clear_pending_events()`] to receive events.

#[cfg(lsps1)]
use crate::lsps1;
use crate::lsps2;
use std::collections::VecDeque;
use std::sync::{Condvar, Mutex};

Expand Down Expand Up @@ -62,7 +62,7 @@ impl EventQueue {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Event {
/// An LSPS2 (JIT Channel) protocol event.
LSPS2(jit_channel::LSPS2Event),
LSPS2(lsps2::LSPS2Event),
/// An LSPS1 protocol event.
#[cfg(lsps1)]
LSPS1(lsps1::event::Event),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub mod events;
pub mod jit_channel;
mod lsps0;
#[cfg(lsps1)]
mod lsps1;
pub mod lsps2;
mod utils;

pub use lsps0::message_handler::{JITChannelsConfig, LiquidityManager, LiquidityProviderConfig};
22 changes: 11 additions & 11 deletions src/lsps0/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use {
};

use crate::events::{Event, EventQueue};
use crate::jit_channel::channel_manager::JITChannelManager;
use crate::jit_channel::msgs::{OpeningFeeParams, RawOpeningFeeParams};
use crate::lsps0::msgs::RequestId;
use crate::lsps0::msgs::{LSPSMessage, RawLSPSMessage, LSPS_MESSAGE_TYPE_ID};
use crate::lsps0::protocol::LSPS0MessageHandler;
use crate::lsps2::channel_manager::JITChannelManager;
use crate::lsps2::msgs::{OpeningFeeParams, RawOpeningFeeParams};

use chrono::Utc;
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
Expand Down Expand Up @@ -64,7 +64,7 @@ pub struct LiquidityProviderConfig {
pub lsps1_config: Option<CRChannelConfig>,
/// Optional configuration for JIT channels
/// should you want to support them.
pub jit_channels: Option<JITChannelsConfig>,
pub lsps2_config: Option<JITChannelsConfig>,
}

/// Configuration options for JIT channels.
Expand Down Expand Up @@ -202,10 +202,10 @@ where {
);

let lsps2_message_handler = provider_config.as_ref().and_then(|config| {
config.jit_channels.as_ref().map(|jit_channels_config| {
config.lsps2_config.as_ref().map(|config| {
JITChannelManager::new(
entropy_source.clone(),
jit_channels_config,
config,
Arc::clone(&pending_messages),
Arc::clone(&pending_events),
Arc::clone(&channel_manager),
Expand Down Expand Up @@ -355,7 +355,7 @@ where {
///
/// `token` is an optional String that will be provided to the LSP.
/// It can be used by the LSP as an API key, coupon code, or some other way to identify a user.
pub fn jit_channel_create_invoice(
pub fn lsps2_create_invoice(
&self, counterparty_node_id: PublicKey, payment_size_msat: Option<u64>,
token: Option<String>, user_channel_id: u128,
) -> Result<(), APIError> {
Expand All @@ -379,7 +379,7 @@ where {
///
/// Should be called in response to receiving a [`LSPS2Event::GetInfo`] event.
///
/// [`LSPS2Event::GetInfo`]: crate::jit_channel::LSPS2Event::GetInfo
/// [`LSPS2Event::GetInfo`]: crate::lsps2::LSPS2Event::GetInfo
pub fn invalid_token_provided(
&self, counterparty_node_id: PublicKey, request_id: RequestId,
) -> Result<(), APIError> {
Expand All @@ -397,7 +397,7 @@ where {
///
/// Should be called in response to receiving a [`LSPS2Event::GetInfo`] event.
///
/// [`LSPS2Event::GetInfo`]: crate::jit_channel::LSPS2Event::GetInfo
/// [`LSPS2Event::GetInfo`]: crate::lsps2::LSPS2Event::GetInfo
pub fn opening_fee_params_generated(
&self, counterparty_node_id: PublicKey, request_id: RequestId,
opening_fee_params_menu: Vec<RawOpeningFeeParams>,
Expand All @@ -422,7 +422,7 @@ where {
///
/// Should be called in response to receiving a [`LSPS2Event::GetInfoResponse`] event.
///
/// [`LSPS2Event::GetInfoResponse`]: crate::jit_channel::LSPS2Event::GetInfoResponse
/// [`LSPS2Event::GetInfoResponse`]: crate::lsps2::LSPS2Event::GetInfoResponse
pub fn opening_fee_params_selected(
&self, counterparty_node_id: PublicKey, channel_id: u128,
opening_fee_params: OpeningFeeParams,
Expand All @@ -445,7 +445,7 @@ where {
///
/// Should be called in response to receiving a [`LSPS2Event::BuyRequest`] event.
///
/// [`LSPS2Event::BuyRequest`]: crate::jit_channel::LSPS2Event::BuyRequest
/// [`LSPS2Event::BuyRequest`]: crate::lsps2::LSPS2Event::BuyRequest
pub fn invoice_parameters_generated(
&self, counterparty_node_id: PublicKey, request_id: RequestId, scid: u64,
cltv_expiry_delta: u32, client_trusts_lsp: bool,
Expand Down Expand Up @@ -477,7 +477,7 @@ where {
/// Will do nothing if the scid does not match any of the ones we gave out.
///
/// [`Event::HTLCIntercepted`]: lightning::events::Event::HTLCIntercepted
/// [`LSPS2Event::OpenChannel`]: crate::jit_channel::LSPS2Event::OpenChannel
/// [`LSPS2Event::OpenChannel`]: crate::lsps2::LSPS2Event::OpenChannel
pub fn htlc_intercepted(
&self, scid: u64, intercept_id: InterceptId, expected_outbound_amount_msat: u64,
) -> Result<(), APIError> {
Expand Down
8 changes: 4 additions & 4 deletions src/lsps0/msgs.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::jit_channel::msgs::{
LSPS2Message, LSPS2Request, LSPS2Response, LSPS2_BUY_METHOD_NAME, LSPS2_GET_INFO_METHOD_NAME,
LSPS2_GET_VERSIONS_METHOD_NAME,
};
#[cfg(lsps1)]
use crate::lsps1::msgs::{
LSPS1Message, LSPS1Request, LSPS1Response, LSPS1_CREATE_ORDER_METHOD_NAME,
LSPS1_GET_INFO_METHOD_NAME, LSPS1_GET_ORDER_METHOD_NAME,
};
use crate::lsps2::msgs::{
LSPS2Message, LSPS2Request, LSPS2Response, LSPS2_BUY_METHOD_NAME, LSPS2_GET_INFO_METHOD_NAME,
LSPS2_GET_VERSIONS_METHOD_NAME,
};
use lightning::impl_writeable_msg;
use lightning::ln::wire;
use serde::de;
Expand Down
Loading