diff --git a/crates/cdk-mintd/Cargo.toml b/crates/cdk-mintd/Cargo.toml index 34640215e..b12372ef0 100644 --- a/crates/cdk-mintd/Cargo.toml +++ b/crates/cdk-mintd/Cargo.toml @@ -36,6 +36,7 @@ home = "0.5.5" url = "2.3" utoipa = { version = "4", optional = true } utoipa-swagger-ui = { version = "4", features = ["axum"], optional = true } +rand = "0.8.5" [features] swagger = ["cdk-axum/swagger", "dep:utoipa", "dep:utoipa-swagger-ui"] \ No newline at end of file diff --git a/crates/cdk-mintd/src/config.rs b/crates/cdk-mintd/src/config.rs index a4a1ac072..bc343bc6d 100644 --- a/crates/cdk-mintd/src/config.rs +++ b/crates/cdk-mintd/src/config.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use cdk::nuts::{CurrencyUnit, PublicKey}; use cdk::Amount; use config::{Config, ConfigError, File}; +use rand::Rng; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, Default)] @@ -104,14 +105,21 @@ pub struct FakeWallet { pub supported_units: Vec, pub fee_percent: f32, pub reserve_fee_min: Amount, + pub min_delay_time: u64, + pub max_delay_time: u64, } impl Default for FakeWallet { fn default() -> Self { + let mut rng = rand::thread_rng(); + let min_rang = rng.gen_range(1..=1000); + let max_rang = rng.gen_range(1..=1000); Self { supported_units: vec![CurrencyUnit::Sat], fee_percent: 0.02, reserve_fee_min: 2.into(), + min_delay_time: min_rang, + max_delay_time: max_rang, } } } diff --git a/crates/cdk-mintd/src/setup.rs b/crates/cdk-mintd/src/setup.rs index 53b0c5c63..41c91bd36 100644 --- a/crates/cdk-mintd/src/setup.rs +++ b/crates/cdk-mintd/src/setup.rs @@ -216,12 +216,14 @@ impl LnBackendSetup for config::FakeWallet { min_fee_reserve: self.reserve_fee_min, percent_fee_reserve: self.fee_percent, }; + // calculate + let delay_time = (self.min_delay_time + self.max_delay_time) / 2; let fake_wallet = cdk_fake_wallet::FakeWallet::new( fee_reserve, HashMap::default(), HashSet::default(), - 3, + delay_time, ); Ok(fake_wallet)