mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
bitcoin: hand in a secp256k1_context to all routines.
We don't want to re-create them internally, ever. The test-cli tools are patched to generate them all the time, but they're not performance critical. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -109,11 +109,13 @@ static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig)
|
||||
/* Bitcoin wants DER encoding. */
|
||||
#ifdef SCRIPTS_USE_DER
|
||||
u8 der[73];
|
||||
size_t len = signature_to_der(der, &sig->sig);
|
||||
secp256k1_context *secpctx = secp256k1_context_create(0);
|
||||
size_t len = signature_to_der(secpctx, der, &sig->sig);
|
||||
|
||||
/* Append sighash type */
|
||||
der[len++] = sig->stype;
|
||||
add_push_bytes(scriptp, der, len);
|
||||
secp256k1_context_destroy(secpctx);
|
||||
#else /* Alpha uses raw encoding */
|
||||
u8 with_sighash[sizeof(sig->sig) + 1];
|
||||
memcpy(with_sighash, &sig->sig, sizeof(sig->sig));
|
||||
|
||||
Reference in New Issue
Block a user