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

Commit 122cdb5

Browse files
committed
Drop GetOrderResponse, just use CreateOrderResponse
The object returned as a response to a `GetOrderRequest` is the same as for `CreateOrder`. We therefore shouldn't require two objects with different serializations here. We can just drop `GetOrderResponse` and use `CreateOrderResponse`.
1 parent 71b9dd2 commit 122cdb5

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

src/lsps1/client.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
use super::event::LSPS1ClientEvent;
1313
use super::msgs::{
1414
CreateOrderRequest, CreateOrderResponse, GetInfoRequest, GetInfoResponse, GetOrderRequest,
15-
GetOrderResponse, LSPS1Message, LSPS1Request, LSPS1Response, OptionsSupported, OrderId,
16-
OrderParams,
15+
LSPS1Message, LSPS1Request, LSPS1Response, OptionsSupported, OrderId, OrderParams,
1716
};
1817
use super::utils::is_valid;
1918
use crate::message_queue::MessageQueue;
@@ -526,7 +525,7 @@ where
526525
}
527526

528527
fn handle_get_order_response(
529-
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: GetOrderResponse,
528+
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: CreateOrderResponse,
530529
) -> Result<(), LightningError> {
531530
let outer_state_lock = self.per_peer_state.read().unwrap();
532531
match outer_state_lock.get(&counterparty_node_id) {

src/lsps1/msgs.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ pub struct GetOrderRequest {
217217
pub order_id: OrderId,
218218
}
219219

220-
/// A response to an [`GetOrderRequest`].
221-
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
222-
pub struct GetOrderResponse {
223-
/// The response to the order request.
224-
pub response: CreateOrderResponse,
225-
}
226-
227220
/// An enum that captures all the valid JSON-RPC requests in the LSPS1 protocol.
228221
#[derive(Clone, Debug, PartialEq, Eq)]
229222
pub enum LSPS1Request {
@@ -256,7 +249,7 @@ pub enum LSPS1Response {
256249
/// An error response to a [`CreateOrderRequest`].
257250
CreateOrderError(ResponseError),
258251
/// A successful response to a [`GetOrderRequest`].
259-
GetOrder(GetOrderResponse),
252+
GetOrder(CreateOrderResponse),
260253
/// An error response to a [`GetOrderRequest`].
261254
GetOrderError(ResponseError),
262255
}

src/lsps1/service.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use super::event::LSPS1ServiceEvent;
1313
use super::msgs::{
1414
ChannelInfo, CreateOrderRequest, CreateOrderResponse, GetInfoResponse, GetOrderRequest,
15-
GetOrderResponse, LSPS1Message, LSPS1Request, LSPS1Response, OptionsSupported, OrderId,
16-
OrderParams, OrderPayment, OrderState, LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
15+
LSPS1Message, LSPS1Request, LSPS1Response, OptionsSupported, OrderId, OrderParams,
16+
OrderPayment, OrderState, LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
1717
};
1818
use super::utils::is_valid;
1919
use crate::message_queue::MessageQueue;
@@ -376,16 +376,14 @@ where
376376
self.enqueue_response(
377377
&counterparty_node_id,
378378
request_id,
379-
LSPS1Response::GetOrder(GetOrderResponse {
380-
response: CreateOrderResponse {
381-
order_id,
382-
order: config.order.clone(),
383-
order_state,
384-
created_at: config.created_at,
385-
expires_at: config.expires_at,
386-
payment: config.payment.clone(),
387-
channel,
388-
},
379+
LSPS1Response::GetOrder(CreateOrderResponse {
380+
order_id,
381+
order: config.order.clone(),
382+
order_state,
383+
created_at: config.created_at,
384+
expires_at: config.expires_at,
385+
payment: config.payment.clone(),
386+
channel,
389387
}),
390388
)
391389
} else {

0 commit comments

Comments
 (0)