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 21aadfb56..a6d3ac783 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 @@ -23,9 +23,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 145043f7a..747b997d6 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -21,10 +21,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 @@ -77,7 +74,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), @@ -95,7 +92,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 745bda4c4..c79e66311 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 857845d5f..1ae46800c 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -769,13 +769,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 4f139e050..a6ad8efe7 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -6910,9 +6910,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 b49aeba27..a60e8b233 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -5371,9 +5371,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;