|
|
@@ -4,8 +4,10 @@ use serde::{Deserialize, Serialize};
|
|
|
|
|
|
use super::PublicKey;
|
|
|
use crate::nut00::KnownMethod;
|
|
|
+use crate::nut25::MeltQuoteBolt12Response;
|
|
|
use crate::nuts::{
|
|
|
- CurrencyUnit, MeltQuoteBolt11Response, MintQuoteBolt11Response, PaymentMethod, ProofState,
|
|
|
+ CurrencyUnit, MeltQuoteBolt11Response, MeltQuoteCustomResponse, MintQuoteBolt11Response,
|
|
|
+ MintQuoteCustomResponse, PaymentMethod, ProofState,
|
|
|
};
|
|
|
use crate::quote_id::QuoteIdError;
|
|
|
use crate::MintQuoteBolt12Response;
|
|
|
@@ -175,6 +177,15 @@ where
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl<T> From<MeltQuoteBolt12Response<T>> for NotificationPayload<T>
|
|
|
+where
|
|
|
+ T: Clone,
|
|
|
+{
|
|
|
+ fn from(melt_quote: MeltQuoteBolt12Response<T>) -> NotificationPayload<T> {
|
|
|
+ NotificationPayload::MeltQuoteBolt12Response(melt_quote)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
#[serde(bound = "T: Serialize + DeserializeOwned")]
|
|
|
#[serde(untagged)]
|
|
|
@@ -191,6 +202,12 @@ where
|
|
|
MintQuoteBolt11Response(MintQuoteBolt11Response<T>),
|
|
|
/// Mint Quote Bolt12 Response
|
|
|
MintQuoteBolt12Response(MintQuoteBolt12Response<T>),
|
|
|
+ /// Melt Quote Bolt12 Response
|
|
|
+ MeltQuoteBolt12Response(MeltQuoteBolt12Response<T>),
|
|
|
+ /// Custom Mint Quote Response (method, response)
|
|
|
+ CustomMintQuoteResponse(String, MintQuoteCustomResponse<T>),
|
|
|
+ /// Custom Melt Quote Response (method, response)
|
|
|
+ CustomMeltQuoteResponse(String, MeltQuoteCustomResponse<T>),
|
|
|
}
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Hash, Serialize)]
|
|
|
@@ -210,11 +227,14 @@ where
|
|
|
MintQuoteBolt12(T),
|
|
|
/// MintQuote id is an QuoteId
|
|
|
MeltQuoteBolt12(T),
|
|
|
+ /// MintQuote id is an QuoteId
|
|
|
+ MintQuoteCustom(String, T),
|
|
|
+ /// MintQuote id is an QuoteId
|
|
|
+ MeltQuoteCustom(String, T),
|
|
|
}
|
|
|
|
|
|
/// Kind
|
|
|
-#[derive(Debug, Clone, Copy, Eq, Ord, PartialOrd, PartialEq, Hash, Serialize, Deserialize)]
|
|
|
-#[serde(rename_all = "snake_case")]
|
|
|
+#[derive(Debug, Clone, Eq, Ord, PartialOrd, PartialEq, Hash)]
|
|
|
pub enum Kind {
|
|
|
/// Bolt 11 Melt Quote
|
|
|
Bolt11MeltQuote,
|
|
|
@@ -224,6 +244,44 @@ pub enum Kind {
|
|
|
ProofState,
|
|
|
/// Bolt 12 Mint Quote
|
|
|
Bolt12MintQuote,
|
|
|
+ /// Bolt 12 Melt Quote
|
|
|
+ Bolt12MeltQuote,
|
|
|
+ /// Custom
|
|
|
+ Custom(String),
|
|
|
+}
|
|
|
+
|
|
|
+impl Serialize for Kind {
|
|
|
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
+ where
|
|
|
+ S: serde::Serializer,
|
|
|
+ {
|
|
|
+ let s = match self {
|
|
|
+ Kind::Bolt11MintQuote => "bolt11_mint_quote",
|
|
|
+ Kind::Bolt11MeltQuote => "bolt11_melt_quote",
|
|
|
+ Kind::Bolt12MintQuote => "bolt12_mint_quote",
|
|
|
+ Kind::Bolt12MeltQuote => "bolt12_melt_quote",
|
|
|
+ Kind::ProofState => "proof_state",
|
|
|
+ Kind::Custom(custom) => custom.as_str(),
|
|
|
+ };
|
|
|
+ serializer.serialize_str(s)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl<'de> Deserialize<'de> for Kind {
|
|
|
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
+ where
|
|
|
+ D: serde::Deserializer<'de>,
|
|
|
+ {
|
|
|
+ let s = String::deserialize(deserializer)?;
|
|
|
+ Ok(match s.as_str() {
|
|
|
+ "bolt11_mint_quote" => Kind::Bolt11MintQuote,
|
|
|
+ "bolt11_melt_quote" => Kind::Bolt11MeltQuote,
|
|
|
+ "bolt12_mint_quote" => Kind::Bolt12MintQuote,
|
|
|
+ "bolt12_melt_quote" => Kind::Bolt12MeltQuote,
|
|
|
+ "proof_state" => Kind::ProofState,
|
|
|
+ custom => Kind::Custom(custom.to_string()),
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl<I> AsRef<I> for Params<I> {
|