Browse Source

bitcoin/script: bitcoin_witness_p2wpkh()

For the wallet code to use for change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
82f5b3ad51
  1. 15
      bitcoin/script.c
  2. 5
      bitcoin/script.h

15
bitcoin/script.c

@ -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)
{

5
bitcoin/script.h

@ -85,6 +85,11 @@ u8 **bitcoin_witness_2of2(const tal_t *ctx,
const struct pubkey *key1,
const struct pubkey *key2);
/* Create a witness which spends a p2wpkh. */
u8 **bitcoin_witness_p2wpkh(const tal_t *ctx,
const secp256k1_ecdsa_signature *sig,
const struct pubkey *key);
/* Create a witness which spends a "secret_or_delay" scriptpubkey */
u8 **bitcoin_witness_secret(const tal_t *ctx,
const void *secret, size_t secret_len,

Loading…
Cancel
Save