mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-10 00:16:02 +01:00
refactor: remove duplicate NUT08 struct
This commit is contained in:
@@ -32,15 +32,13 @@ pub use nut03::{SwapRequest, SwapResponse};
|
||||
pub use nut04::{
|
||||
MintBolt11Request, MintBolt11Response, MintQuoteBolt11Request, MintQuoteBolt11Response,
|
||||
};
|
||||
#[cfg(not(feature = "nut08"))]
|
||||
pub use nut05::{MeltBolt11Request, MeltBolt11Response};
|
||||
pub use nut05::{MeltQuoteBolt11Request, MeltQuoteBolt11Response};
|
||||
pub use nut05::{
|
||||
MeltBolt11Request, MeltBolt11Response, MeltQuoteBolt11Request, MeltQuoteBolt11Response,
|
||||
};
|
||||
pub use nut06::{MintInfo, MintVersion, Nuts};
|
||||
#[cfg(feature = "wallet")]
|
||||
#[cfg(feature = "nut07")]
|
||||
pub use nut07::{CheckStateRequest, CheckStateResponse};
|
||||
#[cfg(feature = "nut08")]
|
||||
pub use nut08::{MeltBolt11Request, MeltBolt11Response};
|
||||
#[cfg(feature = "nut09")]
|
||||
pub use nut09::{RestoreRequest, RestoreResponse};
|
||||
#[cfg(feature = "nut10")]
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "nut08")]
|
||||
use super::{BlindSignature, BlindedMessage};
|
||||
use super::{CurrencyUnit, PaymentMethod};
|
||||
use crate::nuts::Proofs;
|
||||
use crate::types::MeltQuote;
|
||||
@@ -51,6 +53,10 @@ pub struct MeltBolt11Request {
|
||||
pub quote: String,
|
||||
/// Proofs
|
||||
pub inputs: Proofs,
|
||||
/// Blinded Message that can be used to return change [NUT-08]
|
||||
/// Amount field of BlindedMessages `SHOULD` be set to zero
|
||||
#[cfg(feature = "nut08")]
|
||||
pub outputs: Option<Vec<BlindedMessage>>,
|
||||
}
|
||||
|
||||
impl MeltBolt11Request {
|
||||
@@ -66,6 +72,9 @@ pub struct MeltBolt11Response {
|
||||
pub paid: bool,
|
||||
/// Bolt11 preimage
|
||||
pub payment_preimage: Option<String>,
|
||||
/// Change
|
||||
#[cfg(feature = "nut08")]
|
||||
pub change: Option<Vec<BlindSignature>>,
|
||||
}
|
||||
|
||||
/// Melt Method Settings
|
||||
|
||||
@@ -3,26 +3,10 @@
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{BlindSignature, BlindedMessage, Proofs};
|
||||
use super::{MeltBolt11Request, MeltBolt11Response};
|
||||
use crate::Amount;
|
||||
|
||||
/// Melt Bolt11 Request [NUT-08]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct MeltBolt11Request {
|
||||
/// Quote ID
|
||||
pub quote: String,
|
||||
/// Proofs
|
||||
pub inputs: Proofs,
|
||||
/// Blinded Message that can be used to return change [NUT-08]
|
||||
/// Amount field of BlindedMessages `SHOULD` be set to zero
|
||||
pub outputs: Option<Vec<BlindedMessage>>,
|
||||
}
|
||||
|
||||
impl MeltBolt11Request {
|
||||
pub fn proofs_amount(&self) -> Amount {
|
||||
self.inputs.iter().map(|proof| proof.amount).sum()
|
||||
}
|
||||
|
||||
pub fn output_amount(&self) -> Option<Amount> {
|
||||
self.outputs
|
||||
.as_ref()
|
||||
@@ -30,15 +14,6 @@ impl MeltBolt11Request {
|
||||
}
|
||||
}
|
||||
|
||||
/// Melt Response [NUT-08]
|
||||
/// Lightning fee return [NUT-08]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct MeltBolt11Response {
|
||||
pub paid: bool,
|
||||
pub payment_preimage: Option<String>,
|
||||
pub change: Option<Vec<BlindSignature>>,
|
||||
}
|
||||
|
||||
impl MeltBolt11Response {
|
||||
pub fn change_amount(&self) -> Option<Amount> {
|
||||
self.change
|
||||
|
||||
Reference in New Issue
Block a user