mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-25 16:44:46 +01:00
invoice and amount type
This commit is contained in:
@@ -8,6 +8,8 @@ members = ["integration_test"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
bitcoin = { version = "0.30.0", features=["serde"] }
|
||||
lightning-invoice = { version = "0.22.0", features=["serde"] }
|
||||
minreq = { version = "2.7.0", features = ["json-using-serde", "https"] }
|
||||
serde = { version = "1.0.160", features = ["derive"]}
|
||||
thiserror = "1.0.40"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use lightning_invoice::Invoice;
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
@@ -60,12 +61,10 @@ impl CashuMint {
|
||||
}
|
||||
|
||||
/// Check Max expected fee [NUT-05]
|
||||
pub async fn check_fees(&self, invoice: &str) -> Result<CheckFeesResponse, Error> {
|
||||
pub async fn check_fees(&self, invoice: Invoice) -> Result<CheckFeesResponse, Error> {
|
||||
let url = self.url.join("checkfees")?;
|
||||
|
||||
let request = CheckFeesRequest {
|
||||
pr: invoice.to_string(),
|
||||
};
|
||||
let request = CheckFeesRequest { pr: invoice };
|
||||
|
||||
Ok(minreq::post(url)
|
||||
.with_json(&request)?
|
||||
@@ -78,14 +77,14 @@ impl CashuMint {
|
||||
pub async fn melt(
|
||||
&self,
|
||||
proofs: Vec<Proof>,
|
||||
invoice: &str,
|
||||
invoice: Invoice,
|
||||
outputs: Option<Vec<BlindedMessage>>,
|
||||
) -> Result<MeltResposne, Error> {
|
||||
let url = self.url.join("melt")?;
|
||||
|
||||
let request = MeltRequest {
|
||||
proofs,
|
||||
pr: invoice.to_string(),
|
||||
pr: invoice,
|
||||
outputs,
|
||||
};
|
||||
|
||||
|
||||
12
src/types.rs
12
src/types.rs
@@ -2,6 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use bitcoin::Amount;
|
||||
use lightning_invoice::Invoice;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// Blinded Message [NUT-00]
|
||||
@@ -18,8 +20,8 @@ pub struct BlindedMessage {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Promise {
|
||||
pub id: String,
|
||||
/// Amount in satoshi
|
||||
pub amount: u64,
|
||||
#[serde(with = "bitcoin::amount::serde::as_sat")]
|
||||
pub amount: Amount,
|
||||
/// blinded signature (C_) on the secret message `B_` of [BlindedMessage]
|
||||
#[serde(rename = "C_")]
|
||||
pub c: String,
|
||||
@@ -56,7 +58,7 @@ pub struct MintKeySets {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct RequestMintResponse {
|
||||
/// Bolt11 payment request
|
||||
pub pr: String,
|
||||
pub pr: Invoice,
|
||||
/// Hash of Invoice
|
||||
pub hash: String,
|
||||
}
|
||||
@@ -84,7 +86,7 @@ pub struct CheckFeesResponse {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CheckFeesRequest {
|
||||
/// Lighting Invoice
|
||||
pub pr: String,
|
||||
pub pr: Invoice,
|
||||
}
|
||||
|
||||
/// Melt Request [NUT-05]
|
||||
@@ -92,7 +94,7 @@ pub struct CheckFeesRequest {
|
||||
pub struct MeltRequest {
|
||||
pub proofs: Vec<Proof>,
|
||||
/// bollt11
|
||||
pub pr: String,
|
||||
pub pr: Invoice,
|
||||
/// Blinded Message that can be used to return change [NUT-08]
|
||||
/// Amount feild of blindedMessages `SHOULD` be set to zero
|
||||
pub outputs: Option<Vec<BlindedMessage>>,
|
||||
|
||||
Reference in New Issue
Block a user