mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
wally: override wally to use tal-context
See attached. This lets us do fancy things with tal_steal
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <unistd.h>
|
||||
#include <wally_core.h>
|
||||
|
||||
static const tal_t *wally_tal_ctx;
|
||||
|
||||
#if BACKTRACE_SUPPORTED
|
||||
static void (*bt_print)(const char *fmt, ...) PRINTF_FMT(1,2);
|
||||
static void (*bt_exit)(void);
|
||||
@@ -119,6 +121,21 @@ static void add_steal_notifiers(const tal_t *root)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void *wally_tal(size_t size)
|
||||
{
|
||||
return tal_arr_label(wally_tal_ctx, u8, size, "wally_notleak");
|
||||
}
|
||||
|
||||
static void wally_free(void *ptr)
|
||||
{
|
||||
tal_free(ptr);
|
||||
}
|
||||
|
||||
static struct wally_operations wally_tal_ops = {
|
||||
.malloc_fn = wally_tal,
|
||||
.free_fn = wally_free,
|
||||
};
|
||||
|
||||
void daemon_setup(const char *argv0,
|
||||
void (*backtrace_print)(const char *fmt, ...),
|
||||
void (*backtrace_exit)(void))
|
||||
@@ -153,7 +170,11 @@ void daemon_setup(const char *argv0,
|
||||
|
||||
/* We handle write returning errors! */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
/* We set up Wally, the bitcoin wallet lib */
|
||||
wally_tal_ctx = tal_label(NULL, char, "wally_ctx_notleak");
|
||||
wally_init(0);
|
||||
wally_set_operations(&wally_tal_ops);
|
||||
secp256k1_ctx = wally_get_secp_context();
|
||||
|
||||
setup_tmpctx();
|
||||
@@ -164,6 +185,7 @@ void daemon_shutdown(void)
|
||||
{
|
||||
tal_free(tmpctx);
|
||||
wally_cleanup(0);
|
||||
wally_free(wally_tal_ctx);
|
||||
}
|
||||
|
||||
void daemon_maybe_debug(char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user