bitcoin/script: bitcoin_witness_p2wpkh()

For the wallet code to use for change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-02-21 15:15:29 +10:30
parent 08e95d59b5
commit 82f5b3ad51
2 changed files with 20 additions and 0 deletions

View File

@@ -281,6 +281,21 @@ void bitcoin_witness_p2sh_p2wpkh(const tal_t *ctx,
input->witness[1] = stack_key(input->witness, key);
}
u8 **bitcoin_witness_p2wpkh(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig,
const struct pubkey *key)
{
u8 **witness;
/* BIP141: The witness must consist of exactly 2 items (≤ 520
* bytes each). The first one a signature, and the second one
* a public key. */
witness = tal_arr(ctx, u8 *, 2);
witness[0] = stack_sig(witness, sig);
witness[1] = stack_key(witness, key);
return witness;
}
/* Create an output script for a 32-byte witness. */
u8 *scriptpubkey_p2wsh(const tal_t *ctx, const u8 *witnessscript)
{