Skip to content

Commit

Permalink
Rename funding_confirms_within_blocks
Browse files Browse the repository at this point in the history
`confirms_within_blocks` -> `funding_confirms_within_blocks`
  • Loading branch information
ErikDeSmedt committed Apr 16, 2024
1 parent 53b0d1a commit 1ed0d06
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
20 changes: 10 additions & 10 deletions libs/lsp-primitives/src/lsps1/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Lsps1OptionsBuilder {
pub struct Lsps1CreateOrderRequestBuilder {
lsp_balance_sat: Option<SatAmount>,
client_balance_sat: Option<SatAmount>,
confirms_within_blocks: Option<u8>,
funding_confirms_within_blocks: Option<u8>,
channel_expiry_blocks: Option<u32>,
token: Option<String>,
refund_onchain_address: Option<OnchainAddress>,
Expand All @@ -240,8 +240,8 @@ impl Lsps1CreateOrderRequestBuilder {
self
}

pub fn confirms_within_blocks(mut self, confirms_within_blocks: Option<u8>) -> Self {
self.confirms_within_blocks = confirms_within_blocks;
pub fn funding_confirms_within_blocks(mut self, funding_confirms_within_blocks: Option<u8>) -> Self {
self.funding_confirms_within_blocks = funding_confirms_within_blocks;
self
}

Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -300,7 +300,7 @@ pub struct Lsps1CreateOrderResponseBuilder {
uuid: Option<Uuid>,
lsp_balance_sat: Option<SatAmount>,
client_balance_sat: Option<SatAmount>,
confirms_within_blocks: Option<u8>,
funding_confirms_within_blocks: Option<u8>,
channel_expiry_blocks: Option<u32>,
token: Option<String>,
announce_channel: Option<bool>,
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -388,7 +388,7 @@ impl Lsps1CreateOrderResponseBuilder {
.client_balance_sat
.context("Missing field 'client_balance_sat' in Lsps1CreateOrderRequestBuilder")?;
let confirms_within_blocks = self
.confirms_within_blocks
.funding_confirms_within_blocks
.context("Missing field 'confirms_within_blocks' in Lsps1CreateOrderRequestBuilder")?;
let channel_expiry_blocks = self
.channel_expiry_blocks
Expand Down
4 changes: 2 additions & 2 deletions libs/lsp-primitives/src/lsps1/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub refund_onchain_address: Option<OnchainAddress>,
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-client/src/plugin_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Lsps1CreateOrderRequest {
pub peer_id: String,
pub lsp_balance_sat: SatAmount,
pub client_balance_sat: Option<SatAmount>,
pub confirms_within_blocks: Option<u8>,
pub funding_confirms_within_blocks: Option<u8>,
pub channel_expiry_blocks: u32,
pub token: Option<String>,
pub refund_onchain_address: Option<OnchainAddress>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-server/src/db/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub(crate) refund_onchain_address: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions plugins/lsps-server/src/db/sqlite/queries/create_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-server/src/db/sqlite/queries/get_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions plugins/lsps-server/src/db/sqlite/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub(crate) refund_onchain_address: Option<String>,
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-server/src/lsps1/fee_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions plugins/lsps-server/src/lsps1/hooks/custommsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion plugins/lsps-server/src/lsps1/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ed0d06

Please sign in to comment.