Create an output script for a 32-byte witness. */
| 267 | |
| 268 | /* Create an output script for a 32-byte witness. */ |
| 269 | u8 *scriptpubkey_p2wsh(const tal_t *ctx, const u8 *witnessscript) |
| 270 | { |
| 271 | struct sha256 h; |
| 272 | u8 *script = tal_arr(ctx, u8, 0); |
| 273 | |
| 274 | add_op(&script, OP_0); |
| 275 | sha256(&h, witnessscript, tal_count(witnessscript)); |
| 276 | script_push_bytes(&script, h.u.u8, sizeof(h.u.u8)); |
| 277 | assert(tal_count(script) == BITCOIN_SCRIPTPUBKEY_P2WSH_LEN); |
| 278 | return script; |
| 279 | } |
| 280 | |
| 281 | /* Create an output script for a 20-byte witness. */ |
| 282 | u8 *scriptpubkey_p2wpkh(const tal_t *ctx, const struct pubkey *key) |