| 36 | } |
| 37 | |
| 38 | void common_setup(const char *argv0) |
| 39 | { |
| 40 | int wally_ret; |
| 41 | |
| 42 | setup_locale(); |
| 43 | err_set_progname(argv0); |
| 44 | |
| 45 | /* We rely on libsodium for some of the crypto stuff, so we'd better |
| 46 | * not start if it cannot do its job correctly. */ |
| 47 | if (sodium_init() == -1) |
| 48 | errx(1, "Could not initialize libsodium. Maybe not enough entropy" |
| 49 | " available ?"); |
| 50 | |
| 51 | /* We set up Wally, the bitcoin wallet lib */ |
| 52 | wally_ret = wally_init(0); |
| 53 | if (wally_ret != WALLY_OK) |
| 54 | errx(1, "Error initializing libwally: %i", wally_ret); |
| 55 | wally_ret = wally_set_operations(&wally_tal_ops); |
| 56 | if (wally_ret != WALLY_OK) |
| 57 | errx(1, "Error setting libwally operations: %i", wally_ret); |
| 58 | secp256k1_ctx = wally_get_secp_context(); |
| 59 | |
| 60 | /* Make htable* use tal for the tables themselves. */ |
| 61 | htable_set_allocator(htable_tal, htable_tal_free); |
| 62 | |
| 63 | setup_tmpctx(); |
| 64 | } |
| 65 | |
| 66 | void common_shutdown(void) |
| 67 | { |