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

Commit 0f84a4b

Browse files
committed
LSPS1: Account for semantics change of confirms_within_blocks
as per BitcoinAndLightningLayerSpecs/lsp#81
1 parent 1ea185d commit 0f84a4b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/lsps1/event.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ pub enum LSPS1ClientEvent {
3535
user_channel_id: u128,
3636
/// The node id of the LSP that provided this response.
3737
counterparty_node_id: PublicKey,
38-
/// The website of the LSP.
39-
website: String,
4038
/// All options supported by the LSP.
4139
options_supported: OptionsSupported,
4240
},

src/lsps1/msgs.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ pub struct GetInfoRequest {}
3838
/// An object representing the supported protocol options.
3939
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
4040
pub struct OptionsSupported {
41-
/// The minimum number of block confirmations before the LSP accepts a channel as confirmed.
42-
pub min_channel_confirmations: u8,
41+
/// The smallest number of confirmations needed for the LSP to accept a channel as confirmed.
42+
pub min_required_channel_confirmations: u8,
43+
/// The smallest number of blocks in which the LSP can confirm the funding transaction.
44+
pub min_funding_confirms_within_blocks: u8,
4345
/// The minimum number of block confirmations before the LSP accepts an on-chain payment as confirmed.
4446
pub min_onchain_payment_confirmations: Option<u8>,
4547
/// Indicates if the LSP supports zero reserve.
@@ -84,6 +86,7 @@ pub struct GetInfoResponse {
8486
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
8587
pub struct CreateOrderRequest {
8688
/// The order made.
89+
#[serde(flatten)]
8790
pub order: OrderParams,
8891
}
8992

@@ -99,8 +102,10 @@ pub struct OrderParams {
99102
/// the channel.
100103
#[serde(with = "string_amount")]
101104
pub client_balance_sat: u64,
102-
/// The number of blocks the client wants to wait maximally for the channel to be confirmed.
103-
pub confirms_within_blocks: u32,
105+
/// The number of confirmations the funding tx must have before the LSP sends `channel_ready`.
106+
pub required_channel_confirmations: u8,
107+
/// The maximum number of blocks the client wants to wait until the funding transaction is confirmed.
108+
pub funding_confirms_within_blocks: u8,
104109
/// Indicates how long the channel is leased for in block time.
105110
pub channel_expiry_blocks: u32,
106111
/// May contain arbitrary associated data like a coupon code or a authentication token.
@@ -275,7 +280,8 @@ mod tests {
275280

276281
#[test]
277282
fn options_supported_serialization() {
278-
let min_channel_confirmations = 6;
283+
let min_required_channel_confirmations = 0;
284+
let min_funding_confirms_within_blocks = 6;
279285
let min_onchain_payment_confirmations = Some(6);
280286
let supports_zero_channel_reserve = true;
281287
let min_onchain_payment_size_sat = Some(100_000);
@@ -288,7 +294,8 @@ mod tests {
288294
let max_channel_balance_sat = 100_000_000;
289295

290296
let options_supported = OptionsSupported {
291-
min_channel_confirmations,
297+
min_required_channel_confirmations,
298+
min_funding_confirms_within_blocks,
292299
min_onchain_payment_confirmations,
293300
supports_zero_channel_reserve,
294301
min_onchain_payment_size_sat,
@@ -301,7 +308,8 @@ mod tests {
301308
max_channel_balance_sat,
302309
};
303310

304-
let json_str = r#"{"max_channel_balance_sat":"100000000","max_channel_expiry_blocks":144,"max_initial_client_balance_sat":"100000000","max_initial_lsp_balance_sat":"100000000","min_channel_balance_sat":"100000","min_channel_confirmations":6,"min_initial_client_balance_sat":"10000000","min_initial_lsp_balance_sat":"100000","min_onchain_payment_confirmations":6,"min_onchain_payment_size_sat":"100000","supports_zero_channel_reserve":true}"#;
311+
let json_str = r#"{"max_channel_balance_sat":"100000000","max_channel_expiry_blocks":144,"max_initial_client_balance_sat":"100000000","max_initial_lsp_balance_sat":"100000000","min_channel_balance_sat":"100000","min_funding_confirms_within_blocks":6,"min_initial_client_balance_sat":"10000000","min_initial_lsp_balance_sat":"100000","min_onchain_payment_confirmations":6,"min_onchain_payment_size_sat":"100000","min_required_channel_confirmations":0,"supports_zero_channel_reserve":true}"#;
312+
305313
assert_eq!(json_str, serde_json::json!(options_supported).to_string());
306314
assert_eq!(options_supported, serde_json::from_str(json_str).unwrap());
307315
}

0 commit comments

Comments
 (0)