upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/cashu.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/cashu.h')
-rw-r--r--main/cashu.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/main/cashu.h b/main/cashu.h
new file mode 100644
index 0000000..17891c5
--- /dev/null
+++ b/main/cashu.h
@@ -0,0 +1,42 @@
1#ifndef CASHU_H
2#define CASHU_H
3
4#include "esp_err.h"
5#include <stdint.h>
6#include <stdbool.h>
7
8#define CASHU_MAX_PROOFS 10
9#define CASHU_MAX_SECRET_LEN 128
10#define CASHU_MAX_ID_LEN 16
11#define CASHU_MAX_C_LEN 128
12
13typedef struct {
14 uint64_t amount;
15 char id[CASHU_MAX_ID_LEN];
16 char secret[CASHU_MAX_SECRET_LEN];
17 char c[CASHU_MAX_C_LEN];
18} cashu_proof_t;
19
20typedef struct {
21 cashu_proof_t proofs[CASHU_MAX_PROOFS];
22 int proof_count;
23 char mint_url[256];
24 uint64_t total_amount;
25} cashu_token_t;
26
27typedef struct {
28 char y_hex[65];
29 bool spent;
30} cashu_proof_state_t;
31
32esp_err_t cashu_decode_token(const char *token_str, cashu_token_t *out);
33
34esp_err_t cashu_check_proof_states(const char *mint_url, const cashu_token_t *token,
35 cashu_proof_state_t *states, int *state_count);
36
37uint64_t cashu_calculate_allotment_ms(uint64_t token_amount, uint64_t price_per_step,
38 uint64_t step_size_ms);
39
40bool cashu_is_mint_accepted(const char *mint_url);
41
42#endif