Skip to content

Commit

Permalink
feat: payment request payload
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Oct 22, 2024
1 parent 721fefd commit fd8b29c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/cdk/src/nuts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ pub use nut11::{Conditions, P2PKWitness, SigFlag, SpendingConditions};
pub use nut12::{BlindSignatureDleq, ProofDleq};
pub use nut14::HTLCWitness;
pub use nut15::{Mpp, MppMethodSettings, Settings as NUT15Settings};
pub use nut18::{PaymentRequest, Transport};
pub use nut18::{PaymentRequest, PaymentRequestPayload, Transport};
23 changes: 19 additions & 4 deletions crates/cdk/src/nuts/nut18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use thiserror::Error;

use crate::{mint_url::MintUrl, Amount};

use super::CurrencyUnit;
use super::{CurrencyUnit, Proofs};

const PAYMENT_REQUEST_PREFIX: &str = "creqA";

Expand All @@ -33,7 +33,7 @@ pub enum Error {
}

/// Transport Type
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum TransportType {
/// Nostr
#[serde(rename = "nostr")]
Expand All @@ -58,7 +58,7 @@ impl FromStr for Transport {
}

/// Transport
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct Transport {
/// Type
#[serde(rename = "t")]
Expand All @@ -72,7 +72,7 @@ pub struct Transport {
}

/// Payment Request
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaymentRequest {
/// `Payment id`
#[serde(rename = "i")]
Expand Down Expand Up @@ -123,6 +123,21 @@ impl FromStr for PaymentRequest {
}
}

/// Payment Request
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaymentRequestPayload {
/// Id
pub id: Option<String>,
/// Memo
pub memo: Option<String>,
/// Mint
pub mint: MintUrl,
/// Unit
pub unit: CurrencyUnit,
/// Proofs
pub proofs: Proofs,
}

#[cfg(test)]
mod tests {
use std::str::FromStr;
Expand Down

0 comments on commit fd8b29c

Please sign in to comment.