Skip to content

Commit 6b720fd

Browse files
committed
Prefix BLIP-51/LSPS1 message types to avoid naming collisions
1 parent f9c477f commit 6b720fd

File tree

4 files changed

+111
-101
lines changed

4 files changed

+111
-101
lines changed

lightning-liquidity/src/lsps1/client.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
1212
use super::event::LSPS1ClientEvent;
1313
use super::msgs::{
14-
CreateOrderRequest, CreateOrderResponse, GetInfoRequest, GetInfoResponse, GetOrderRequest,
15-
LSPS1Message, LSPS1Request, LSPS1Response, OrderId, OrderParameters,
14+
LSPS1CreateOrderRequest, LSPS1CreateOrderResponse, LSPS1GetInfoRequest, LSPS1GetInfoResponse,
15+
LSPS1GetOrderRequest, LSPS1Message, LSPS1OrderId, LSPS1OrderParams, LSPS1Request,
16+
LSPS1Response,
1617
};
1718
use crate::message_queue::MessageQueue;
1819

@@ -94,14 +95,15 @@ where
9495
peer_state_lock.pending_get_info_requests.insert(request_id.clone());
9596
}
9697

97-
let request = LSPS1Request::GetInfo(GetInfoRequest {});
98+
let request = LSPS1Request::GetInfo(LSPS1GetInfoRequest {});
9899
let msg = LSPS1Message::Request(request_id.clone(), request).into();
99100
self.pending_messages.enqueue(&counterparty_node_id, msg);
100101
request_id
101102
}
102103

