bindings/cashu-sdk add fee reserve arguments

This commit is contained in:
thesimplekid
2023-09-10 19:36:48 +01:00
parent 06ffef6db5
commit 8e0327eb31
5 changed files with 29 additions and 3 deletions

View File

@@ -325,7 +325,7 @@ interface Wallet {
interface Mint {
[Throws=CashuSdkError]
constructor(string secret, string derivation_path, record<string, MintKeySet> inactive_keysets, sequence<Secret> spent_secrets, u8 max_order);
constructor(string secret, string derivation_path, record<string, MintKeySet> inactive_keysets, sequence<Secret> spent_secrets, u8 max_order, Amount min_fee_reserve, f32 percent_fee_reserve);
KeySet active_keyset_pubkeys();
KeySetResponse keysets();
MintKeySet active_keyset();

View File

@@ -17,7 +17,7 @@ mod ffi {
pub use crate::client::Client;
pub use crate::error::CashuSdkError;
pub use crate::mint::Mint;
pub use crate::types::{Melted, ProofsStatus, SendProofs};
pub use crate::types::{FeeReserve, Melted, ProofsStatus, SendProofs};
pub use crate::wallet::Wallet;
// UDL

View File

@@ -7,8 +7,9 @@ use std::{
use cashu_sdk::mint::Mint as MintSdk;
use cashu_sdk::nuts::nut02::Id as IdSdk;
use fee_reserve::FeeReserve;
use crate::error::Result;
use crate::{error::Result, types::fee_reserve};
use cashu_ffi::{
Amount, CheckSpendableRequest, CheckSpendableResponse, Id, KeySet, KeySetResponse, MeltRequest,
MeltResponse, MintKeySet, MintRequest, PostMintResponse, Proof, Secret, SplitRequest,
@@ -26,6 +27,8 @@ impl Mint {
inactive_keysets: HashMap<String, Arc<MintKeySet>>,
spent_secrets: Vec<Arc<Secret>>,
max_order: u8,
min_fee_reserve: Arc<Amount>,
percent_fee_reserve: f32,
) -> Result<Self> {
let spent_secrets = spent_secrets
.into_iter()
@@ -47,6 +50,8 @@ impl Mint {
inactive_keysets,
spent_secrets,
max_order,
*min_fee_reserve.as_ref().deref(),
percent_fee_reserve,
)
.into(),
})

View File

@@ -0,0 +1,19 @@
use std::{ops::Deref, sync::Arc};
use cashu_ffi::Amount;
use cashu_sdk::mint::FeeReserve as FeeReserveSdk;
pub struct FeeReserve {
inner: FeeReserveSdk,
}
impl FeeReserve {
pub fn new(min_fee_reserve: Arc<Amount>, percent_fee_reserve: f32) -> Self {
Self {
inner: FeeReserveSdk {
min_fee_reserve: *min_fee_reserve.as_ref().deref(),
percent_fee_reserve,
},
}
}
}

View File

@@ -1,7 +1,9 @@
pub mod fee_reserve;
pub mod melted;
pub mod proofs_status;
pub mod send_proofs;
pub use fee_reserve::FeeReserve;
pub use melted::Melted;
pub use proofs_status::ProofsStatus;
pub use send_proofs::SendProofs;