Browse Source

libwally: use their secp context for all our daemons.

I didn't convert all tests: they can still use a standalone context.
It's just marginally more efficient to share the libwally one for all
our daemons which link against it anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
8975fc2ceb
  1. 5
      channeld/test/run-full_channel.c
  2. 6
      common/subdaemon.c
  3. 7
      common/test/run-bolt11.c
  4. 5
      lightningd/lightningd.c
  5. 8
      wallet/test/run-wallet.c

5
channeld/test/run-full_channel.c

@ -335,8 +335,7 @@ int main(void)
const u8 *funding_wscript, **wscripts;
size_t i;
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
secp256k1_ctx = wally_get_secp_context();
setup_tmpctx();
feerate_per_kw = tal_arr(tmpctx, u32, NUM_SIDES);
@ -623,7 +622,7 @@ int main(void)
}
/* No memory leaks please */
secp256k1_context_destroy(secp256k1_ctx);
wally_cleanup(0);
tal_free(tmpctx);
/* FIXME: Do BOLT comparison! */

6
common/subdaemon.c

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <wally_core.h>
#if BACKTRACE_SUPPORTED
static struct backtrace_state *backtrace_state;
@ -75,8 +76,7 @@ void subdaemon_setup(int argc, char *argv[])
/* We handle write returning errors! */
signal(SIGPIPE, SIG_IGN);
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
secp256k1_ctx = wally_get_secp_context();
setup_tmpctx();
@ -105,5 +105,5 @@ void subdaemon_setup(int argc, char *argv[])
void subdaemon_shutdown(void)
{
tal_free(tmpctx);
secp256k1_context_destroy(secp256k1_ctx);
wally_cleanup(0);
}

7
common/test/run-bolt11.c

@ -5,6 +5,7 @@
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <stdio.h>
#include <wally_core.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_pubkey */
@ -118,8 +119,7 @@ int main(void)
struct pubkey node;
u64 msatoshi;
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
secp256k1_ctx = wally_get_secp_context();
setup_tmpctx();
/* BOLT #11:
@ -235,8 +235,7 @@ int main(void)
test_b11("lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqscc6gd6ql3jrc5yzme8v4ntcewwz5cnw92tz0pc8qcuufvq7khhr8wpald05e92xw006sq94mg8v2ndf4sefvf9sygkshp5zfem29trqq2yxxz7", b11, "One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon");
/* FIXME: Test the others! */
secp256k1_context_destroy(secp256k1_ctx);
wally_cleanup(0);
tal_free(tmpctx);
return 0;
}

5
lightningd/lightningd.c

@ -288,8 +288,7 @@ int main(int argc, char *argv[])
#endif
ld = new_lightningd(NULL);
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
secp256k1_ctx = wally_get_secp_context();
setup_tmpctx();
io_poll_override(debug_poll);
@ -428,6 +427,6 @@ int main(int argc, char *argv[])
memleak_cleanup();
#endif
take_cleanup();
secp256k1_context_destroy(secp256k1_ctx);
wally_cleanup(0);
return 0;
}

8
wallet/test/run-wallet.c

@ -24,6 +24,7 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const c
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <wally_core.h>
bool deprecated_apis = true;
@ -1004,11 +1005,6 @@ int main(void)
take_cleanup();
tal_free(tmpctx);
/* FIXME! https://github.com/ElementsProject/libwally-core/issues/26 */
{
secp256k1_context *secp_ctx(void);
secp256k1_context_destroy(secp_ctx());
}
wally_cleanup(0);
return !ok;
}

Loading…
Cancel
Save