bolt11.h (2808B)
1 #ifndef LIGHTNING_COMMON_BOLT11_H 2 #define LIGHTNING_COMMON_BOLT11_H 3 4 #include "short_types.h" 5 #include "hash_u5.h" 6 #include "list.h" 7 #include "node_id.h" 8 //#include <secp256k1_recovery.h> 9 10 /* We only have 10 bits for the field length, meaning < 640 bytes */ 11 #define BOLT11_FIELD_BYTE_LIMIT ((1 << 10) * 5 / 8) 12 13 /* BOLT #11: 14 * * `c` (24): `data_length` variable. 15 * `min_final_cltv_expiry` to use for the last HTLC in the route. 16 * Default is 18 if not specified. 17 */ 18 #define DEFAULT_FINAL_CLTV_DELTA 18 19 20 struct feature_set; 21 22 struct bolt11_field { 23 struct list_node list; 24 25 char tag; 26 u5 *data; 27 }; 28 29 /* BOLT #11: 30 * * `pubkey` (264 bits) 31 * * `short_channel_id` (64 bits) 32 * * `fee_base_msat` (32 bits, big-endian) 33 * * `fee_proportional_millionths` (32 bits, big-endian) 34 * * `cltv_expiry_delta` (16 bits, big-endian) 35 */ 36 37 /* 38 struct route_info { 39 struct node_id pubkey; 40 u16 cltv_expiry_delta; 41 struct short_channel_id short_channel_id; 42 u32 fee_base_msat, fee_proportional_millionths; 43 }; 44 */ 45 46 struct bolt11 { 47 const struct chainparams *chain; 48 u64 timestamp; 49 struct amount_msat *msat; /* NULL if not specified. */ 50 51 struct sha256 payment_hash; 52 struct node_id receiver_id; 53 54 /* description_hash valid if and only if description is NULL. */ 55 const char *description; 56 struct sha256 *description_hash; 57 58 /* How many seconds to pay from @timestamp above. */ 59 u64 expiry; 60 61 /* How many blocks final hop requires. */ 62 u32 min_final_cltv_expiry; 63 64 /* If non-NULL, indicates fallback addresses to pay to. */ 65 const u8 **fallbacks; 66 67 /* If non-NULL: array of route arrays */ 68 //struct route_info **routes; 69 70 /* signature of sha256 of entire thing. */ 71 //secp256k1_ecdsa_signature sig; 72 73 /* payment secret, if any. */ 74 //struct secret *payment_secret; 75 76 /* Features bitmap, if any. */ 77 u8 *features; 78 79 /* Optional metadata to send with payment. */ 80 u8 *metadata; 81 82 struct list_head extra_fields; 83 }; 84 85 /* Decodes and checks signature; returns NULL on error; description is 86 * (optional) out-of-band description of payment, for `h` field. 87 * fset is NULL to accept any features (usually not desirable!). 88 * 89 * if @must_be_chain is not NULL, fails unless it's this chain. 90 */ 91 struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str, char **fail); 92 93 /* Extracts signature but does not check it. */ 94 struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str, u5 **sigdata, char **fail); 95 96 /* Initialize an empty bolt11 struct with optional amount */ 97 struct bolt11 *new_bolt11(const tal_t *ctx); 98 99 #if DEVELOPER 100 /* Flag for tests to suppress `min_final_cltv_expiry` field generation, to match test vectors */ 101 extern bool dev_bolt11_no_c_generation; 102 #endif 103 104 #endif /* LIGHTNING_COMMON_BOLT11_H */