diff --git a/moksha-core/src/fixtures/nutshell_mint_info.json b/moksha-core/src/fixtures/nutshell_mint_info.json index 2dd356fc..4711bf05 100644 --- a/moksha-core/src/fixtures/nutshell_mint_info.json +++ b/moksha-core/src/fixtures/nutshell_mint_info.json @@ -11,8 +11,28 @@ ], "motd": "Message to users", "nuts": { - "4": { "methods": [["bolt11", "sat"]], "disabled": false }, - "5": { "methods": [["bolt11", "sat"]], "disabled": false }, + "4": { + "methods": [ + { + "method": "bolt11", + "unit": "sat", + "min_amount": 1, + "max_amount": 21 + } + ], + "disabled": false + }, + "5": { + "methods": [ + { + "method": "bolt11", + "unit": "sat", + "min_amount": 1, + "max_amount": 42 + } + ], + "disabled": false + }, "7": { "supported": true }, "8": { "supported": true }, "9": { "supported": true }, diff --git a/moksha-core/src/primitives.rs b/moksha-core/src/primitives.rs index 28916719..98bd7bad 100644 --- a/moksha-core/src/primitives.rs +++ b/moksha-core/src/primitives.rs @@ -423,14 +423,20 @@ pub struct Nuts { #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] pub struct Nut4 { - pub methods: Vec<(PaymentMethod, CurrencyUnit)>, + #[serde(rename = "methods")] + pub payment_methods: Vec, pub disabled: bool, } impl Default for Nut4 { fn default() -> Self { Self { - methods: vec![(PaymentMethod::Bolt11, CurrencyUnit::Sat)], + payment_methods: vec![PaymentMethodConfig { + payment_method: PaymentMethod::Bolt11, + unit: CurrencyUnit::Sat, + min_amount: Some(1), + max_amount: Some(10_000_000), + }], disabled: false, } } @@ -438,13 +444,21 @@ impl Default for Nut4 { #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] pub struct Nut5 { - pub methods: Vec<(PaymentMethod, CurrencyUnit)>, + #[serde(rename = "methods")] + pub payment_methods: Vec, + pub disabled: bool, } impl Default for Nut5 { fn default() -> Self { Self { - methods: vec![(PaymentMethod::Bolt11, CurrencyUnit::Sat)], + payment_methods: vec![PaymentMethodConfig { + payment_method: PaymentMethod::Bolt11, + unit: CurrencyUnit::Sat, + min_amount: Some(1), + max_amount: Some(10_000_000), + }], + disabled: false, } } } @@ -489,11 +503,21 @@ pub struct Nut12 { pub struct Nut14 { pub supported: bool, #[serde(rename = "methods")] - pub payment_methods: Vec, + pub payment_methods: Vec, } #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] pub struct PaymentMethodConfig { + #[serde(rename = "method")] + pub payment_method: PaymentMethod, + pub unit: CurrencyUnit, + pub min_amount: Option, + pub max_amount: Option, +} + +#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)] +pub struct PaymentMethodConfigBtcOnchain { + #[serde(rename = "method")] pub payment_method: PaymentMethod, pub unit: CurrencyUnit, pub min_amount: u64, @@ -504,7 +528,7 @@ impl Default for Nut14 { fn default() -> Self { Self { supported: true, - payment_methods: vec![PaymentMethodConfig { + payment_methods: vec![PaymentMethodConfigBtcOnchain { payment_method: PaymentMethod::BtcOnchain, unit: CurrencyUnit::Sat, min_amount: 1_000, @@ -518,14 +542,14 @@ impl Default for Nut14 { pub struct Nut15 { pub supported: bool, #[serde(rename = "methods")] - pub payment_methods: Vec, + pub payment_methods: Vec, } impl Default for Nut15 { fn default() -> Self { Self { supported: true, - payment_methods: vec![PaymentMethodConfig { + payment_methods: vec![PaymentMethodConfigBtcOnchain { payment_method: PaymentMethod::BtcOnchain, unit: CurrencyUnit::Sat, min_amount: 1_000, diff --git a/moksha-mint/src/config.rs b/moksha-mint/src/config.rs index bf8c3537..15420a3f 100644 --- a/moksha-mint/src/config.rs +++ b/moksha-mint/src/config.rs @@ -1,7 +1,9 @@ use std::{env, net::SocketAddr, path::PathBuf, str::FromStr}; use clap::Parser; -use moksha_core::primitives::{CurrencyUnit, Nut14, Nut15, PaymentMethod, PaymentMethodConfig}; +use moksha_core::primitives::{ + CurrencyUnit, Nut14, Nut15, PaymentMethod, PaymentMethodConfigBtcOnchain, +}; use serde::{Deserialize, Serialize}; use crate::lightning::{ @@ -211,7 +213,7 @@ impl From for Nut14 { fn from(settings: BtcOnchainConfig) -> Self { Self { supported: true, - payment_methods: vec![PaymentMethodConfig { + payment_methods: vec![PaymentMethodConfigBtcOnchain { payment_method: PaymentMethod::BtcOnchain, unit: CurrencyUnit::Sat, min_amount: settings.min_amount, @@ -225,7 +227,7 @@ impl From for Nut15 { fn from(settings: BtcOnchainConfig) -> Self { Self { supported: true, - payment_methods: vec![PaymentMethodConfig { + payment_methods: vec![PaymentMethodConfigBtcOnchain { payment_method: PaymentMethod::BtcOnchain, unit: CurrencyUnit::Sat, min_amount: settings.min_amount,