Skip to content

Commit

Permalink
chore: rename btc-onchain to nut-17/nut-18
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Mar 29, 2024
1 parent 29a3c99 commit b9424c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions moksha-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async fn main() -> anyhow::Result<()> {
Command::PayOnchain { address, amount } => {
let info = wallet.get_mint_info().await?;

if info.nuts.nut15.map_or(true, |nut15| !nut15.supported) {
if info.nuts.nut18.map_or(true, |nut18| !nut18.supported) {
println!("Error: onchain-payments are not supported by this mint");
return Ok(());
}
Expand Down Expand Up @@ -207,13 +207,13 @@ async fn main() -> anyhow::Result<()> {
Command::Mint { amount } => {
let info = wallet.get_mint_info().await?;

let payment_method = info.nuts.nut14.as_ref().map_or_else(
let payment_method = info.nuts.nut17.as_ref().map_or_else(
|| {
println!("Only bolt11 minting is supported");
PaymentMethod::Bolt11
},
|nut14| {
if !nut14.supported {
|nut17| {
if !nut17.supported {
println!("Only bolt11 minting is supported");
PaymentMethod::Bolt11
} else {
Expand All @@ -232,8 +232,8 @@ async fn main() -> anyhow::Result<()> {

let quote = match payment_method {
PaymentMethod::BtcOnchain => {
let nut14 = info.nuts.nut14.expect("nut14 is None");
let payment_method = nut14.payment_methods.first().expect("no payment methods");
let nut17 = info.nuts.nut17.expect("nut17 is None");
let payment_method = nut17.payment_methods.first().expect("no payment methods");
if amount < payment_method.min_amount {
println!(
"Amount too low. Minimum amount is {} (sat)",
Expand Down
18 changes: 9 additions & 9 deletions moksha-core/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ pub struct Nuts {
/// DLEQ proofs
pub nut12: Nut12,

// TODO remove this if nut-14 and nut-15 are merged
#[serde(rename = "14", skip_serializing_if = "Option::is_none")]
// TODO remove this if nut-17 and nut-18 are merged
#[serde(rename = "17", skip_serializing_if = "Option::is_none")]
/// minting tokens onchain
pub nut14: Option<Nut14>,
pub nut17: Option<Nut17>,

#[serde(rename = "15", skip_serializing_if = "Option::is_none")]
#[serde(rename = "18", skip_serializing_if = "Option::is_none")]
/// melting tokens onchain
pub nut15: Option<Nut15>,
pub nut18: Option<Nut18>,
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
Expand Down Expand Up @@ -510,7 +510,7 @@ pub struct Nut12 {
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
pub struct Nut14 {
pub struct Nut17 {
pub supported: bool,
#[serde(rename = "methods")]
pub payment_methods: Vec<PaymentMethodConfigBtcOnchain>,
Expand All @@ -534,7 +534,7 @@ pub struct PaymentMethodConfigBtcOnchain {
pub max_amount: u64,
}

impl Default for Nut14 {
impl Default for Nut17 {
fn default() -> Self {
Self {
supported: true,
Expand All @@ -549,13 +549,13 @@ impl Default for Nut14 {
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, ToSchema)]
pub struct Nut15 {
pub struct Nut18 {
pub supported: bool,
#[serde(rename = "methods")]
pub payment_methods: Vec<PaymentMethodConfigBtcOnchain>,
}

impl Default for Nut15 {
impl Default for Nut18 {
fn default() -> Self {
Self {
supported: true,
Expand Down
6 changes: 3 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::{
CurrencyUnit, Nut14, Nut15, PaymentMethod, PaymentMethodConfigBtcOnchain,
CurrencyUnit, Nut17, Nut18, PaymentMethod, PaymentMethodConfigBtcOnchain,
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -209,7 +209,7 @@ impl FromStr for BtcOnchainTypeVariant {
}
}

impl From<BtcOnchainConfig> for Nut14 {
impl From<BtcOnchainConfig> for Nut17 {
fn from(settings: BtcOnchainConfig) -> Self {
Self {
supported: true,
Expand All @@ -223,7 +223,7 @@ impl From<BtcOnchainConfig> for Nut14 {
}
}

impl From<BtcOnchainConfig> for Nut15 {
impl From<BtcOnchainConfig> for Nut18 {
fn from(settings: BtcOnchainConfig) -> Self {
Self {
supported: true,
Expand Down
4 changes: 2 additions & 2 deletions moksha-mint/src/routes/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ fn get_nuts(cfg: &MintConfig) -> Nuts {
let default_config = BtcOnchainConfig::default();
let config = cfg.btconchain_backend.as_ref().unwrap_or(&default_config);
Nuts {
nut14: Some(config.to_owned().into()),
nut15: Some(config.to_owned().into()),
nut17: Some(config.to_owned().into()),
nut18: Some(config.to_owned().into()),
..Nuts::default()
}
}
6 changes: 3 additions & 3 deletions moksha-mint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use moksha_core::blind::BlindedMessage;
use moksha_core::blind::BlindedSignature;
use moksha_core::primitives::{
CurrencyUnit, GetMeltOnchainResponse, KeyResponse, KeysResponse, MintInfoResponse,
MintLegacyInfoResponse, Nut10, Nut11, Nut12, Nut14, Nut15, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts,
MintLegacyInfoResponse, Nut10, Nut11, Nut12, Nut17, Nut18, Nut4, Nut5, Nut7, Nut8, Nut9, Nuts,
PaymentMethod, PostMeltBolt11Request, PostMeltBolt11Response, PostMeltQuoteBolt11Request,
PostMeltQuoteBolt11Response, PostMeltQuoteOnchainRequest, PostMeltQuoteOnchainResponse,
PostMintBolt11Request, PostMintBolt11Response, PostMintQuoteBolt11Request,
Expand Down Expand Up @@ -151,8 +151,8 @@ pub async fn run_server(mint: Mint) -> anyhow::Result<()> {
PostSwapRequest,
PostSwapResponse,
P2SHScript,
Nut14,
Nut15,
Nut17,
Nut18,
PostMintQuoteOnchainRequest,
PostMintQuoteOnchainResponse,
PostMeltQuoteOnchainRequest,
Expand Down

0 comments on commit b9424c1

Please sign in to comment.