mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-08 15:35:35 +01:00
refactor: some cashu-sdk-ffi to v1
This commit is contained in:
@@ -33,10 +33,6 @@ interface Secret {
|
||||
|
||||
// NUT00
|
||||
|
||||
interface Id {
|
||||
[Throws=CashuError]
|
||||
constructor(string id);
|
||||
};
|
||||
|
||||
interface PublicKey {
|
||||
[Throws=CashuError, Name=from_hex]
|
||||
@@ -112,6 +108,14 @@ interface PreMintSecrets {
|
||||
sequence<Amount> amounts();
|
||||
};
|
||||
|
||||
|
||||
// NUT-02
|
||||
|
||||
interface Id {
|
||||
[Throws=CashuError]
|
||||
constructor(string id);
|
||||
};
|
||||
|
||||
interface KeyPair {
|
||||
[Name=from_secret_key]
|
||||
constructor(SecretKey secret_key);
|
||||
@@ -137,7 +141,6 @@ interface MintKeySet {
|
||||
constructor(string secret, string unit, string derivation_path, u8 max_order);
|
||||
};
|
||||
|
||||
|
||||
interface KeysResponse {
|
||||
constructor(Keys keys);
|
||||
};
|
||||
@@ -147,14 +150,28 @@ interface KeySetResponse {
|
||||
sequence<KeySetInfo> keysets();
|
||||
};
|
||||
|
||||
// --- NUT-04
|
||||
// NUT-03
|
||||
|
||||
interface SwapRequest {
|
||||
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
|
||||
sequence<Proof> proofs();
|
||||
sequence<BlindedMessage> outputs();
|
||||
Amount proofs_amount();
|
||||
Amount output_amount();
|
||||
};
|
||||
|
||||
interface SwapResponse {
|
||||
constructor(sequence<BlindedSignature> promises);
|
||||
sequence<BlindedSignature> signatures();
|
||||
};
|
||||
|
||||
// NUT-04
|
||||
|
||||
interface MintQuoteBolt11Request {
|
||||
constructor(Amount amount, string unit);
|
||||
Amount amount();
|
||||
};
|
||||
|
||||
|
||||
interface MintQuoteBolt11Response {
|
||||
constructor(string quote, string request, boolean paid, u64 expiry);
|
||||
string quote();
|
||||
@@ -175,8 +192,6 @@ interface MintBolt11Response {
|
||||
sequence<BlindedSignature> signatures();
|
||||
};
|
||||
|
||||
// ---
|
||||
|
||||
// NUT-05
|
||||
|
||||
interface MeltQuoteBolt11Response {
|
||||
@@ -208,19 +223,20 @@ interface MeltBolt11Response {
|
||||
boolean paid();
|
||||
};
|
||||
|
||||
// ----
|
||||
interface SwapRequest {
|
||||
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
|
||||
sequence<Proof> proofs();
|
||||
sequence<BlindedMessage> outputs();
|
||||
Amount proofs_amount();
|
||||
Amount output_amount();
|
||||
// NUT-06
|
||||
|
||||
interface MintInfo {
|
||||
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
|
||||
string? name();
|
||||
PublicKey? pubkey();
|
||||
MintVersion? version();
|
||||
string? description();
|
||||
string? description_long();
|
||||
sequence<sequence<string>>? contact();
|
||||
string? motd();
|
||||
};
|
||||
|
||||
interface SwapResponse {
|
||||
constructor(sequence<BlindedSignature> promises);
|
||||
sequence<BlindedSignature> signatures();
|
||||
};
|
||||
// NUT-07
|
||||
|
||||
interface CheckSpendableRequest {
|
||||
constructor(sequence<MintProof> proofs);
|
||||
@@ -239,17 +255,6 @@ interface MintVersion {
|
||||
string version();
|
||||
};
|
||||
|
||||
interface MintInfo {
|
||||
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
|
||||
string? name();
|
||||
PublicKey? pubkey();
|
||||
MintVersion? version();
|
||||
string? description();
|
||||
string? description_long();
|
||||
sequence<sequence<string>>? contact();
|
||||
string? motd();
|
||||
};
|
||||
|
||||
interface KeySetInfo {
|
||||
constructor(Id id, string unit);
|
||||
|
||||
|
||||
@@ -25,6 +25,16 @@ impl From<&CurrencyUnit> for CurrencyUnitSdk {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CurrencyUnit> for CurrencyUnitSdk {
|
||||
fn from(unit: CurrencyUnit) -> CurrencyUnitSdk {
|
||||
match unit {
|
||||
CurrencyUnit::Sat() => CurrencyUnitSdk::Sat,
|
||||
CurrencyUnit::Usd() => CurrencyUnitSdk::Usd,
|
||||
CurrencyUnit::Custom { unit } => CurrencyUnitSdk::Custom(unit.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CurrencyUnitSdk> for CurrencyUnit {
|
||||
fn from(unit: CurrencyUnitSdk) -> CurrencyUnit {
|
||||
match unit {
|
||||
|
||||
@@ -160,3 +160,9 @@ impl MintBolt11Response {
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MintBolt11ResponseSdk> for MintBolt11Response {
|
||||
fn from(inner: MintBolt11ResponseSdk) -> MintBolt11Response {
|
||||
MintBolt11Response { inner }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ interface CashuError {
|
||||
};
|
||||
|
||||
|
||||
// Types
|
||||
|
||||
// Types
|
||||
|
||||
[Enum]
|
||||
interface CurrencyUnit {
|
||||
Sat();
|
||||
Usd();
|
||||
Custom(string unit);
|
||||
};
|
||||
|
||||
@@ -25,26 +25,17 @@ interface Bolt11Invoice {
|
||||
};
|
||||
|
||||
interface Amount {
|
||||
u64 to_sat();
|
||||
u64 to_msat();
|
||||
[Name = from_sat]
|
||||
constructor(u64 sat);
|
||||
[Name = from_msat]
|
||||
constructor(u64 msat);
|
||||
constructor(u64 amount);
|
||||
sequence<Amount> split();
|
||||
};
|
||||
|
||||
|
||||
interface Secret {
|
||||
constructor();
|
||||
sequence<u8> as_bytes();
|
||||
};
|
||||
|
||||
// NUT00
|
||||
|
||||
interface Id {
|
||||
[Throws=CashuError]
|
||||
constructor(string id);
|
||||
};
|
||||
|
||||
interface PublicKey {
|
||||
[Throws=CashuError, Name=from_hex]
|
||||
@@ -62,6 +53,7 @@ interface SecretKey {
|
||||
interface BlindedMessage {
|
||||
constructor(Id keyset_id, Amount amount, PublicKey b);
|
||||
Amount amount();
|
||||
Id keyset_id();
|
||||
PublicKey b();
|
||||
};
|
||||
|
||||
@@ -70,12 +62,12 @@ interface Proof {
|
||||
Amount amount();
|
||||
Secret secret();
|
||||
PublicKey c();
|
||||
Id id();
|
||||
};
|
||||
Id keyset_id();
|
||||
};
|
||||
|
||||
interface BlindedSignature {
|
||||
constructor(Id id, Amount amount, PublicKey c);
|
||||
Id id();
|
||||
constructor(Id keyset_id, Amount amount, PublicKey c);
|
||||
Id keyset_id();
|
||||
Amount amount();
|
||||
PublicKey c();
|
||||
};
|
||||
@@ -85,7 +77,7 @@ interface MintProof {
|
||||
Amount? amount();
|
||||
Secret secret();
|
||||
PublicKey? c();
|
||||
Id? id();
|
||||
Id? keyset_id();
|
||||
|
||||
};
|
||||
|
||||
@@ -98,10 +90,10 @@ interface MintProofs {
|
||||
|
||||
interface Token {
|
||||
[Throws=CashuError]
|
||||
constructor(string mint, sequence<Proof> token, string? memo, CurrencyUnit? unit);
|
||||
constructor(string mint, sequence<Proof> token, string? memo, string? unit);
|
||||
sequence<MintProofs> token();
|
||||
string? memo();
|
||||
CurrencyUnit? unit();
|
||||
string? unit();
|
||||
string to_string();
|
||||
[Throws=CashuError, Name=from_string]
|
||||
constructor(string token);
|
||||
@@ -119,6 +111,14 @@ interface PreMintSecrets {
|
||||
sequence<Amount> amounts();
|
||||
};
|
||||
|
||||
|
||||
// NUT-02
|
||||
|
||||
interface Id {
|
||||
[Throws=CashuError]
|
||||
constructor(string id);
|
||||
};
|
||||
|
||||
interface KeyPair {
|
||||
[Name=from_secret_key]
|
||||
constructor(SecretKey secret_key);
|
||||
@@ -139,13 +139,11 @@ interface KeySet {
|
||||
Keys keys();
|
||||
};
|
||||
|
||||
|
||||
interface MintKeySet {
|
||||
[Name=generate]
|
||||
constructor(string secret, string unit, string derivation_path, u8 max_order);
|
||||
};
|
||||
|
||||
|
||||
interface KeysResponse {
|
||||
constructor(Keys keys);
|
||||
};
|
||||
@@ -155,6 +153,48 @@ interface KeySetResponse {
|
||||
sequence<KeySetInfo> keysets();
|
||||
};
|
||||
|
||||
// NUT-03
|
||||
|
||||
interface SwapRequest {
|
||||
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
|
||||
sequence<Proof> proofs();
|
||||
sequence<BlindedMessage> outputs();
|
||||
Amount proofs_amount();
|
||||
Amount output_amount();
|
||||
};
|
||||
|
||||
interface SwapResponse {
|
||||
constructor(sequence<BlindedSignature> promises);
|
||||
sequence<BlindedSignature> signatures();
|
||||
};
|
||||
|
||||
// NUT-04
|
||||
|
||||
interface MintQuoteBolt11Request {
|
||||
constructor(Amount amount, string unit);
|
||||
Amount amount();
|
||||
};
|
||||
|
||||
interface MintQuoteBolt11Response {
|
||||
constructor(string quote, string request, boolean paid, u64 expiry);
|
||||
string quote();
|
||||
string request();
|
||||
boolean paid();
|
||||
u64 expiry();
|
||||
};
|
||||
|
||||
|
||||
interface MintBolt11Request {
|
||||
constructor(string quote, sequence<BlindedMessage> outputs);
|
||||
string quote();
|
||||
sequence<BlindedMessage> outputs();
|
||||
};
|
||||
|
||||
interface MintBolt11Response {
|
||||
constructor(sequence<BlindedSignature> signatures);
|
||||
sequence<BlindedSignature> signatures();
|
||||
};
|
||||
|
||||
// NUT-05
|
||||
|
||||
interface MeltQuoteBolt11Response {
|
||||
@@ -171,66 +211,55 @@ interface MeltQuoteBolt11Request {
|
||||
[Throws=CashuError]
|
||||
constructor(string request, string unit);
|
||||
string request();
|
||||
string unit();
|
||||
};
|
||||
|
||||
interface MeltBolt11Request {
|
||||
[Throws=CashuError]
|
||||
constructor(sequence<Proof> inputs, string quote);
|
||||
constructor(string quote, sequence<Proof> inputs, sequence<BlindedMessage>? outputs);
|
||||
sequence<Proof> inputs();
|
||||
string quote();
|
||||
};
|
||||
|
||||
interface RequestMintResponse {
|
||||
[Throws=CashuError]
|
||||
constructor(string invoice, string hash);
|
||||
string invoice();
|
||||
string hash();
|
||||
interface MeltBolt11Response {
|
||||
constructor(boolean paid, string? payment_preimage, sequence<BlindedSignature>? change);
|
||||
string? payment_preimage();
|
||||
boolean paid();
|
||||
};
|
||||
|
||||
interface MintRequest {
|
||||
constructor(sequence<BlindedMessage> outputs);
|
||||
sequence<BlindedMessage> outputs();
|
||||
Amount total_amount();
|
||||
// NUT-06
|
||||
|
||||
interface MintInfo {
|
||||
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
|
||||
string? name();
|
||||
PublicKey? pubkey();
|
||||
MintVersion? version();
|
||||
string? description();
|
||||
string? description_long();
|
||||
sequence<sequence<string>>? contact();
|
||||
string? motd();
|
||||
};
|
||||
|
||||
interface PostMintResponse {
|
||||
constructor(sequence<BlindedSignature> promises);
|
||||
sequence<BlindedSignature> promises();
|
||||
// NUT-07
|
||||
|
||||
interface CheckSpendableRequest {
|
||||
constructor(sequence<MintProof> proofs);
|
||||
sequence<MintProof> proofs();
|
||||
};
|
||||
|
||||
interface SplitRequest {
|
||||
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
|
||||
sequence<Proof> proofs();
|
||||
sequence<BlindedMessage> outputs();
|
||||
Amount proofs_amount();
|
||||
Amount output_amount();
|
||||
interface CheckSpendableResponse {
|
||||
constructor(sequence<boolean> spendable, sequence<boolean> pending);
|
||||
sequence<boolean> spendable();
|
||||
sequence<boolean> pending();
|
||||
};
|
||||
|
||||
interface SplitResponse {
|
||||
constructor(sequence<BlindedSignature> promises);
|
||||
sequence<BlindedSignature> promises();
|
||||
Amount? promises_amount();
|
||||
|
||||
};
|
||||
|
||||
|
||||
interface MintVersion {
|
||||
constructor(string name, string version);
|
||||
string name();
|
||||
string version();
|
||||
};
|
||||
|
||||
interface MintInfo {
|
||||
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, sequence<string> nuts, string? motd);
|
||||
string? name();
|
||||
PublicKey? pubkey();
|
||||
MintVersion? version();
|
||||
string? description();
|
||||
string? description_long();
|
||||
sequence<sequence<string>>? contact();
|
||||
sequence<string> nuts();
|
||||
string? motd();
|
||||
interface KeySetInfo {
|
||||
constructor(Id id, string unit);
|
||||
};
|
||||
|
||||
enum InvoiceStatus {
|
||||
@@ -240,17 +269,6 @@ enum InvoiceStatus {
|
||||
"InFlight"
|
||||
};
|
||||
|
||||
interface ProofsStatus {
|
||||
constructor(sequence<Proof> spendable, sequence<Proof> spent);
|
||||
sequence<Proof> spendable();
|
||||
sequence<Proof> spent();
|
||||
};
|
||||
|
||||
|
||||
interface KeySetInfo {
|
||||
constructor(Id id, string unit);
|
||||
|
||||
};
|
||||
|
||||
// Cashu Sdk
|
||||
|
||||
@@ -281,23 +299,19 @@ interface Wallet {
|
||||
// [Throws=CashuSdkError]
|
||||
// ProofsStatus check_proofs_spent(sequence<Proof> proofs);
|
||||
[Throws=CashuSdkError]
|
||||
RequestMintResponse request_mint(Amount amount);
|
||||
[Throws=CashuSdkError]
|
||||
Token mint_token(Amount amount, string hash, string? unit, string? memo);
|
||||
Token mint_token(Amount amount, string hash,CurrencyUnit? unit, string? memo);
|
||||
[Throws=CashuSdkError]
|
||||
sequence<Proof> mint(Amount amount, string hash);
|
||||
[Throws=CashuSdkError]
|
||||
Amount check_fee(Bolt11Invoice invoice);
|
||||
[Throws=CashuSdkError]
|
||||
sequence<Proof> receive(string encoded_token);
|
||||
[Throws=CashuSdkError]
|
||||
sequence<Proof> process_split_response(PreMintSecrets blinded_messages, sequence<BlindedSignature> promises);
|
||||
sequence<Proof> process_swap_response(PreMintSecrets blinded_messages, sequence<BlindedSignature> promises);
|
||||
[Throws=CashuSdkError]
|
||||
SendProofs send(Amount amount, sequence<Proof> proofs);
|
||||
[Throws=CashuSdkError]
|
||||
Melted melt(Bolt11Invoice invoice, sequence<Proof> proofs, Amount fee_reserve);
|
||||
Melted melt(string quote, sequence<Proof> proofs, Amount fee_reserve);
|
||||
[Throws=CashuSdkError]
|
||||
string proof_to_token(sequence<Proof> proof, string? unit, string? memo);
|
||||
string proofs_to_token(sequence<Proof> proof, CurrencyUnit? unit, string? memo);
|
||||
};
|
||||
|
||||
|
||||
@@ -308,11 +322,5 @@ interface Mint {
|
||||
KeySetResponse keysets();
|
||||
KeySet? keyset(Id id);
|
||||
[Throws=CashuSdkError]
|
||||
PostMintResponse process_mint_request(MintRequest mint_request);
|
||||
[Throws=CashuSdkError]
|
||||
SplitResponse process_split_request(SplitRequest split_request);
|
||||
[Throws=CashuSdkError]
|
||||
void verify_melt_request(MeltRequest melt_request);
|
||||
[Throws=CashuSdkError]
|
||||
MeltResponse process_melt_request(MeltRequest melt_request, string preimage, Amount totoal_spent);
|
||||
SwapResponse process_swap_request(SwapRequest swap_request);
|
||||
};
|
||||
|
||||
@@ -5,12 +5,13 @@ mod wallet;
|
||||
|
||||
mod ffi {
|
||||
pub use cashu_ffi::{
|
||||
Amount, BlindedMessage, BlindedSignature, Bolt11Invoice, CashuError, CheckFeesRequest,
|
||||
CheckFeesResponse, CheckSpendableRequest, CheckSpendableResponse, Id, InvoiceStatus,
|
||||
KeyPair, KeySet, KeySetInfo, KeySetResponse, Keys, KeysResponse, MeltRequest, MeltResponse,
|
||||
MintInfo, MintKeySet, MintProof, MintProofs, MintRequest, MintVersion, Nut05MeltRequest,
|
||||
Nut05MeltResponse, PostMintResponse, PreMintSecrets, Proof, PublicKey, RequestMintResponse,
|
||||
Secret, SecretKey, SplitRequest, SplitResponse, Token,
|
||||
Amount, BlindedMessage, BlindedSignature, Bolt11Invoice, CashuError, CheckSpendableRequest,
|
||||
CheckSpendableResponse, CurrencyUnit, Id, InvoiceStatus, KeyPair, KeySet, KeySetInfo,
|
||||
KeySetResponse, Keys, KeysResponse, MeltBolt11Request, MeltBolt11Response,
|
||||
MeltQuoteBolt11Request, MeltQuoteBolt11Response, MintBolt11Request, MintBolt11Response,
|
||||
MintInfo, MintKeySet, MintProof, MintProofs, MintQuoteBolt11Request,
|
||||
MintQuoteBolt11Response, MintVersion, Nut05MeltBolt11Request, Nut05MeltBolt11Response,
|
||||
PreMintSecrets, Proof, PublicKey, Secret, SecretKey, SwapRequest, SwapResponse, Token,
|
||||
};
|
||||
|
||||
pub use crate::error::CashuSdkError;
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
use cashu_ffi::{
|
||||
Amount, CheckSpendableRequest, CheckSpendableResponse, Id, KeySet, KeySetResponse,
|
||||
KeysResponse, MeltRequest, MeltResponse, MintRequest, PostMintResponse, Secret, SplitRequest,
|
||||
SplitResponse,
|
||||
KeysResponse, MeltBolt11Request, MeltBolt11Response, MintBolt11Request, MintBolt11Response,
|
||||
Secret, SwapRequest, SwapResponse,
|
||||
};
|
||||
use cashu_sdk::mint::Mint as MintSdk;
|
||||
|
||||
@@ -38,6 +38,8 @@ impl Mint {
|
||||
&secret,
|
||||
keysets,
|
||||
spent_secrets,
|
||||
// TODO: quotes
|
||||
vec![],
|
||||
*min_fee_reserve.as_ref().deref(),
|
||||
percent_fee_reserve,
|
||||
)
|
||||
@@ -67,8 +69,8 @@ impl Mint {
|
||||
|
||||
pub fn process_mint_request(
|
||||
&self,
|
||||
mint_request: Arc<MintRequest>,
|
||||
) -> Result<Arc<PostMintResponse>> {
|
||||
mint_request: Arc<MintBolt11Request>,
|
||||
) -> Result<Arc<MintBolt11Response>> {
|
||||
Ok(Arc::new(
|
||||
self.inner
|
||||
.write()
|
||||
@@ -78,15 +80,15 @@ impl Mint {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn process_split_request(
|
||||
pub fn process_swap_request(
|
||||
&self,
|
||||
split_request: Arc<SplitRequest>,
|
||||
) -> Result<Arc<SplitResponse>> {
|
||||
split_request: Arc<SwapRequest>,
|
||||
) -> Result<Arc<SwapResponse>> {
|
||||
Ok(Arc::new(
|
||||
self.inner
|
||||
.write()
|
||||
.unwrap()
|
||||
.process_split_request(split_request.as_ref().deref().clone())?
|
||||
.process_swap_request(split_request.as_ref().deref().clone())?
|
||||
.into(),
|
||||
))
|
||||
}
|
||||
@@ -104,7 +106,7 @@ impl Mint {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn verify_melt_request(&self, melt_request: Arc<MeltRequest>) -> Result<()> {
|
||||
pub fn verify_melt_request(&self, melt_request: Arc<MeltBolt11Request>) -> Result<()> {
|
||||
Ok(self
|
||||
.inner
|
||||
.write()
|
||||
@@ -114,10 +116,10 @@ impl Mint {
|
||||
|
||||
pub fn process_melt_request(
|
||||
&self,
|
||||
melt_request: Arc<MeltRequest>,
|
||||
melt_request: Arc<MeltBolt11Request>,
|
||||
preimage: String,
|
||||
total_spent: Arc<Amount>,
|
||||
) -> Result<Arc<MeltResponse>> {
|
||||
) -> Result<Arc<MeltBolt11Response>> {
|
||||
Ok(Arc::new(
|
||||
self.inner
|
||||
.write()
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use cashu_ffi::{
|
||||
BlindedSignature, Bolt11Invoice, PreMintSecrets, Proof, RequestMintResponse, Token,
|
||||
};
|
||||
use cashu_ffi::{BlindedSignature, CurrencyUnit, PreMintSecrets, Proof, Token};
|
||||
use cashu_sdk::client::minreq_client::HttpClient;
|
||||
use cashu_sdk::types::ProofsStatus;
|
||||
use cashu_sdk::url::UncheckedUrl;
|
||||
@@ -43,23 +41,21 @@ impl Wallet {
|
||||
Ok(Arc::new(proofs))
|
||||
}
|
||||
|
||||
pub fn request_mint(&self, amount: Arc<Amount>) -> Result<Arc<RequestMintResponse>> {
|
||||
let mint_response = RUNTIME
|
||||
.block_on(async { self.inner.request_mint(*amount.as_ref().deref()).await })?
|
||||
.into();
|
||||
Ok(Arc::new(mint_response))
|
||||
}
|
||||
|
||||
pub fn mint_token(
|
||||
&self,
|
||||
amount: Arc<Amount>,
|
||||
hash: String,
|
||||
unit: Option<String>,
|
||||
unit: Option<CurrencyUnit>,
|
||||
memo: Option<String>,
|
||||
) -> Result<Arc<Token>> {
|
||||
let token = RUNTIME.block_on(async {
|
||||
self.inner
|
||||
.mint_token(*amount.as_ref().deref(), &hash, unit, memo)
|
||||
.mint_token(
|
||||
*amount.as_ref().deref(),
|
||||
&hash,
|
||||
memo,
|
||||
unit.map(|u| u.into()),
|
||||
)
|
||||
.await
|
||||
})?;
|
||||
|
||||
@@ -73,20 +69,13 @@ impl Wallet {
|
||||
Ok(proofs.into_iter().map(|p| Arc::new(p.into())).collect())
|
||||
}
|
||||
|
||||
pub fn check_fee(&self, invoice: Arc<Bolt11Invoice>) -> Result<Arc<Amount>> {
|
||||
let amount = RUNTIME
|
||||
.block_on(async { self.inner.check_fee(invoice.as_ref().deref().clone()).await })?;
|
||||
|
||||
Ok(Arc::new(amount.into()))
|
||||
}
|
||||
|
||||
pub fn receive(&self, encoded_token: String) -> Result<Vec<Arc<Proof>>> {
|
||||
let proofs = RUNTIME.block_on(async { self.inner.receive(&encoded_token).await })?;
|
||||
|
||||
Ok(proofs.into_iter().map(|p| Arc::new(p.into())).collect())
|
||||
}
|
||||
|
||||
pub fn process_split_response(
|
||||
pub fn process_swap_response(
|
||||
&self,
|
||||
blinded_messages: Arc<PreMintSecrets>,
|
||||
promises: Vec<Arc<BlindedSignature>>,
|
||||
@@ -117,14 +106,14 @@ impl Wallet {
|
||||
|
||||
pub fn melt(
|
||||
&self,
|
||||
invoice: Arc<Bolt11Invoice>,
|
||||
quote: String,
|
||||
proofs: Vec<Arc<Proof>>,
|
||||
fee_reserve: Arc<Amount>,
|
||||
) -> Result<Arc<Melted>> {
|
||||
let melted = RUNTIME.block_on(async {
|
||||
self.inner
|
||||
.melt(
|
||||
invoice.as_ref().deref().clone(),
|
||||
quote,
|
||||
proofs.iter().map(|p| p.as_ref().deref().clone()).collect(),
|
||||
*fee_reserve.as_ref().deref(),
|
||||
)
|
||||
@@ -134,16 +123,16 @@ impl Wallet {
|
||||
Ok(Arc::new(melted.into()))
|
||||
}
|
||||
|
||||
pub fn proof_to_token(
|
||||
pub fn proofs_to_token(
|
||||
&self,
|
||||
proofs: Vec<Arc<Proof>>,
|
||||
unit: Option<String>,
|
||||
unit: Option<CurrencyUnit>,
|
||||
memo: Option<String>,
|
||||
) -> Result<String> {
|
||||
Ok(self.inner.proofs_to_token(
|
||||
proofs.iter().map(|p| p.as_ref().deref().clone()).collect(),
|
||||
unit,
|
||||
memo,
|
||||
unit.map(|u| u.into()),
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user