diff --git a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h index 5856a4772..c71ddba25 100644 --- a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h +++ b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h @@ -25,9 +25,7 @@ typedef struct _Dart_Handle* Dart_Handle; /** * The minimum acceptable fee rate when claiming using zero-conf */ -#define DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET 100 - -#define DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET 10 +#define DEFAULT_ZERO_CONF_MIN_FEE_RATE 100 /** * The maximum acceptable amount in satoshi when claiming using zero-conf diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index 19a92a9d2..86baeb3b7 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -22,10 +22,7 @@ use strum_macros::{Display, EnumString}; use crate::error::{PaymentError, SdkError, SdkResult}; use crate::prelude::DEFAULT_EXTERNAL_INPUT_PARSERS; -use crate::receive_swap::{ - DEFAULT_ZERO_CONF_MAX_SAT, DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET, - DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET, -}; +use crate::receive_swap::{DEFAULT_ZERO_CONF_MAX_SAT, DEFAULT_ZERO_CONF_MIN_FEE_RATE}; use crate::utils; // Uses f64 for the maximum precision when converting between units @@ -85,7 +82,7 @@ impl Config { cache_dir: None, network: LiquidNetwork::Mainnet, payment_timeout_sec: 15, - zero_conf_min_fee_rate_msat: DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET, + zero_conf_min_fee_rate_msat: DEFAULT_ZERO_CONF_MIN_FEE_RATE, sync_service_url: BREEZ_SYNC_SERVICE_URL.to_string(), zero_conf_max_amount_sat: None, breez_api_key: Some(breez_api_key), @@ -104,7 +101,7 @@ impl Config { cache_dir: None, network: LiquidNetwork::Testnet, payment_timeout_sec: 15, - zero_conf_min_fee_rate_msat: DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET, + zero_conf_min_fee_rate_msat: DEFAULT_ZERO_CONF_MIN_FEE_RATE, sync_service_url: BREEZ_SYNC_SERVICE_URL.to_string(), zero_conf_max_amount_sat: None, breez_api_key, diff --git a/lib/core/src/receive_swap.rs b/lib/core/src/receive_swap.rs index e614bc08b..e46869df3 100644 --- a/lib/core/src/receive_swap.rs +++ b/lib/core/src/receive_swap.rs @@ -19,8 +19,7 @@ use crate::{ }; /// The minimum acceptable fee rate when claiming using zero-conf -pub const DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET: u32 = 100; -pub const DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET: u32 = 10; +pub const DEFAULT_ZERO_CONF_MIN_FEE_RATE: u32 = 100; /// The maximum acceptable amount in satoshi when claiming using zero-conf pub const DEFAULT_ZERO_CONF_MAX_SAT: u64 = 100_000; @@ -158,7 +157,8 @@ impl ReceiveSwapHandler { // If the fees are higher than our estimated value let tx_fees: u64 = lockup_tx.all_fees().values().sum(); let min_fee_rate = self.config.zero_conf_min_fee_rate_msat as f32 / 1000.0; - let lower_bound_estimated_fees = lockup_tx.vsize() as f32 * min_fee_rate * 0.8; + let lower_bound_estimated_fees = + lockup_tx.discount_vsize() as f32 * min_fee_rate * 0.8; if lower_bound_estimated_fees > tx_fees as f32 { warn!("[Receive Swap {id}] Lockup tx fees are too low: Expected at least {lower_bound_estimated_fees} sat, got {tx_fees} sat. Waiting for confirmation..."); diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 18164922a..f7f93e33c 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -788,13 +788,15 @@ impl LiquidSdk { amount_sat: u64, address: &str, ) -> Result { - Ok(self + let fee_sat = self .onchain_wallet .build_tx(Some(LIQUID_FEE_RATE_MSAT_PER_VBYTE), address, amount_sat) .await? .all_fees() .values() - .sum()) + .sum::(); + info!("Estimated tx fee: {fee_sat} sat"); + Ok(fee_sat) } fn get_temp_p2tr_addr(&self) -> &str { diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index e98bfb8eb..74b191617 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -6928,9 +6928,7 @@ const double LIQUID_FEE_RATE_SAT_PER_VBYTE = 0.1; const double LIQUID_FEE_RATE_MSAT_PER_VBYTE = 100.0; -const int DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET = 100; - -const int DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET = 10; +const int DEFAULT_ZERO_CONF_MIN_FEE_RATE = 100; const int DEFAULT_ZERO_CONF_MAX_SAT = 100000; diff --git a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart index cb8d4ed60..a47f40422 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -5445,9 +5445,7 @@ const double LIQUID_FEE_RATE_SAT_PER_VBYTE = 0.1; const double LIQUID_FEE_RATE_MSAT_PER_VBYTE = 100.0; -const int DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET = 100; - -const int DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET = 10; +const int DEFAULT_ZERO_CONF_MIN_FEE_RATE = 100; const int DEFAULT_ZERO_CONF_MAX_SAT = 100000;