103104
fn handle_get_info_response(
104-
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: GetInfoResponse,
105+
&self, request_id: RequestId, counterparty_node_id: &PublicKey,
106+
result: LSPS1GetInfoResponse,
105107
) -> Result<(), LightningError> {
106108
let outer_state_lock = self.per_peer_state.write().unwrap();
107109

@@ -184,7 +186,7 @@ where
184186
///
185187
/// The client agrees to paying channel fees according to the provided parameters.
186188
pub fn create_order(
187-
&self, counterparty_node_id: &PublicKey, order: OrderParameters,
189+
&self, counterparty_node_id: &PublicKey, order: LSPS1OrderParams,
188190
refund_onchain_address: Option<Address>,
189191
) -> RequestId {
190192
let (request_id, request_msg) = {
@@ -195,8 +197,10 @@ where
195197
let mut peer_state_lock = inner_state_lock.lock().unwrap();
196198

197199
let request_id = crate::utils::generate_request_id(&self.entropy_source);
198-
let request =
199-
LSPS1Request::CreateOrder(CreateOrderRequest { order, refund_onchain_address });
200+
let request = LSPS1Request::CreateOrder(LSPS1CreateOrderRequest {
201+
order,
202+
refund_onchain_address,
203+
});
200204
let msg = LSPS1Message::Request(request_id.clone(), request).into();
201205
peer_state_lock.pending_create_order_requests.insert(request_id.clone());
202206

@@ -212,7 +216,7 @@ where
212216

213217
fn handle_create_order_response(
214218
&self, request_id: RequestId, counterparty_node_id: &PublicKey,
215-
response: CreateOrderResponse,
219+
response: LSPS1CreateOrderResponse,
216220
) -> Result<(), LightningError> {
217221
let outer_state_lock = self.per_peer_state.read().unwrap();
218222
match outer_state_lock.get(counterparty_node_id) {
@@ -302,7 +306,7 @@ where
302306
///
303307
/// [`LSPS1ClientEvent::OrderStatus`]: crate::lsps1::event::LSPS1ClientEvent::OrderStatus
304308
pub fn check_order_status(
305-
&self, counterparty_node_id: &PublicKey, order_id: OrderId,
309+
&self, counterparty_node_id: &PublicKey, order_id: LSPS1OrderId,
306310
) -> RequestId {
307311
let (request_id, request_msg) = {
308312
let mut outer_state_lock = self.per_peer_state.write().unwrap();
@@ -314,7 +318,8 @@ where
314318
let request_id = crate::utils::generate_request_id(&self.entropy_source);
315319
peer_state_lock.pending_get_order_requests.insert(request_id.clone());
316320

317-
let request = LSPS1Request::GetOrder(GetOrderRequest { order_id: order_id.clone() });
321+
let request =
322+
LSPS1Request::GetOrder(LSPS1GetOrderRequest { order_id: order_id.clone() });
318323
let msg = LSPS1Message::Request(request_id.clone(), request).into();
319324

320325
(request_id, Some(msg))
@@ -329,7 +334,7 @@ where
329334

330335
fn handle_get_order_response(
331336
&self, request_id: RequestId, counterparty_node_id: &PublicKey,
332-
response: CreateOrderResponse,
337+
response: LSPS1CreateOrderResponse,
333338
) -> Result<(), LightningError> {
334339
let outer_state_lock = self.per_peer_state.read().unwrap();
335340
match outer_state_lock.get(counterparty_node_id) {

lightning-liquidity/src/lsps1/event.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
//! Contains bLIP-51 / LSPS1 event types
1111
12-
use super::msgs::OrderId;
13-
use super::msgs::{ChannelInfo, LSPS1Options, OrderParameters, PaymentInfo};
12+
use super::msgs::LSPS1OrderId;
13+
use super::msgs::{LSPS1ChannelInfo, LSPS1Options, LSPS1OrderParams, LSPS1PaymentInfo};
1414

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

@@ -78,13 +78,13 @@ pub enum LSPS1ClientEvent {
7878
/// The node id of the LSP.
7979
counterparty_node_id: PublicKey,
8080
/// The id of the channel order.
81-
order_id: OrderId,
81+
order_id: LSPS1OrderId,
8282
/// The order created by client and approved by LSP.
83-
order: OrderParameters,
83+
order: LSPS1OrderParams,
8484
/// The details regarding payment of the order
85-
payment: PaymentInfo,
85+
payment: LSPS1PaymentInfo,
8686
/// The details regarding state of the channel ordered.
87-
channel: Option<ChannelInfo>,
87+
channel: Option<LSPS1ChannelInfo>,
8888
},
8989
/// Information from the LSP about the status of a previously created order.
9090
///
@@ -102,13 +102,13 @@ pub enum LSPS1ClientEvent {
102102
/// The node id of the LSP.
103103
counterparty_node_id: PublicKey,
104104
/// The id of the channel order.
105-
order_id: OrderId,
105+
order_id: LSPS1OrderId,
106106
/// The order created by client and approved by LSP.
107-
order: OrderParameters,
107+
order: LSPS1OrderParams,
108108
/// The details regarding payment of the order
109-
payment: PaymentInfo,
109+
payment: LSPS1PaymentInfo,
110110
/// The details regarding state of the channel ordered.
111-
channel: Option<ChannelInfo>,
111+
channel: Option<LSPS1ChannelInfo>,
112112
},
113113
/// A request previously issued via [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`].
114114
/// failed as the LSP returned an error response.
@@ -151,7 +151,7 @@ pub enum LSPS1ServiceEvent {
151151
/// The node id of the client making the information request.
152152
counterparty_node_id: PublicKey,
153153
/// The order requested by the client.
154-
order: OrderParameters,
154+
order: LSPS1OrderParams,
155155
},
156156
/// A request from client to check the status of the payment.
157157
///
@@ -169,7 +169,7 @@ pub enum LSPS1ServiceEvent {
169169
/// The node id of the client making the information request.
170170
counterparty_node_id: PublicKey,
171171
/// The order id of order with pending payment.
172-
order_id: OrderId,
172+
order_id: LSPS1OrderId,
173173
},
174174
/// If error is encountered, refund the amount if paid by the client.
175175
Refund {
@@ -178,6 +178,6 @@ pub enum LSPS1ServiceEvent {
178178
/// The node id of the client making the information request.
179179
counterparty_node_id: PublicKey,
180180
/// The order id of the refunded order.
181-
order_id: OrderId,
181+
order_id: LSPS1OrderId,
182182
},
183183
}

0 commit comments

Comments
 (0)