feat(nut04/nut05): mint and melt settings as objects

This commit is contained in:
thesimplekid
2024-03-20 23:16:09 +00:00
parent e964a13887
commit 69a0792e01
3 changed files with 41 additions and 5 deletions

View File

@@ -64,9 +64,22 @@ pub struct MintBolt11Response {
pub signatures: Vec<BlindedSignature>,
}
/// Mint Method Settings
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct MintMethodSettings {
/// Payment Method e.g. bolt11
method: PaymentMethod,
/// Currency Unit e.g. sat
unit: CurrencyUnit,
/// Min Amount
min_amount: Amount,
/// Max Amount
max_amount: Amount,
}
/// Mint Settings
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Settings {
methods: Vec<(PaymentMethod, CurrencyUnit)>,
methods: Vec<MintMethodSettings>,
disabled: bool,
}

View File

@@ -3,7 +3,7 @@
use serde::{Deserialize, Serialize};
use super::CurrencyUnit;
use super::{CurrencyUnit, PaymentMethod};
use crate::nuts::Proofs;
use crate::types::MeltQuote;
use crate::{Amount, Bolt11Invoice};
@@ -68,8 +68,21 @@ pub struct MeltBolt11Response {
pub payment_preimage: Option<String>,
}
/// Melt Method Settings
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct MeltMethodSettings {
/// Payment Method e.g. bolt11
method: PaymentMethod,
/// Currency Unit e.g. sat
unit: CurrencyUnit,
/// Min Amount
min_amount: Amount,
/// Max Amount
max_amount: Amount,
}
/// Melt Settings
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Settings {
methods: Vec<(String, CurrencyUnit)>,
methods: Vec<MeltMethodSettings>,
}

View File

@@ -142,13 +142,23 @@ mod tests {
"nuts": {
"4": {
"methods": [
["bolt11", "sat"]
{
"method": "bolt11",
"unit": "sat",
"min_amount": 0,
"max_amount": 10000
}
],
"disabled": false
},
"5": {
"methods": [
["bolt11", "sat"]
{
"method": "bolt11",
"unit": "sat",
"min_amount": 0,
"max_amount": 10000
}
]
},
"7": {"supported": true},