cashu.udl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. namespace cashu {};
  2. [Error]
  3. interface CashuError {
  4. Generic(string err);
  5. };
  6. interface Bolt11Invoice {
  7. [Throws=CashuError]
  8. constructor(string bolt11);
  9. string as_string();
  10. Amount? amount();
  11. };
  12. interface Amount {
  13. u64 to_sat();
  14. u64 to_msat();
  15. [Name = from_sat]
  16. constructor(u64 sat);
  17. [Name = from_msat]
  18. constructor(u64 msat);
  19. sequence<Amount> split();
  20. };
  21. interface Secret {
  22. constructor();
  23. sequence<u8> as_bytes();
  24. };
  25. interface Id {
  26. [Throws=CashuError]
  27. constructor(string id);
  28. };
  29. interface PublicKey {
  30. [Throws=CashuError, Name=from_hex]
  31. constructor(string hex);
  32. [Throws=CashuError]
  33. string to_hex();
  34. };
  35. interface SecretKey {
  36. [Throws=CashuError]
  37. string to_hex();
  38. };
  39. interface BlindedMessage {
  40. constructor(Amount amount, PublicKey b);
  41. Amount amount();
  42. PublicKey b();
  43. };
  44. interface Proof {
  45. constructor(Amount amount, Secret secret, PublicKey c, Id? id);
  46. Amount amount();
  47. Secret secret();
  48. PublicKey c();
  49. Id? id();
  50. };
  51. interface BlindedSignature {
  52. constructor(Id id, Amount amount, PublicKey c);
  53. Id id();
  54. Amount amount();
  55. PublicKey c();
  56. };
  57. interface MintProof {
  58. constructor(Amount? amount, Secret secret, PublicKey? c, Id? id);
  59. Amount? amount();
  60. Secret secret();
  61. PublicKey? c();
  62. Id? id();
  63. };
  64. interface MintProofs {
  65. [Throws=CashuError]
  66. constructor(string mint, sequence<Proof> proofs);
  67. string url();
  68. sequence<Proof> proofs();
  69. };
  70. interface Token {
  71. [Throws=CashuError]
  72. constructor(string mint, sequence<Proof> token, string? memo);
  73. sequence<MintProofs> token();
  74. string? memo();
  75. [Throws=CashuError]
  76. string as_string();
  77. [Throws=CashuError, Name=from_string]
  78. constructor(string token);
  79. };
  80. interface BlindedMessages {
  81. [Throws=CashuError, Name=random]
  82. constructor(Amount amount);
  83. [Throws=CashuError, Name=blank]
  84. constructor(Amount fee_reserve);
  85. sequence<BlindedMessage> blinded_messages();
  86. sequence<Secret> secrets();
  87. sequence<SecretKey> rs();
  88. sequence<Amount> amounts();
  89. };
  90. interface KeyPair {
  91. [Name=from_secret_key]
  92. constructor(SecretKey secret_key);
  93. SecretKey secret_key();
  94. PublicKey public_key();
  95. };
  96. interface Keys {
  97. constructor(record<string, PublicKey> keys);
  98. record<string, PublicKey> keys();
  99. record<string, string> as_hashmap();
  100. PublicKey? amount_key(Amount amount);
  101. };
  102. interface KeySet {
  103. constructor(Id id, Keys keys);
  104. Id id();
  105. Keys keys();
  106. };
  107. interface MintKeySet {
  108. [Name=generate]
  109. constructor(string secret, string derivation_path, u8 max_order);
  110. };
  111. interface KeysResponse {
  112. constructor(Keys keys);
  113. };
  114. interface KeySetResponse {
  115. constructor(sequence<Id> keyset_ids);
  116. sequence<Id> keyset_ids();
  117. };
  118. interface RequestMintResponse {
  119. [Throws=CashuError]
  120. constructor(string invoice, string hash);
  121. string invoice();
  122. string hash();
  123. };
  124. interface MintRequest {
  125. constructor(sequence<BlindedMessage> outputs);
  126. sequence<BlindedMessage> outputs();
  127. Amount total_amount();
  128. };
  129. interface PostMintResponse {
  130. constructor(sequence<BlindedSignature> promises);
  131. sequence<BlindedSignature> promises();
  132. };
  133. interface CheckFeesRequest {
  134. [Throws=CashuError]
  135. constructor(string invoice);
  136. string invoice();
  137. };
  138. interface CheckFeesResponse {
  139. constructor(Amount amount);
  140. Amount amount();
  141. };
  142. interface Nut05MeltRequest {
  143. [Throws=CashuError]
  144. constructor(sequence<Proof> proofs, string Invoice);
  145. sequence<Proof> proofs();
  146. string invoice();
  147. };
  148. interface Nut05MeltResponse {
  149. constructor(boolean paid, string? preimage);
  150. boolean paid();
  151. string? preimage();
  152. };
  153. interface SplitRequest {
  154. constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
  155. sequence<Proof> proofs();
  156. sequence<BlindedMessage> outputs();
  157. Amount proofs_amount();
  158. Amount output_amount();
  159. };
  160. interface SplitResponse {
  161. constructor(sequence<BlindedSignature> promises);
  162. sequence<BlindedSignature> promises();
  163. Amount? promises_amount();
  164. };
  165. interface CheckSpendableRequest {
  166. constructor(sequence<MintProof> proofs);
  167. sequence<MintProof> proofs();
  168. };
  169. interface CheckSpendableResponse {
  170. constructor(sequence<boolean> spendable, sequence<boolean> pending);
  171. sequence<boolean> spendable();
  172. sequence<boolean> pending();
  173. };
  174. interface MeltRequest {
  175. [Throws=CashuError]
  176. constructor(sequence<Proof> proofs, string Invoice, sequence<BlindedMessage>? outputs);
  177. sequence<Proof> proofs();
  178. string invoice();
  179. sequence<BlindedMessage>? outputs();
  180. };
  181. interface MeltResponse {
  182. constructor(boolean paid, string? preimage, sequence<BlindedSignature>? change);
  183. boolean paid();
  184. string? preimage();
  185. sequence<BlindedSignature>? change();
  186. };
  187. interface MintVersion {
  188. constructor(string name, string version);
  189. string name();
  190. string version();
  191. };
  192. interface MintInfo {
  193. constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, sequence<string> nuts, string? motd);
  194. string? name();
  195. PublicKey? pubkey();
  196. MintVersion? version();
  197. string? description();
  198. string? description_long();
  199. sequence<sequence<string>>? contact();
  200. sequence<string> nuts();
  201. string? motd();
  202. };
  203. enum InvoiceStatus {
  204. "Unpaid",
  205. "Paid",
  206. "Expired",
  207. "InFlight"
  208. };