1 #ifndef LIGHTNING_BITCOIN_VARINT_H
2 #define LIGHTNING_BITCOIN_VARINT_H
3 #include "config.h"
4 #include <ccan/short_types/short_types.h>
5 #include <stdlib.h>
6 
7 /* We unpack varints for our in-memory representation */
8 #define varint_t u64
9 
10 #define VARINT_MAX_LEN 9
11 
12 /* Calculate bytes used (up to 9) */
13 size_t varint_size(varint_t v);
14 
15 /* Returns bytes used (up to 9) */
16 size_t varint_put(u8 buf[VARINT_MAX_LEN], varint_t v);
17 
18 /* Returns bytes used: 0 if max_len too small. */
19 size_t varint_get(const u8 *p, size_t max_len, varint_t *val);
20 
21 #endif /* LIGHTNING_BITCOIN_VARINT_H */
22