base58, script, protobuf_convert: don't use temporary secp256k1 context.

We use libsecp256k1 to convert signatures to DER; we were creating a
temporary one, but we really should be handing the one we have in dstate
through.  This does that, everywhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-07-01 11:19:28 +09:30
parent a35055c699
commit 69cb158edd
18 changed files with 63 additions and 40 deletions

View File

@@ -43,6 +43,7 @@ u8 *bitcoin_redeem_p2wpkh(const tal_t *ctx, const struct pubkey *key);
/* Create a witness which spends the 2of2. */
void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
secp256k1_context *secpctx,
struct bitcoin_tx_input *input,
const struct bitcoin_signature *sig,
const struct pubkey *key);
@@ -76,6 +77,7 @@ u8 *scriptpubkey_p2wpkh(const tal_t *ctx, const struct pubkey *key);
/* Create a witness which spends the 2of2. */
u8 **bitcoin_witness_2of2(const tal_t *ctx,
secp256k1_context *secpctx,
const struct bitcoin_signature *sig1,
const struct bitcoin_signature *sig2,
const struct pubkey *key1,
@@ -83,12 +85,14 @@ u8 **bitcoin_witness_2of2(const tal_t *ctx,
/* Create a witness which spends a "secret_or_delay" scriptpubkey */
u8 **bitcoin_witness_secret(const tal_t *ctx,
secp256k1_context *secpctx,
const void *secret, size_t secret_len,
const struct bitcoin_signature *sig,
const u8 *witnessscript);
/* Create a witness which spends bitcoin_redeeem_htlc_recv/send */
u8 **bitcoin_witness_htlc(const tal_t *ctx,
secp256k1_context *secpctx,
const void *htlc_or_revocation_preimage,
const struct bitcoin_signature *sig,
const u8 *witnessscript);