2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_UTILS_H
|
|
|
|
#define LIGHTNING_COMMON_UTILS_H
|
2016-05-03 03:29:20 +02:00
|
|
|
#include "config.h"
|
2016-09-07 23:34:36 +02:00
|
|
|
#include <ccan/short_types/short_types.h>
|
2016-05-03 03:29:20 +02:00
|
|
|
#include <ccan/tal/tal.h>
|
2016-12-02 08:41:06 +01:00
|
|
|
#include <secp256k1.h>
|
|
|
|
|
|
|
|
extern secp256k1_context *secp256k1_ctx;
|
2016-05-03 03:29:20 +02:00
|
|
|
|
|
|
|
/* Allocate and fill in a hex-encoded string of this data. */
|
|
|
|
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len);
|
|
|
|
|
2017-01-10 05:49:25 +01:00
|
|
|
/* Allocate and fill a hex-encoding of this tal pointer. */
|
|
|
|
char *tal_hex(const tal_t *ctx, const tal_t *data);
|
|
|
|
|
2016-09-07 23:34:36 +02:00
|
|
|
/* Allocate and fill a buffer with the data of this hex string. */
|
|
|
|
u8 *tal_hexdata(const tal_t *ctx, const void *str, size_t len);
|
|
|
|
|
2017-09-28 05:40:57 +02:00
|
|
|
/* Get a temporary context for this function scope (tal_free at end) */
|
|
|
|
tal_t *tal_tmpctx_(const tal_t *ctx, const char *file, unsigned int line);
|
2016-11-01 12:04:27 +01:00
|
|
|
#define tal_tmpctx(ctx) \
|
2017-09-28 05:40:57 +02:00
|
|
|
tal_tmpctx_((ctx), __FILE__, __LINE__)
|
|
|
|
|
|
|
|
/* Return non-NULL if any tmpctx still allocated. */
|
|
|
|
const char *tmpctx_any(void);
|
2016-11-01 12:04:27 +01:00
|
|
|
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_COMMON_UTILS_H */
|