diff --git a/libs/lsp-primitives/src/lsps1/builders.rs b/libs/lsp-primitives/src/lsps1/builders.rs index f0f8423..172923f 100644 --- a/libs/lsp-primitives/src/lsps1/builders.rs +++ b/libs/lsp-primitives/src/lsps1/builders.rs @@ -213,7 +213,7 @@ impl Lsps1OptionsBuilder { pub struct Lsps1CreateOrderRequestBuilder { lsp_balance_sat: Option, client_balance_sat: Option, - confirms_within_blocks: Option, + funding_confirms_within_blocks: Option, channel_expiry_blocks: Option, token: Option, refund_onchain_address: Option, @@ -240,8 +240,8 @@ impl Lsps1CreateOrderRequestBuilder { self } - pub fn confirms_within_blocks(mut self, confirms_within_blocks: Option) -> Self { - self.confirms_within_blocks = confirms_within_blocks; + pub fn funding_confirms_within_blocks(mut self, funding_confirms_within_blocks: Option) -> Self { + self.funding_confirms_within_blocks = funding_confirms_within_blocks; self } @@ -275,7 +275,7 @@ impl Lsps1CreateOrderRequestBuilder { // Fields that allow for reasonable defaults let client_balance_sat = self.client_balance_sat.unwrap_or(SatAmount::new(0)); let announce_channel = self.announce_channel.unwrap_or(false); - let confirms_within_blocks = self.confirms_within_blocks.unwrap_or(6); + let funding_confirms_within_blocks = self.funding_confirms_within_blocks.unwrap_or(6); // Non-required fields let token = self.token; @@ -284,7 +284,7 @@ impl Lsps1CreateOrderRequestBuilder { let request = Lsps1CreateOrderRequest { lsp_balance_sat, client_balance_sat, - confirms_within_blocks, + funding_confirms_within_blocks, channel_expiry_blocks, token, refund_onchain_address, @@ -300,7 +300,7 @@ pub struct Lsps1CreateOrderResponseBuilder { uuid: Option, lsp_balance_sat: Option, client_balance_sat: Option, - confirms_within_blocks: Option, + funding_confirms_within_blocks: Option, channel_expiry_blocks: Option, token: Option, announce_channel: Option, @@ -320,7 +320,7 @@ impl Lsps1CreateOrderResponseBuilder { Self::new() .lsp_balance_sat(request.lsp_balance_sat) .client_balance_sat(request.client_balance_sat) - .confirms_within_blocks(request.confirms_within_blocks) + .funding_confirms_within_blocks(request.funding_confirms_within_blocks) .channel_expiry_blocks(request.channel_expiry_blocks) .token(request.token.unwrap_or("".to_string())) // .refund_onchain_address(request.refund_onchain_address) @@ -339,8 +339,8 @@ impl Lsps1CreateOrderResponseBuilder { self.client_balance_sat = Some(client_balance_sat); self } - pub fn confirms_within_blocks(mut self, confirms_within_blocks: u8) -> Self { - self.confirms_within_blocks = Some(confirms_within_blocks); + pub fn funding_confirms_within_blocks(mut self, funding_confirms_within_blocks: u8) -> Self { + self.funding_confirms_within_blocks = Some(funding_confirms_within_blocks); self } pub fn channel_expiry_blocks(mut self, channel_expiry_blocks: u32) -> Self { @@ -387,9 +387,9 @@ impl Lsps1CreateOrderResponseBuilder { let client_balance_sat = self .client_balance_sat .context("Missing field 'client_balance_sat' in Lsps1CreateOrderRequestBuilder")?; - let confirms_within_blocks = self - .confirms_within_blocks - .context("Missing field 'confirms_within_blocks' in Lsps1CreateOrderRequestBuilder")?; + let funding_confirms_within_blocks = self + .funding_confirms_within_blocks + .context("Missing field 'funding_confirms_within_blocks' in Lsps1CreateOrderRequestBuilder")?; let channel_expiry_blocks = self .channel_expiry_blocks .context("Missing field 'channel_expiry_blocks' in Lsps1CreateOrderRequestBuilder")?; @@ -415,7 +415,7 @@ impl Lsps1CreateOrderResponseBuilder { order_id, lsp_balance_sat, client_balance_sat, - confirms_within_blocks, + funding_confirms_within_blocks, channel_expiry_blocks, token, announce_channel, diff --git a/libs/lsp-primitives/src/lsps1/schema.rs b/libs/lsp-primitives/src/lsps1/schema.rs index 32e59e7..eefff13 100644 --- a/libs/lsp-primitives/src/lsps1/schema.rs +++ b/libs/lsp-primitives/src/lsps1/schema.rs @@ -33,7 +33,7 @@ pub struct Lsps1Options { pub struct Lsps1CreateOrderRequest { pub lsp_balance_sat: SatAmount, pub client_balance_sat: SatAmount, - pub confirms_within_blocks: u8, + pub funding_confirms_within_blocks: u8, pub channel_expiry_blocks: u32, pub token: Option, pub refund_onchain_address: Option, @@ -45,7 +45,7 @@ impl ExpectedFields for Lsps1CreateOrderRequest { vec![ "lsp_balance_sat".to_string(), "client_balance_sat".to_string(), - "confirms_within_blocks".to_string(), + "funding_confirms_within_blocks".to_string(), "channel_expiry_blocks".to_string(), "token".to_string(), "refund_onchain_address".to_string(), @@ -59,7 +59,7 @@ pub struct Lsps1CreateOrderResponse { pub order_id: Uuid, pub lsp_balance_sat: SatAmount, pub client_balance_sat: SatAmount, - pub confirms_within_blocks: u8, + pub funding_confirms_within_blocks: u8, pub channel_expiry_blocks: u32, pub token: String, pub announce_channel: bool, @@ -197,7 +197,7 @@ mod test { let request = Lsps1CreateOrderRequest { lsp_balance_sat: SatAmount::new(100_000), client_balance_sat: SatAmount::new(1_000), - confirms_within_blocks: 10, + funding_confirms_within_blocks: 10, channel_expiry_blocks: 1000, token: None, refund_onchain_address: Some(onchain), diff --git a/libs/lsp-primitives/src/lsps1/util.rs b/libs/lsp-primitives/src/lsps1/util.rs index 612a8b4..46495c1 100644 --- a/libs/lsp-primitives/src/lsps1/util.rs +++ b/libs/lsp-primitives/src/lsps1/util.rs @@ -133,7 +133,7 @@ mod tests { Lsps1CreateOrderRequestBuilder::new() .client_balance_sat(Some(SatAmount::new(0))) .lsp_balance_sat(SatAmount::new(500_000)) - .confirms_within_blocks(Some(6)) + .funding_confirms_within_blocks(Some(6)) .channel_expiry_blocks(1_000) .token(None) .refund_onchain_address(None) diff --git a/plugins/lsps-client/src/main.rs b/plugins/lsps-client/src/main.rs index d661594..0245713 100644 --- a/plugins/lsps-client/src/main.rs +++ b/plugins/lsps-client/src/main.rs @@ -213,7 +213,7 @@ async fn lsps1_create_order( let create_order_request = lsps1::builders::Lsps1CreateOrderRequestBuilder::new() .lsp_balance_sat(request.lsp_balance_sat) .client_balance_sat(request.client_balance_sat) - .confirms_within_blocks(request.confirms_within_blocks) + .funding_confirms_within_blocks(request.funding_confirms_within_blocks) .channel_expiry_blocks(request.channel_expiry_blocks) .token(request.token) .refund_onchain_address(request.refund_onchain_address) diff --git a/plugins/lsps-client/src/plugin_rpc.rs b/plugins/lsps-client/src/plugin_rpc.rs index 9b44d38..aa5f33c 100644 --- a/plugins/lsps-client/src/plugin_rpc.rs +++ b/plugins/lsps-client/src/plugin_rpc.rs @@ -30,7 +30,7 @@ pub struct Lsps1CreateOrderRequest { pub peer_id: String, pub lsp_balance_sat: SatAmount, pub client_balance_sat: Option, - pub confirms_within_blocks: Option, + pub funding_confirms_within_blocks: Option, pub channel_expiry_blocks: u32, pub token: Option, pub refund_onchain_address: Option, diff --git a/plugins/lsps-server/migrations/20231129151538_create_order_table.up.sql b/plugins/lsps-server/migrations/20231129151538_create_order_table.up.sql index 0932a9e..597d694 100644 --- a/plugins/lsps-server/migrations/20231129151538_create_order_table.up.sql +++ b/plugins/lsps-server/migrations/20231129151538_create_order_table.up.sql @@ -5,7 +5,7 @@ CREATE TABLE lsps1_order ( client_node_id TEXT NOT NULL, -- The node-id of the client lsp_balance_sat INTEGER NOT NULL, -- as requested by the client client_balance_sat INTEGER NOT NULL, -- as requested by the client - confirms_within_blocks INTEGER NOT NULL, -- as requested by the client + funding_confirms_within_blocks INTEGER NOT NULL, -- as requested by the client channel_expiry_blocks INTEGER NOT NULL, -- as requested by the client token TEXT, -- as requested by the client refund_onchain_address TEXT, -- as requested by the client diff --git a/plugins/lsps-server/src/db/schema.rs b/plugins/lsps-server/src/db/schema.rs index c0865bf..5679d24 100644 --- a/plugins/lsps-server/src/db/schema.rs +++ b/plugins/lsps-server/src/db/schema.rs @@ -10,7 +10,7 @@ pub struct Lsps1Order { pub(crate) client_node_id: PublicKey, pub(crate) lsp_balance_sat: SatAmount, pub(crate) client_balance_sat: SatAmount, - pub(crate) confirms_within_blocks: u8, + pub(crate) funding_confirms_within_blocks: u8, pub(crate) channel_expiry_blocks: u32, pub(crate) token: Option, pub(crate) refund_onchain_address: Option, diff --git a/plugins/lsps-server/src/db/sqlite/mod.rs b/plugins/lsps-server/src/db/sqlite/mod.rs index 5e6975d..1fbe9c4 100644 --- a/plugins/lsps-server/src/db/sqlite/mod.rs +++ b/plugins/lsps-server/src/db/sqlite/mod.rs @@ -65,7 +65,7 @@ mod test { .unwrap(), lsp_balance_sat: SatAmount::new(100_000), client_balance_sat: SatAmount::new(0), - confirms_within_blocks: 0, + funding_confirms_within_blocks: 0, created_at, expires_at, refund_onchain_address: None, @@ -131,7 +131,7 @@ mod test { assert_eq!(order.uuid, uuid); assert_eq!(order.lsp_balance_sat, SatAmount::new(100_000)); assert_eq!(order.client_balance_sat, SatAmount::new(0)); - assert_eq!(order.confirms_within_blocks, 0); + assert_eq!(order.funding_confirms_within_blocks, 0); assert_eq!( order.created_at.unix_timestamp(), initial_order.created_at.unix_timestamp() diff --git a/plugins/lsps-server/src/db/sqlite/queries/create_order.rs b/plugins/lsps-server/src/db/sqlite/queries/create_order.rs index cd45d94..afa032e 100644 --- a/plugins/lsps-server/src/db/sqlite/queries/create_order.rs +++ b/plugins/lsps-server/src/db/sqlite/queries/create_order.rs @@ -38,7 +38,7 @@ impl Lsps1CreateOrderQuery { INSERT INTO lsps1_order ( uuid, client_node_id, lsp_balance_sat, client_balance_sat, - confirms_within_blocks, channel_expiry_blocks, + funding_confirms_within_blocks, channel_expiry_blocks, token, refund_onchain_address, announce_channel, created_at, expires_at @@ -50,7 +50,7 @@ impl Lsps1CreateOrderQuery { order.client_node_id, order.lsp_balance_sat, order.client_balance_sat, - order.confirms_within_blocks, + order.funding_confirms_within_blocks, order.channel_expiry_blocks, order.token, order.refund_onchain_address, diff --git a/plugins/lsps-server/src/db/sqlite/queries/get_order.rs b/plugins/lsps-server/src/db/sqlite/queries/get_order.rs index 9606f3b..07a960a 100644 --- a/plugins/lsps-server/src/db/sqlite/queries/get_order.rs +++ b/plugins/lsps-server/src/db/sqlite/queries/get_order.rs @@ -26,7 +26,7 @@ impl GetOrderQuery { Lsps1OrderSqlite, r#"SELECT uuid, client_node_id, lsp_balance_sat, - client_balance_sat, confirms_within_blocks, channel_expiry_blocks, + client_balance_sat, funding_confirms_within_blocks, channel_expiry_blocks, token, refund_onchain_address, announce_channel, ord.created_at, expires_at, os.order_state_enum_id as order_state, generation diff --git a/plugins/lsps-server/src/db/sqlite/schema.rs b/plugins/lsps-server/src/db/sqlite/schema.rs index 46b966a..c9e09a4 100644 --- a/plugins/lsps-server/src/db/sqlite/schema.rs +++ b/plugins/lsps-server/src/db/sqlite/schema.rs @@ -18,7 +18,7 @@ pub struct Lsps1Order { pub(crate) client_node_id: String, pub(crate) lsp_balance_sat: i64, pub(crate) client_balance_sat: i64, - pub(crate) confirms_within_blocks: i64, + pub(crate) funding_confirms_within_blocks: i64, pub(crate) channel_expiry_blocks: i64, pub(crate) token: Option, pub(crate) refund_onchain_address: Option, @@ -119,7 +119,7 @@ impl TryFrom<&Lsps1Order> for Lsps1OrderBase { client_node_id: PublicKey::from_hex(&order.client_node_id)?, lsp_balance_sat: SatAmount::new(u64::try_from(order.lsp_balance_sat)?), client_balance_sat: SatAmount::new(u64::try_from(order.client_balance_sat)?), - confirms_within_blocks: u8::try_from(order.confirms_within_blocks)?, + funding_confirms_within_blocks: u8::try_from(order.funding_confirms_within_blocks)?, channel_expiry_blocks: u32::try_from(order.channel_expiry_blocks)?, token: order.token.clone(), refund_onchain_address: order.refund_onchain_address.clone(), @@ -141,7 +141,7 @@ impl TryFrom<&Lsps1OrderBase> for Lsps1Order { client_node_id: order.client_node_id.to_hex(), lsp_balance_sat: i64::try_from(order.lsp_balance_sat.sat_value())?, client_balance_sat: i64::try_from(order.client_balance_sat.sat_value())?, - confirms_within_blocks: i64::try_from(order.confirms_within_blocks)?, + funding_confirms_within_blocks: i64::try_from(order.funding_confirms_within_blocks)?, channel_expiry_blocks: i64::try_from(order.channel_expiry_blocks)?, token: order.token.clone(), refund_onchain_address: order.refund_onchain_address.clone(), diff --git a/plugins/lsps-server/src/lsps1/fee_calc.rs b/plugins/lsps-server/src/lsps1/fee_calc.rs index b637fae..a6da7a2 100644 --- a/plugins/lsps-server/src/lsps1/fee_calc.rs +++ b/plugins/lsps-server/src/lsps1/fee_calc.rs @@ -52,7 +52,7 @@ impl FeeCalculator for StandardFeeCalculator { .estimates .context("Failed to retrieve feerates")?; - let onchain_feerate_kwu = calculate_onchain_feerate(order.confirms_within_blocks, &feerates) + let onchain_feerate_kwu = calculate_onchain_feerate(order.funding_confirms_within_blocks, &feerates) .context("Failed to compute approriate feerate")? as u64; diff --git a/plugins/lsps-server/src/lsps1/hooks/custommsg.rs b/plugins/lsps-server/src/lsps1/hooks/custommsg.rs index bd3baad..8f6ff5b 100644 --- a/plugins/lsps-server/src/lsps1/hooks/custommsg.rs +++ b/plugins/lsps-server/src/lsps1/hooks/custommsg.rs @@ -92,11 +92,11 @@ pub(crate) async fn do_lsps1_create_order( uuid: Uuid::new_v4(), client_node_id: context.peer_id, announce_channel: order.announce_channel, - created_at: created_at, - expires_at: expires_at, + created_at, + expires_at, lsp_balance_sat: order.lsp_balance_sat, client_balance_sat: order.client_balance_sat, - confirms_within_blocks: order.confirms_within_blocks, + funding_confirms_within_blocks: order.funding_confirms_within_blocks, channel_expiry_blocks: order.channel_expiry_blocks, token: order.token.clone(), refund_onchain_address: order.refund_onchain_address.as_ref().map(|x| x.to_string()), diff --git a/plugins/lsps-server/src/lsps1/msg.rs b/plugins/lsps-server/src/lsps1/msg.rs index 7208ab6..aabb4bb 100644 --- a/plugins/lsps-server/src/lsps1/msg.rs +++ b/plugins/lsps-server/src/lsps1/msg.rs @@ -10,7 +10,7 @@ impl BuildLsps1Order for Lsps1CreateOrderResponseBuilder { self.uuid(order.uuid) .lsp_balance_sat(order.lsp_balance_sat) .client_balance_sat(order.client_balance_sat) - .confirms_within_blocks(order.confirms_within_blocks) + .funding_confirms_within_blocks(order.funding_confirms_within_blocks) .channel_expiry_blocks(order.channel_expiry_blocks) .token(order.token.unwrap_or("".to_string())) .announce_channel(order.announce_channel) diff --git a/test/server/test_lsps1.py b/test/server/test_lsps1.py index 94a551d..ea540fc 100644 --- a/test/server/test_lsps1.py +++ b/test/server/test_lsps1.py @@ -73,7 +73,7 @@ def test_lsps1_create_order_violate_options(lsps_server, lsps_client): params = dict( lsp_balance_sat="0", client_balance_sat="1000001", # Too large - confirms_within_blocks=1, + funding_confirms_within_blocks=1, channel_expiry_blocks=144, announce_channel=False, ) @@ -84,7 +84,7 @@ def test_lsps1_create_order_violate_options(lsps_server, lsps_client): params=json.dumps(params), ) - assert "error" in response, "Should be optiom mismatch but returned result" + assert "error" in response, "Should be option mismatch but returned result" error = response["error"] assert error["code"] == 1000 @@ -98,7 +98,7 @@ def test_lsps1_create_order(lsps_server, lsps_client): params = dict( lsp_balance_sat="500000", client_balance_sat="0", - confirms_within_blocks=1, + funding_confirms_within_blocks=1, channel_expiry_blocks=144, announce_channel=False, ) @@ -114,7 +114,7 @@ def test_lsps1_create_order(lsps_server, lsps_client): assert result["lsp_balance_sat"] == "500000" assert result["client_balance_sat"] == "0" - assert result["confirms_within_blocks"] == 1 + assert result["funding_confirms_within_blocks"] == 1 assert result["channel_expiry_blocks"] == 144 assert result["announce_channel"] == False @@ -128,7 +128,7 @@ def test_lsps1_get_order_by_uuid(lsps_client, lsps_server): params = dict( lsp_balance_sat="500000", client_balance_sat="0", - confirms_within_blocks=1, + funding_confirms_within_blocks=1, channel_expiry_blocks=144, announce_channel=False, ) @@ -151,7 +151,7 @@ def test_lsps1_get_order_by_uuid(lsps_client, lsps_server): assert result["lsp_balance_sat"] == "500000" assert result["client_balance_sat"] == "0" - assert result["confirms_within_blocks"] == 1 + assert result["funding_confirms_within_blocks"] == 1 assert result["channel_expiry_blocks"] == 144 assert not result["announce_channel"] @@ -173,7 +173,7 @@ def test_pay_lsps1_order(lsps_client, lsps_server): params = dict( lsp_balance_sat="123456", client_balance_sat="0", - confirms_within_blocks=1, + funding_confirms_within_blocks=1, channel_expiry_blocks=144, announce_channel=False, )