diff --git a/crates/cdk-axum/src/router_handlers.rs b/crates/cdk-axum/src/router_handlers.rs index 4d348b1e8..aec451bea 100644 --- a/crates/cdk-axum/src/router_handlers.rs +++ b/crates/cdk-axum/src/router_handlers.rs @@ -3,7 +3,6 @@ use axum::extract::{Json, Path, State}; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; use cdk::error::ErrorResponse; -use cdk::nuts::nut05::MeltBolt11Response; use cdk::nuts::{ CheckStateRequest, CheckStateResponse, Id, KeysResponse, KeysetResponse, MeltBolt11Request, MeltQuoteBolt11Request, MeltQuoteBolt11Response, MintBolt11Request, MintBolt11Response, @@ -121,7 +120,7 @@ pub async fn get_check_melt_bolt11_quote( pub async fn post_melt_bolt11( State(state): State, Json(payload): Json, -) -> Result, Response> { +) -> Result, Response> { let res = state .mint .melt_bolt11(&payload) diff --git a/crates/cdk/src/mint/melt.rs b/crates/cdk/src/mint/melt.rs index e3cd3fb82..a46452de2 100644 --- a/crates/cdk/src/mint/melt.rs +++ b/crates/cdk/src/mint/melt.rs @@ -16,7 +16,6 @@ use crate::{ Amount, Error, }; -use super::nut05::MeltBolt11Response; use super::{ CurrencyUnit, MeltBolt11Request, MeltQuote, MeltQuoteBolt11Request, MeltQuoteBolt11Response, Mint, PaymentMethod, PublicKey, State, @@ -397,7 +396,7 @@ impl Mint { pub async fn melt_bolt11( &self, melt_request: &MeltBolt11Request, - ) -> Result { + ) -> Result { use std::sync::Arc; async fn check_payment_state( ln: Arc + Send + Sync>, @@ -595,7 +594,7 @@ impl Mint { err })?; - Ok(res.into()) + Ok(res) } /// Process melt request marking [`Proofs`] as spent diff --git a/crates/cdk/src/nuts/nut05.rs b/crates/cdk/src/nuts/nut05.rs index 00a8f7082..c459341d8 100644 --- a/crates/cdk/src/nuts/nut05.rs +++ b/crates/cdk/src/nuts/nut05.rs @@ -227,28 +227,6 @@ impl MeltBolt11Request { } } -// TODO: to be deprecated -/// Melt Response [NUT-05] -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct MeltBolt11Response { - /// Indicate if payment was successful - pub paid: bool, - /// Bolt11 preimage - pub payment_preimage: Option, - /// Change - pub change: Option>, -} - -impl From for MeltBolt11Response { - fn from(quote_response: MeltQuoteBolt11Response) -> MeltBolt11Response { - MeltBolt11Response { - paid: quote_response.paid.unwrap(), - payment_preimage: quote_response.payment_preimage, - change: quote_response.change, - } - } -} - /// Melt Method Settings #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct MeltMethodSettings { diff --git a/crates/cdk/src/wallet/client.rs b/crates/cdk/src/wallet/client.rs index 143af9fb5..c99723a19 100644 --- a/crates/cdk/src/wallet/client.rs +++ b/crates/cdk/src/wallet/client.rs @@ -7,7 +7,6 @@ use url::Url; use super::Error; use crate::error::ErrorResponse; -use crate::nuts::nut05::MeltBolt11Response; use crate::nuts::nut15::Mpp; use crate::nuts::{ BlindedMessage, CheckStateRequest, CheckStateResponse, CurrencyUnit, Id, KeySet, KeysResponse, @@ -267,7 +266,7 @@ impl HttpClient { quote: String, inputs: Vec, outputs: Option>, - ) -> Result { + ) -> Result { let url = join_url(mint_url, &["v1", "melt", "bolt11"])?; let request = MeltBolt11Request { @@ -286,9 +285,9 @@ impl HttpClient { .await?; match serde_json::from_value::(res.clone()) { - Ok(melt_quote_response) => Ok(melt_quote_response.into()), + Ok(melt_quote_response) => Ok(melt_quote_response), Err(_) => { - if let Ok(res) = serde_json::from_value::(res.clone()) { + if let Ok(res) = serde_json::from_value::(res.clone()) { return Ok(res); } Err(ErrorResponse::from_value(res)?.into()) diff --git a/crates/cdk/src/wallet/melt.rs b/crates/cdk/src/wallet/melt.rs index 2bff1a831..c7217c287 100644 --- a/crates/cdk/src/wallet/melt.rs +++ b/crates/cdk/src/wallet/melt.rs @@ -5,10 +5,7 @@ use tracing::instrument; use crate::{ dhke::construct_proofs, - nuts::{ - CurrencyUnit, MeltQuoteBolt11Response, MeltQuoteState, PreMintSecrets, Proofs, PublicKey, - State, - }, + nuts::{CurrencyUnit, MeltQuoteBolt11Response, PreMintSecrets, Proofs, PublicKey, State}, types::{Melted, ProofInfo}, util::unix_time, Amount, Error, Wallet, @@ -204,13 +201,8 @@ impl Wallet { None => None, }; - let state = match melt_response.paid { - true => MeltQuoteState::Paid, - false => MeltQuoteState::Unpaid, - }; - let melted = Melted::from_proofs( - state, + melt_response.state, melt_response.payment_preimage, quote_info.amount, proofs.clone(),