Browse Source

`bindings:` add `MintKeySet`

thesimplekid 1 year ago
parent
commit
2edce622ae

+ 5 - 0
bindings/cashu-ffi/src/cashu.udl

@@ -118,6 +118,11 @@ interface KeySet {
 	Keys keys();
 };
 
+interface MintKeySet {
+	[Name=generate]
+	constructor(string secret, string derivation_path, u8 max_order);
+};
+
 interface KeySetResponse {
 	constructor(sequence<string> keyset_ids);
 	sequence<string> keyset_ids();

+ 1 - 1
bindings/cashu-ffi/src/lib.rs

@@ -14,7 +14,7 @@ mod ffi {
     pub use crate::nuts::nut01::keys::Keys;
     pub use crate::nuts::nut01::public_key::PublicKey;
     pub use crate::nuts::nut01::secret_key::SecretKey;
-    pub use crate::nuts::nut02::key_set::{KeySet, KeySetResponse};
+    pub use crate::nuts::nut02::{KeySet, KeySetResponse, MintKeySet};
     pub use crate::nuts::nut03::RequestMintResponse;
     pub use crate::nuts::nut04::{MintRequest, PostMintResponse};
     pub use crate::nuts::nut05::{

+ 22 - 0
bindings/cashu-ffi/src/nuts/nut02/mint_keyset.rs

@@ -0,0 +1,22 @@
+use std::ops::Deref;
+
+use cashu::nuts::nut02::mint::KeySet as KeySetSdk;
+
+pub struct MintKeySet {
+    inner: KeySetSdk,
+}
+
+impl Deref for MintKeySet {
+    type Target = KeySetSdk;
+    fn deref(&self) -> &Self::Target {
+        &self.inner
+    }
+}
+
+impl MintKeySet {
+    pub fn generate(secret: String, derivation_path: String, max_order: u8) -> Self {
+        Self {
+            inner: KeySetSdk::generate(secret, derivation_path, max_order),
+        }
+    }
+}

+ 4 - 0
bindings/cashu-ffi/src/nuts/nut02/mod.rs

@@ -1 +1,5 @@
 pub mod key_set;
+pub mod mint_keyset;
+
+pub use key_set::{KeySet, KeySetResponse};
+pub use mint_keyset::MintKeySet;

+ 6 - 0
bindings/cashu-sdk-ffi/src/cashu_sdk.udl

@@ -121,6 +121,12 @@ interface KeySet {
 	Keys keys();
 };
 
+
+interface MintKeySet {
+	[Name=generate]
+	constructor(string secret, string derivation_path, u8 max_order);
+};
+
 interface KeySetResponse {
 	constructor(sequence<string> keyset_ids);
 	sequence<string> keyset_ids();

+ 5 - 3
bindings/cashu-sdk-ffi/src/lib.rs

@@ -1,5 +1,6 @@
 mod client;
 mod error;
+mod mint;
 mod types;
 mod wallet;
 
@@ -8,13 +9,14 @@ mod ffi {
         Amount, BlindedMessage, BlindedMessages, BlindedSignature, Bolt11Invoice, CashuError,
         CheckFeesRequest, CheckFeesResponse, CheckSpendableRequest, CheckSpendableResponse,
         InvoiceStatus, KeyPair, KeySet, KeySetResponse, Keys, MeltRequest, MeltResponse, MintInfo,
-        MintProof, MintProofs, MintRequest, MintVersion, Nut05MeltRequest, Nut05MeltResponse,
-        PostMintResponse, Proof, PublicKey, RequestMintResponse, SecretKey, SplitRequest,
-        SplitResponse, Token,
+        MintKeySet, MintProof, MintProofs, MintRequest, MintVersion, Nut05MeltRequest,
+        Nut05MeltResponse, PostMintResponse, Proof, PublicKey, RequestMintResponse, SecretKey,
+        SplitRequest, SplitResponse, Token,
     };
 
     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::wallet::Wallet;