Merge pull request #539 from thesimplekid/multiple_limts

fix: extra mint/melt info limits
This commit is contained in:
thesimplekid
2025-01-16 11:46:17 +00:00
committed by GitHub
5 changed files with 16 additions and 37 deletions

View File

@@ -211,7 +211,7 @@ pub struct MintMethodSettings {
}
/// Mint Settings
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = nut04::Settings))]
pub struct Settings {
/// Methods to mint
@@ -241,20 +241,3 @@ impl Settings {
None
}
}
impl Default for Settings {
fn default() -> Self {
let bolt11_mint = MintMethodSettings {
method: PaymentMethod::Bolt11,
unit: CurrencyUnit::Sat,
min_amount: Some(Amount::from(1)),
max_amount: Some(Amount::from(1000000)),
description: true,
};
Settings {
methods: vec![bolt11_mint],
disabled: false,
}
}
}

View File

@@ -402,7 +402,7 @@ impl Settings {
}
/// Melt Settings
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = nut05::Settings))]
pub struct Settings {
/// Methods to melt
@@ -410,19 +410,3 @@ pub struct Settings {
/// Minting disabled
pub disabled: bool,
}
impl Default for Settings {
fn default() -> Self {
let bolt11_mint = MeltMethodSettings {
method: PaymentMethod::Bolt11,
unit: CurrencyUnit::Sat,
min_amount: Some(Amount::from(1)),
max_amount: Some(Amount::from(1000000)),
};
Settings {
methods: vec![bolt11_mint],
disabled: false,
}
}
}

View File

@@ -42,7 +42,7 @@ where
mint_builder = mint_builder.add_ln_backend(
CurrencyUnit::Sat,
PaymentMethod::Bolt11,
MintMeltLimits::default(),
MintMeltLimits::new(1, 5_000),
Arc::new(fake_wallet),
);

View File

@@ -156,7 +156,7 @@ where
mint_builder = mint_builder.add_ln_backend(
CurrencyUnit::Sat,
PaymentMethod::Bolt11,
MintMeltLimits::default(),
MintMeltLimits::new(1, 5_000),
Arc::new(cln_backend),
);

View File

@@ -254,3 +254,15 @@ pub struct MintMeltLimits {
/// Max melt amount
pub melt_max: Amount,
}
impl MintMeltLimits {
/// Create new [`MintMeltLimits`]
pub fn new(min: u64, max: u64) -> Self {
Self {
mint_min: min.into(),
mint_max: max.into(),
melt_min: min.into(),
melt_max: max.into(),
}
}
}