Skip to content

Commit

Permalink
Merge pull request #539 from thesimplekid/multiple_limts
Browse files Browse the repository at this point in the history
fix: extra mint/melt info limits
  • Loading branch information
thesimplekid authored Jan 16, 2025
2 parents 411ba61 + b86d42b commit 0180215
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 37 deletions.
19 changes: 1 addition & 18 deletions crates/cashu/src/nuts/nut04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}
}
18 changes: 1 addition & 17 deletions crates/cashu/src/nuts/nut05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,27 +402,11 @@ 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
pub methods: Vec<MeltMethodSettings>,
/// 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,
}
}
}
2 changes: 1 addition & 1 deletion crates/cdk-integration-tests/src/init_fake_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);

Expand Down
2 changes: 1 addition & 1 deletion crates/cdk-integration-tests/src/init_regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);

Expand Down
12 changes: 12 additions & 0 deletions crates/cdk/src/mint/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}

0 comments on commit 0180215

Please sign in to comment.