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