@@ -170,7 +170,7 @@ where
170
170
fn handle_get_info_request (
171
171
& self , request_id : RequestId , counterparty_node_id : & PublicKey ,
172
172
) -> Result < ( ) , LightningError > {
173
- let response = GetInfoResponse {
173
+ let response = LSPS1Response :: GetInfo ( GetInfoResponse {
174
174
website : self . config . website . clone ( ) . unwrap ( ) . to_string ( ) ,
175
175
options : self
176
176
. config
@@ -181,28 +181,27 @@ where
181
181
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
182
182
} )
183
183
. unwrap ( ) ,
184
- } ;
184
+ } ) ;
185
185
186
- self . enqueue_response ( counterparty_node_id, request_id, LSPS1Response :: GetInfo ( response) ) ;
186
+ let msg = LSPS1Message :: Response ( request_id, response) . into ( ) ;
187
+ self . pending_messages . enqueue ( counterparty_node_id, msg) ;
187
188
Ok ( ( ) )
188
189
}
189
190
190
191
fn handle_create_order_request (
191
192
& self , request_id : RequestId , counterparty_node_id : & PublicKey , params : CreateOrderRequest ,
192
193
) -> Result < ( ) , LightningError > {
193
194
if !is_valid ( & params. order , & self . config . options_supported . as_ref ( ) . unwrap ( ) ) {
194
- self . enqueue_response (
195
- counterparty_node_id,
196
- request_id,
197
- LSPS1Response :: CreateOrderError ( ResponseError {
198
- code : LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE ,
199
- message : format ! ( "Order does not match options supported by LSP server" ) ,
200
- data : Some ( format ! (
201
- "Supported options are {:?}" ,
202
- & self . config. options_supported. as_ref( ) . unwrap( )
203
- ) ) ,
204
- } ) ,
205
- ) ;
195
+ let response = LSPS1Response :: CreateOrderError ( ResponseError {
196
+ code : LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE ,
197
+ message : format ! ( "Order does not match options supported by LSP server" ) ,
198
+ data : Some ( format ! (
199
+ "Supported options are {:?}" ,
200
+ & self . config. options_supported. as_ref( ) . unwrap( )
201
+ ) ) ,
202
+ } ) ;
203
+ let msg = LSPS1Message :: Response ( request_id, response) . into ( ) ;
204
+ self . pending_messages . enqueue ( counterparty_node_id, msg) ;
206
205
return Err ( LightningError {
207
206
err : format ! (
208
207
"Client order does not match any supported options: {:?}" ,
@@ -262,19 +261,17 @@ where
262
261
263
262
peer_state_lock. insert_outbound_channel ( order_id. clone ( ) , channel) ;
264
263
265
- self . enqueue_response (
266
- counterparty_node_id,
267
- request_id,
268
- LSPS1Response :: CreateOrder ( CreateOrderResponse {
269
- order : params. order ,
270
- order_id,
271
- order_state : OrderState :: Created ,
272
- created_at,
273
- expires_at,
274
- payment,
275
- channel : None ,
276
- } ) ,
277
- ) ;
264
+ let response = LSPS1Response :: CreateOrder ( CreateOrderResponse {
265
+ order : params. order ,
266
+ order_id,
267
+ order_state : OrderState :: Created ,
268
+ created_at,
269
+ expires_at,
270
+ payment,
271
+ channel : None ,
272
+ } ) ;
273
+ let msg = LSPS1Message :: Response ( request_id, response) . into ( ) ;
274
+ self . pending_messages . enqueue ( counterparty_node_id, msg) ;
278
275
} ,
279
276
280
277
_ => {
@@ -372,19 +369,17 @@ where
372
369
{
373
370
let config = & outbound_channel. config ;
374
371
375
- self . enqueue_response (
376
- & counterparty_node_id,
377
- request_id,
378
- LSPS1Response :: GetOrder ( CreateOrderResponse {
379
- order_id,
380
- order : config. order . clone ( ) ,
381
- order_state,
382
- created_at : config. created_at ,
383
- expires_at : config. expires_at ,
384
- payment : config. payment . clone ( ) ,
385
- channel,
386
- } ) ,
387
- )
372
+ let response = LSPS1Response :: GetOrder ( CreateOrderResponse {
373
+ order_id,
374
+ order : config. order . clone ( ) ,
375
+ order_state,
376
+ created_at : config. created_at ,
377
+ expires_at : config. expires_at ,
378
+ payment : config. payment . clone ( ) ,
379
+ channel,
380
+ } ) ;
381
+ let msg = LSPS1Message :: Response ( request_id, response) . into ( ) ;
382
+ self . pending_messages . enqueue ( & counterparty_node_id, msg) ;
388
383
} else {
389
384
return Err ( APIError :: APIMisuseError {
390
385
err : format ! ( "Channel with order_id {} not found" , order_id. 0 ) ,
@@ -400,13 +395,6 @@ where
400
395
Ok ( ( ) )
401
396
}
402
397
403
- fn enqueue_response (
404
- & self , counterparty_node_id : & PublicKey , request_id : RequestId , response : LSPS1Response ,
405
- ) {
406
- self . pending_messages
407
- . enqueue ( counterparty_node_id, LSPS1Message :: Response ( request_id, response) . into ( ) ) ;
408
- }
409
-
410
398
fn generate_order_id ( & self ) -> OrderId {
411
399
let bytes = self . entropy_source . get_secure_random_bytes ( ) ;
412
400
OrderId ( utils:: hex_str ( & bytes[ 0 ..16 ] ) )
0 commit comments