Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Renames for lightning-liquidity bindings #3574

Closed
Closed
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 lightning-liquidity/src/lsps1/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use super::event::LSPS1ClientEvent;
use super::msgs::{
CreateOrderRequest, CreateOrderResponse, GetInfoRequest, GetInfoResponse, GetOrderRequest,
CreateOrderRequest, CreateOrderResponse, LSPS1GetInfoRequest, LSPS1GetInfoResponse, GetOrderRequest,
Copy link
Contributor

@tnull tnull Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have to do so, can we at least rename all LSPS1 and LSPS2 message types accordingly? I.e., please prefix everything, not just the types that might clash.

Also note to adjust all the testcases accordingly.

LSPS1Message, LSPS1Request, LSPS1Response, OrderId, OrderParameters,
};
use crate::message_queue::MessageQueue;
Expand Down Expand Up @@ -94,14 +94,14 @@ where
peer_state_lock.pending_get_info_requests.insert(request_id.clone());
}

let request = LSPS1Request::GetInfo(GetInfoRequest {});
let request = LSPS1Request::GetInfo(LSPS1GetInfoRequest {});
let msg = LSPS1Message::Request(request_id.clone(), request).into();
self.pending_messages.enqueue(&counterparty_node_id, msg);
request_id
}

fn handle_get_info_response(
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: GetInfoResponse,
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: LSPS1GetInfoResponse,
) -> Result<(), LightningError> {
let outer_state_lock = self.per_peer_state.write().unwrap();

Expand Down
6 changes: 3 additions & 3 deletions lightning-liquidity/src/lsps1/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! Contains LSPS1 event types

use super::msgs::OrderId;
use super::msgs::{ChannelInfo, LSPS1Options, OrderParameters, PaymentInfo};
use super::msgs::{LSPS1ChannelInfo, LSPS1Options, OrderParameters, PaymentInfo};

use crate::lsps0::ser::{RequestId, ResponseError};

Expand Down Expand Up @@ -84,7 +84,7 @@ pub enum LSPS1ClientEvent {
/// The details regarding payment of the order
payment: PaymentInfo,
/// The details regarding state of the channel ordered.
channel: Option<ChannelInfo>,
channel: Option<LSPS1ChannelInfo>,
},
/// Information from the LSP about the status of a previously created order.
///
Expand All @@ -108,7 +108,7 @@ pub enum LSPS1ClientEvent {
/// The details regarding payment of the order
payment: PaymentInfo,
/// The details regarding state of the channel ordered.
channel: Option<ChannelInfo>,
channel: Option<LSPS1ChannelInfo>,
},
/// A request previously issued via [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`].
/// failed as the LSP returned an error response.
Expand Down
20 changes: 10 additions & 10 deletions lightning-liquidity/src/lsps1/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct OrderId(pub String);
/// for more information.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
#[serde(default)]
pub struct GetInfoRequest {}
pub struct LSPS1GetInfoRequest {}

/// An object representing the supported protocol options.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
Expand Down Expand Up @@ -68,9 +68,9 @@ pub struct LSPS1Options {
pub max_channel_balance_sat: u64,
}

/// A response to a [`GetInfoRequest`].
/// A response to a [`LSPS1GetInfoRequest`].
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct GetInfoResponse {
pub struct LSPS1GetInfoResponse {
/// All options supported by the LSP.
#[serde(flatten)]
pub options: LSPS1Options,
Expand Down Expand Up @@ -131,7 +131,7 @@ pub struct CreateOrderResponse {
/// Contains details about how to pay for the order.
pub payment: PaymentInfo,
/// Contains information about the channel state.
pub channel: Option<ChannelInfo>,
pub channel: Option<LSPS1ChannelInfo>,
}

/// An object representing the state of an order.
Expand Down Expand Up @@ -233,7 +233,7 @@ pub struct OnchainPayment {

/// Details regarding the state of an ordered channel.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct ChannelInfo {
pub struct LSPS1ChannelInfo {
/// The datetime when the funding transaction has been published.
pub funded_at: chrono::DateTime<Utc>,
/// The outpoint of the funding transaction.
Expand All @@ -256,7 +256,7 @@ pub struct GetOrderRequest {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum LSPS1Request {
/// A request to learn about the options supported by the LSP.
GetInfo(GetInfoRequest),
GetInfo(LSPS1GetInfoRequest),
/// A request to create a channel order.
CreateOrder(CreateOrderRequest),
/// A request to query a previously created channel order.
Expand All @@ -266,9 +266,9 @@ pub enum LSPS1Request {
/// An enum that captures all the valid JSON-RPC responses in the LSPS1 protocol.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum LSPS1Response {
/// A successful response to a [`GetInfoRequest`].
GetInfo(GetInfoResponse),
/// An error response to a [`GetInfoRequest`].
/// A successful response to a [`LSPS1GetInfoRequest`].
GetInfo(LSPS1GetInfoResponse),
/// An error response to a [`LSPS1GetInfoRequest`].
GetInfoError(ResponseError),
/// A successful response to a [`CreateOrderRequest`].
CreateOrder(CreateOrderResponse),
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {
"funding_outpoint": "0301e0480b374b32851a9462db29dc19fe830a7f7d7a88b81612b9d42099c0ae:0",
"expires_at": "2012-04-23T18:25:43.511Z"
}"#;
let _channel: ChannelInfo = serde_json::from_str(json_str).unwrap();
let _channel: LSPS1ChannelInfo = serde_json::from_str(json_str).unwrap();

let json_str = r#""CANCELLED""#;
let payment_state: PaymentState = serde_json::from_str(json_str).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions lightning-liquidity/src/lsps1/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use super::event::LSPS1ServiceEvent;
use super::msgs::{
ChannelInfo, CreateOrderRequest, CreateOrderResponse, GetInfoResponse, GetOrderRequest,
LSPS1ChannelInfo, CreateOrderRequest, CreateOrderResponse, GetInfoResponse, GetOrderRequest,
LSPS1Message, LSPS1Options, LSPS1Request, LSPS1Response, OrderId, OrderParameters, OrderState,
PaymentInfo, LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
};
Expand Down Expand Up @@ -364,7 +364,7 @@ where
/// [`LSPS1ServiceEvent::CheckPaymentConfirmation`]: crate::lsps1::event::LSPS1ServiceEvent::CheckPaymentConfirmation
pub fn update_order_status(
&self, request_id: RequestId, counterparty_node_id: PublicKey, order_id: OrderId,
order_state: OrderState, channel: Option<ChannelInfo>,
order_state: OrderState, channel: Option<LSPS1ChannelInfo>,
) -> Result<(), APIError> {
let (result, response) = {
let outer_state_lock = self.per_peer_state.read().unwrap();
Expand Down