Create the redeemscript for a P2SH + P2WPKH (for signing tx) */
| 212 | |
| 213 | /* Create the redeemscript for a P2SH + P2WPKH (for signing tx) */ |
| 214 | u8 *bitcoin_redeem_p2sh_p2wpkh(const tal_t *ctx, const struct pubkey *key) |
| 215 | { |
| 216 | struct ripemd160 keyhash; |
| 217 | u8 *script = tal_arr(ctx, u8, 0); |
| 218 | |
| 219 | /* BIP141: BIP16 redeemScript pushed in the scriptSig is exactly a |
| 220 | * push of a version byte plus a push of a witness program. */ |
| 221 | add_number(&script, 0); |
| 222 | pubkey_to_hash160(key, &keyhash); |
| 223 | script_push_bytes(&script, &keyhash, sizeof(keyhash)); |
| 224 | |
| 225 | assert(tal_count(script) == BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN); |
| 226 | return script; |
| 227 | } |
| 228 | |
| 229 | u8 *bitcoin_scriptsig_redeem(const tal_t *ctx, |
| 230 | const u8 *redeemscript TAKES) |
no test coverage detected