123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- namespace cashu_sdk {};
- // Cashu
- [Error]
- interface CashuError {
- Generic(string err);
- };
- // Types
- interface Bolt11Invoice {
- [Throws=CashuError]
- constructor(string bolt11);
- string as_string();
- Amount? amount();
- };
- interface Amount {
- u64 to_sat();
- u64 to_msat();
- [Name = from_sat]
- constructor(u64 sat);
- [Name = from_msat]
- constructor(u64 msat);
- sequence<Amount> split();
- };
- interface Secret {
- constructor();
- sequence<u8> as_bytes();
- };
- interface Id {
- [Throws=CashuError]
- constructor(string id);
- };
- interface PublicKey {
- [Throws=CashuError, Name=from_hex]
- constructor(string hex);
- [Throws=CashuError]
- string to_hex();
- };
- interface SecretKey {
- [Throws=CashuError]
- string to_hex();
- };
- interface BlindedMessage {
- constructor(Id keyset_id, Amount amount, PublicKey b);
- Amount amount();
- PublicKey b();
- };
- interface Proof {
- constructor(Amount amount, Secret secret, PublicKey c, Id id);
- Amount amount();
- Secret secret();
- PublicKey c();
- Id id();
- };
- interface BlindedSignature {
- constructor(Id id, Amount amount, PublicKey c);
- Id id();
- Amount amount();
- PublicKey c();
- };
- interface MintProof {
- constructor(Amount? amount, Secret secret, PublicKey? c, Id? id);
- Amount? amount();
- Secret secret();
- PublicKey? c();
- Id? id();
-
- };
- interface MintProofs {
- [Throws=CashuError]
- constructor(string mint, sequence<Proof> proofs);
- string url();
- sequence<Proof> proofs();
- };
- interface Token {
- [Throws=CashuError]
- constructor(string mint, sequence<Proof> token, string? memo);
- sequence<MintProofs> token();
- string? memo();
- [Throws=CashuError]
- string as_string();
- [Throws=CashuError, Name=from_string]
- constructor(string token);
-
- };
- interface BlindedMessages {
- [Throws=CashuError, Name=random]
- constructor(Id keyset_id, Amount amount);
- [Throws=CashuError, Name=blank]
- constructor(Id keyset_id, Amount amount);
- sequence<BlindedMessage> blinded_messages();
- sequence<Secret> secrets();
- sequence<SecretKey> rs();
- sequence<Amount> amounts();
- };
- interface KeyPair {
- [Name=from_secret_key]
- constructor(SecretKey secret_key);
- SecretKey secret_key();
- PublicKey public_key();
- };
- interface Keys {
- constructor(record<string, PublicKey> keys);
- record<string, PublicKey> keys();
- record<string, string> as_hashmap();
- PublicKey? amount_key(Amount amount);
- };
- interface KeySet {
- constructor(Id id, string symbol, Keys keys);
- Id id();
- Keys keys();
- };
- interface MintKeySet {
- [Name=generate]
- constructor(string secret, string symbol, string derivation_path, u8 max_order);
- };
- interface KeysResponse {
- constructor(Keys keys);
- };
- interface KeySetResponse {
- constructor(sequence<KeySetInfo> keysets);
- sequence<KeySetInfo> keysets();
- };
- interface RequestMintResponse {
- [Throws=CashuError]
- constructor(string invoice, string hash);
- string invoice();
- string hash();
- };
- interface MintRequest {
- constructor(sequence<BlindedMessage> outputs);
- sequence<BlindedMessage> outputs();
- Amount total_amount();
- };
- interface PostMintResponse {
- constructor(sequence<BlindedSignature> promises);
- sequence<BlindedSignature> promises();
- };
- interface CheckFeesRequest {
- [Throws=CashuError]
- constructor(string invoice);
- string invoice();
- };
- interface CheckFeesResponse {
- constructor(Amount amount);
- Amount amount();
- };
- interface Nut05MeltRequest {
- [Throws=CashuError]
- constructor(sequence<Proof> proofs, string Invoice);
- sequence<Proof> proofs();
- string invoice();
- };
- interface Nut05MeltResponse {
- constructor(boolean paid, string? preimage);
- boolean paid();
- string? preimage();
- };
- interface SplitRequest {
- constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
- sequence<Proof> proofs();
- sequence<BlindedMessage> outputs();
- Amount proofs_amount();
- Amount output_amount();
- };
- interface SplitResponse {
- constructor(sequence<BlindedSignature> promises);
- sequence<BlindedSignature> promises();
- Amount? promises_amount();
- };
- interface CheckSpendableRequest {
- constructor(sequence<MintProof> proofs);
- sequence<MintProof> proofs();
- };
- interface CheckSpendableResponse {
- constructor(sequence<boolean> spendable, sequence<boolean> pending);
- sequence<boolean> spendable();
- sequence<boolean> pending();
- };
- interface MeltRequest {
- [Throws=CashuError]
- constructor(sequence<Proof> proofs, string Invoice, sequence<BlindedMessage>? outputs);
- sequence<Proof> proofs();
- string invoice();
- sequence<BlindedMessage>? outputs();
- };
- interface MeltResponse {
- constructor(boolean paid, string? preimage, sequence<BlindedSignature>? change);
- boolean paid();
- string? preimage();
- sequence<BlindedSignature>? change();
- };
- 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();
- };
- enum InvoiceStatus {
- "Unpaid",
- "Paid",
- "Expired",
- "InFlight"
- };
- interface ProofsStatus {
- constructor(sequence<Proof> spendable, sequence<Proof> spent);
- sequence<Proof> spendable();
- sequence<Proof> spent();
- };
- interface KeySetInfo {
- constructor(Id id, string symbol);
-
- };
- // Cashu Sdk
- interface MintKeySetInfo {
- constructor(Id id, string symbol, u64 valid_from, u64? valid_to, string derivation_path, u8 max_order);
- };
- [Error]
- interface CashuSdkError {
- Generic(string err);
- };
- interface SendProofs {
- constructor(sequence<Proof> change_proofs, sequence<Proof> send_proofs);
- sequence<Proof> send_proofs();
- sequence<Proof> change_proofs();
- };
- interface Melted {
- constructor(boolean paid, string? preimage, sequence<Proof>? change);
- string? preimage();
- boolean paid();
- sequence<Proof>? change();
- };
- 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);
- [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(BlindedMessages 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);
- [Throws=CashuSdkError]
- string proof_to_token(sequence<Proof> proof, string? memo);
- };
- interface Mint {
- [Throws=CashuSdkError]
- constructor(string secret, MintKeySetInfo active_keyset_info, sequence<MintKeySetInfo> inactive_keysets, sequence<Secret> spent_secrets, Amount min_fee_reserve, f32 percent_fee_reserve);
- KeysResponse active_keyset_pubkeys();
- KeySetResponse keysets();
- MintKeySet active_keyset();
- 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);
- };
|