Skip to content

Commit

Permalink
chore: add min-confirmations to info-endpoint
Browse files Browse the repository at this point in the history
fixes #312
  • Loading branch information
ngutech21 committed Jul 29, 2024
1 parent 285d895 commit e1a57b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
21 changes: 16 additions & 5 deletions moksha-core/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ pub struct Nut17 {
pub struct Nut18 {
pub supported: bool,
#[serde(rename = "methods")]
pub payment_methods: Vec<PaymentMethodConfigBtcOnchain>,
pub payment_methods: Vec<PaymentMethodConfigBtcOnchainMint>,
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
Expand All @@ -567,7 +567,17 @@ pub struct PaymentMethodConfig {
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
pub struct PaymentMethodConfigBtcOnchain {
pub struct PaymentMethodConfigBtcOnchainMint {
#[serde(rename = "method")]
pub payment_method: PaymentMethod,
pub unit: CurrencyUnit,
pub min_amount: u64,
pub max_amount: u64,
pub min_confirmations: u8,
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
pub struct PaymentMethodConfigBtcOnchainMelt {
#[serde(rename = "method")]
pub payment_method: PaymentMethod,
pub unit: CurrencyUnit,
Expand All @@ -579,11 +589,12 @@ impl Default for Nut18 {
fn default() -> Self {
Self {
supported: true,
payment_methods: vec![PaymentMethodConfigBtcOnchain {
payment_methods: vec![PaymentMethodConfigBtcOnchainMint {
payment_method: PaymentMethod::BtcOnchain,
unit: CurrencyUnit::Sat,
min_amount: 10_000,
max_amount: 1_000_000,
min_confirmations: 3,
}],
}
}
Expand All @@ -593,14 +604,14 @@ impl Default for Nut18 {
pub struct Nut19 {
pub supported: bool,
#[serde(rename = "methods")]
pub payment_methods: Vec<PaymentMethodConfigBtcOnchain>,
pub payment_methods: Vec<PaymentMethodConfigBtcOnchainMelt>,
}

impl Default for Nut19 {
fn default() -> Self {
Self {
supported: true,
payment_methods: vec![PaymentMethodConfigBtcOnchain {
payment_methods: vec![PaymentMethodConfigBtcOnchainMelt {
payment_method: PaymentMethod::BtcOnchain,
unit: CurrencyUnit::Sat,
min_amount: 10_000,
Expand Down
7 changes: 4 additions & 3 deletions moksha-mint/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{env, net::SocketAddr, path::PathBuf, str::FromStr};

use clap::Parser;
use moksha_core::primitives::{
ContactInfoResponse, CurrencyUnit, Nut18, Nut19, PaymentMethod, PaymentMethodConfigBtcOnchain,
ContactInfoResponse, CurrencyUnit, Nut18, Nut19, PaymentMethod, PaymentMethodConfigBtcOnchainMelt, PaymentMethodConfigBtcOnchainMint
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -213,11 +213,12 @@ impl From<BtcOnchainConfig> for Nut18 {
fn from(settings: BtcOnchainConfig) -> Self {
Self {
supported: true,
payment_methods: vec![PaymentMethodConfigBtcOnchain {
payment_methods: vec![PaymentMethodConfigBtcOnchainMint {
payment_method: PaymentMethod::BtcOnchain,
unit: CurrencyUnit::Sat,
min_amount: settings.min_amount,
max_amount: settings.max_amount,
min_confirmations: settings.min_confirmations,
}],
}
}
Expand All @@ -227,7 +228,7 @@ impl From<BtcOnchainConfig> for Nut19 {
fn from(settings: BtcOnchainConfig) -> Self {
Self {
supported: true,
payment_methods: vec![PaymentMethodConfigBtcOnchain {
payment_methods: vec![PaymentMethodConfigBtcOnchainMelt {
payment_method: PaymentMethod::BtcOnchain,
unit: CurrencyUnit::Sat,
min_amount: settings.min_amount,
Expand Down
20 changes: 12 additions & 8 deletions moksha-mint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ use crate::mint::Mint;
use moksha_core::blind::BlindedMessage;
use moksha_core::blind::BlindedSignature;
use moksha_core::primitives::{
CurrencyUnit, GetMeltBtcOnchainResponse, KeyResponse, KeysResponse, MintInfoResponse, Nut10,
Nut11, Nut12, Nut18, Nut19, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts, PaymentMethod,
PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request,
PostMeltQuoteBolt11Response, PostMeltQuoteBtcOnchainRequest, PostMeltQuoteBtcOnchainResponse,
PostMintBolt11Request, PostMintBolt11Response, PostMintQuoteBolt11Request,
PostMintQuoteBolt11Response, PostMintQuoteBtcOnchainRequest, PostMintQuoteBtcOnchainResponse,
PostSwapRequest, PostSwapResponse,
ContactInfoResponse, CurrencyUnit, GetMeltBtcOnchainResponse, KeyResponse, KeysResponse, MintInfoResponse, Nut10, Nut11, Nut12, Nut13, Nut14, Nut15, Nut16, Nut17, Nut18, Nut19, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts, PaymentMethod, PaymentMethodConfig, PaymentMethodConfigBtcOnchainMelt, PaymentMethodConfigBtcOnchainMint, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request, PostMeltQuoteBolt11Response, PostMeltQuoteBtcOnchainRequest, PostMeltQuoteBtcOnchainResponse, PostMintBolt11Request, PostMintBolt11Response, PostMintQuoteBolt11Request, PostMintQuoteBolt11Response, PostMintQuoteBtcOnchainRequest, PostMintQuoteBtcOnchainResponse, PostSwapRequest, PostSwapResponse
};

use tower_http::services::ServeDir;
Expand Down Expand Up @@ -123,6 +117,11 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> {
Nut10,
Nut11,
Nut12,
Nut13,
Nut14,
Nut15,
Nut16,
Nut17,
CurrencyUnit,
PaymentMethod,
KeysResponse,
Expand Down Expand Up @@ -150,7 +149,12 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> {
PostMintQuoteBtcOnchainResponse,
PostMeltQuoteBtcOnchainRequest,
PostMeltQuoteBtcOnchainResponse,
GetMeltBtcOnchainResponse
GetMeltBtcOnchainResponse,
ContactInfoResponse,
PaymentMethodConfig,
PaymentMethodConfigBtcOnchainMint,
PaymentMethodConfigBtcOnchainMelt
))
)]
struct ApiDoc;
Expand Down

0 comments on commit e1a57b2

Please sign in to comment.