refactor: remove duplicate NUT08 struct

This commit is contained in:
thesimplekid
2024-03-31 23:24:33 +01:00
parent 57f4090be2
commit 34908cfd88
3 changed files with 13 additions and 31 deletions

View File

@@ -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")]

View File

@@ -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

View File

@@ -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