script: add helper to use a raw witness program.

This is for future compatibility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-26 13:29:19 +10:30
parent 9ec5cb7ba2
commit 20ce829f81
2 changed files with 13 additions and 0 deletions

View File

@ -319,6 +319,15 @@ u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33])
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. */
u8 **bitcoin_witness_2of2(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig1,

View File

@ -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. */
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. */
u8 **bitcoin_witness_2of2(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig1,