cashu.udl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. namespace cashu {};
  2. [Error]
  3. interface CashuError {
  4. Generic(string err);
  5. };
  6. // Types
  7. [Enum]
  8. interface CurrencyUnit {
  9. Sat();
  10. Usd();
  11. Custom(string unit);
  12. };
  13. interface Bolt11Invoice {
  14. [Throws=CashuError]
  15. constructor(string bolt11);
  16. string as_string();
  17. Amount? amount();
  18. };
  19. interface Amount {
  20. constructor(u64 amount);
  21. sequence<Amount> split();
  22. };
  23. interface Secret {
  24. constructor();
  25. sequence<u8> as_bytes();
  26. };
  27. // NUT00
  28. interface PublicKey {
  29. [Throws=CashuError, Name=from_hex]
  30. constructor(string hex);
  31. [Throws=CashuError]
  32. string to_hex();
  33. };
  34. interface SecretKey {
  35. [Throws=CashuError]
  36. string to_hex();
  37. };
  38. interface BlindedMessage {
  39. constructor(Id keyset_id, Amount amount, PublicKey b);
  40. Amount amount();
  41. Id keyset_id();
  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 keyset_id();
  50. };
  51. interface BlindedSignature {
  52. constructor(Id keyset_id, Amount amount, PublicKey c);
  53. Id keyset_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? keyset_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, string? unit);
  73. sequence<MintProofs> token();
  74. string? memo();
  75. string? unit();
  76. string to_string();
  77. [Throws=CashuError, Name=from_string]
  78. constructor(string token);
  79. };
  80. interface PreMintSecrets {
  81. [Throws=CashuError, Name=random]
  82. constructor(Id keyset_id, Amount amount);
  83. [Throws=CashuError, Name=blank]
  84. constructor(Id keyset_id, Amount amount);
  85. sequence<BlindedMessage> blinded_messages();
  86. sequence<Secret> secrets();
  87. sequence<SecretKey> rs();
  88. sequence<Amount> amounts();
  89. };
  90. // NUT-02
  91. interface Id {
  92. [Throws=CashuError]
  93. constructor(string id);
  94. };
  95. interface KeyPair {
  96. [Name=from_secret_key]
  97. constructor(SecretKey secret_key);
  98. SecretKey secret_key();
  99. PublicKey public_key();
  100. };
  101. interface Keys {
  102. constructor(record<string, PublicKey> keys);
  103. record<string, PublicKey> keys();
  104. record<string, string> as_hashmap();
  105. PublicKey? amount_key(Amount amount);
  106. };
  107. interface KeySet {
  108. constructor(Id id, string unit, Keys keys);
  109. Id id();
  110. Keys keys();
  111. };
  112. interface MintKeySet {
  113. [Name=generate]
  114. constructor(string secret, string unit, string derivation_path, u8 max_order);
  115. };
  116. interface KeysResponse {
  117. constructor(Keys keys);
  118. };
  119. interface KeySetResponse {
  120. constructor(sequence<KeySetInfo> keysets);
  121. sequence<KeySetInfo> keysets();
  122. };
  123. // NUT-03
  124. interface SwapRequest {
  125. constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
  126. sequence<Proof> proofs();
  127. sequence<BlindedMessage> outputs();
  128. Amount proofs_amount();
  129. Amount output_amount();
  130. };
  131. interface SwapResponse {
  132. constructor(sequence<BlindedSignature> promises);
  133. sequence<BlindedSignature> signatures();
  134. };
  135. // NUT-04
  136. interface MintQuoteBolt11Request {
  137. constructor(Amount amount, string unit);
  138. Amount amount();
  139. };
  140. interface MintQuoteBolt11Response {
  141. constructor(string quote, string request, boolean paid, u64 expiry);
  142. string quote();
  143. string request();
  144. boolean paid();
  145. u64 expiry();
  146. };
  147. interface MintBolt11Request {
  148. constructor(string quote, sequence<BlindedMessage> outputs);
  149. string quote();
  150. sequence<BlindedMessage> outputs();
  151. };
  152. interface MintBolt11Response {
  153. constructor(sequence<BlindedSignature> signatures);
  154. sequence<BlindedSignature> signatures();
  155. };
  156. // NUT-05
  157. interface MeltQuoteBolt11Response {
  158. [Throws=CashuError]
  159. constructor(string quote, u64 amount, u64 fee_reserve, boolean paid, u64 expiry);
  160. string quote();
  161. u64 amount();
  162. u64 fee_reserve();
  163. boolean paid();
  164. u64 expiry();
  165. };
  166. interface MeltQuoteBolt11Request {
  167. [Throws=CashuError]
  168. constructor(string request, string unit);
  169. string request();
  170. };
  171. interface MeltBolt11Request {
  172. [Throws=CashuError]
  173. constructor(string quote, sequence<Proof> inputs, sequence<BlindedMessage>? outputs);
  174. sequence<Proof> inputs();
  175. string quote();
  176. };
  177. interface MeltBolt11Response {
  178. constructor(boolean paid, string? payment_preimage, sequence<BlindedSignature>? change);
  179. string? payment_preimage();
  180. boolean paid();
  181. };
  182. // NUT-06
  183. interface MintInfo {
  184. constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
  185. string? name();
  186. PublicKey? pubkey();
  187. MintVersion? version();
  188. string? description();
  189. string? description_long();
  190. sequence<sequence<string>>? contact();
  191. string? motd();
  192. };
  193. // NUT-07
  194. interface CheckSpendableRequest {
  195. constructor(sequence<MintProof> proofs);
  196. sequence<MintProof> proofs();
  197. };
  198. interface CheckSpendableResponse {
  199. constructor(sequence<boolean> spendable, sequence<boolean> pending);
  200. sequence<boolean> spendable();
  201. sequence<boolean> pending();
  202. };
  203. interface MintVersion {
  204. constructor(string name, string version);
  205. string name();
  206. string version();
  207. };
  208. interface KeySetInfo {
  209. constructor(Id id, string unit);
  210. };
  211. enum InvoiceStatus {
  212. "Unpaid",
  213. "Paid",
  214. "Expired",
  215. "InFlight"
  216. };