Skip to content

Commit 962da67

Browse files
committed
Fix lsps1_service builds
As we're not testing with `cfg(lsps1_service)`, the builds broke during previous refactoring. This isn't bad as we're looking to completely overhaul / rewrite LSPS1 service soon, but until then we fix this pre-existing breakage to make sure following changes make sense.
1 parent dfc7139 commit 962da67

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

ci/ci-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,5 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
132132
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
133133
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
134134
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning
135+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
136+
RUSTFLAGS="--cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity

lightning-liquidity/src/lsps1/service.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ use super::msgs::{
1515
LSPS1Message, LSPS1Options, LSPS1Request, LSPS1Response, OrderId, OrderParameters, OrderState,
1616
PaymentInfo, LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
1717
};
18-
use super::utils::is_valid;
1918
use crate::message_queue::MessageQueue;
2019

2120
use crate::events::{Event, EventQueue};
2221
use crate::lsps0::ser::{ProtocolMessageHandler, RequestId, ResponseError};
23-
use crate::prelude::{new_hash_map, HashMap, String, ToString};
22+
use crate::prelude::{new_hash_map, HashMap, String};
2423
use crate::sync::{Arc, Mutex, RwLock};
2524
use crate::utils;
2625

@@ -306,7 +305,7 @@ where
306305
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: GetOrderRequest,
307306
) -> Result<(), LightningError> {
308307
let outer_state_lock = self.per_peer_state.read().unwrap();
309-
match outer_state_lock.get(&counterparty_node_id) {
308+
match outer_state_lock.get(counterparty_node_id) {
310309
Some(inner_state_lock) => {
311310
let mut peer_state_lock = inner_state_lock.lock().unwrap();
312311

@@ -457,3 +456,25 @@ where
457456
}
458457
}
459458
}
459+
460+
fn check_range(min: u64, max: u64, value: u64) -> bool {
461+
(value >= min) && (value <= max)
462+
}
463+
464+
fn is_valid(order: &OrderParameters, options: &LSPS1Options) -> bool {
465+
let bool = check_range(
466+
options.min_initial_client_balance_sat,
467+
options.max_initial_client_balance_sat,
468+
order.client_balance_sat,
469+
) && check_range(
470+
options.min_initial_lsp_balance_sat,
471+
options.max_initial_lsp_balance_sat,
472+
order.lsp_balance_sat,
473+
) && check_range(
474+
1,
475+
options.max_channel_expiry_blocks.into(),
476+
order.channel_expiry_blocks.into(),
477+
);
478+
479+
bool
480+
}

lightning-liquidity/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ where {
173173
#[cfg(lsps1_service)]
174174
let lsps1_service_handler = service_config.as_ref().and_then(|config| {
175175
if let Some(number) =
176-
<LSPS1ServiceHandler<ES> as ProtocolMessageHandler>::PROTOCOL_NUMBER
176+
<LSPS1ServiceHandler<ES, CM, C> as ProtocolMessageHandler>::PROTOCOL_NUMBER
177177
{
178178
supported_protocols.push(number);
179179
}

0 commit comments

Comments
 (0)