Browse Source

script: add helper to use a raw witness program.

This is for future compatibility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
20ce829f81
  1. 9
      bitcoin/script.c
  2. 4
      bitcoin/script.h

9
bitcoin/script.c

@ -319,6 +319,15 @@ u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33])
return script; return script;
} }
u8 *scriptpubkey_witness_raw(const tal_t *ctx, u8 version,
const u8 *wprog, size_t wprog_size)
{
u8 *script = tal_arr(ctx, u8, 0);
add_number(&script, version);
add_push_bytes(&script, wprog, wprog_size);
return script;
}
/* Create a witness which spends the 2of2. */ /* Create a witness which spends the 2of2. */
u8 **bitcoin_witness_2of2(const tal_t *ctx, u8 **bitcoin_witness_2of2(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig1, const secp256k1_ecdsa_signature *sig1,

4
bitcoin/script.h

@ -57,6 +57,10 @@ u8 *scriptpubkey_p2wpkh(const tal_t *ctx, const struct pubkey *key);
/* Same as above, but compressed key is already DER-encoded. */ /* Same as above, but compressed key is already DER-encoded. */
u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33]); u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33]);
/* Encode an arbitrary witness as <version> <push:wprog> */
u8 *scriptpubkey_witness_raw(const tal_t *ctx, u8 version,
const u8 *wprog, size_t wprog_size);
/* Create a witness which spends the 2of2. */ /* Create a witness which spends the 2of2. */
u8 **bitcoin_witness_2of2(const tal_t *ctx, u8 **bitcoin_witness_2of2(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig1, const secp256k1_ecdsa_signature *sig1,

Loading…
Cancel
Save