diff --git a/bitcoin/script.c b/bitcoin/script.c index 108e17c09..22f5bd24d 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -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, diff --git a/bitcoin/script.h b/bitcoin/script.h index d0cc224ec..f894e9ee6 100644 --- a/bitcoin/script.h +++ b/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. */ u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33]); +/* Encode an arbitrary witness as */ +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,