Create scriptcode (fake witness, basically) for P2WPKH */
| 391 | |
| 392 | /* Create scriptcode (fake witness, basically) for P2WPKH */ |
| 393 | u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key) |
| 394 | { |
| 395 | struct ripemd160 pkhash; |
| 396 | u8 *script = tal_arr(ctx, u8, 0); |
| 397 | pubkey_to_hash160(key, &pkhash); |
| 398 | |
| 399 | /* BIP143: |
| 400 | * |
| 401 | * For P2WPKH witness program, the scriptCode is |
| 402 | * 0x1976a914{20-byte-pubkey-hash}88ac. |
| 403 | */ |
| 404 | |
| 405 | /* PUSH(25): OP_DUP OP_HASH160 PUSH(20) 20-byte-pubkey-hash |
| 406 | * OP_EQUALVERIFY OP_CHECKSIG */ |
| 407 | add_op(&script, OP_DUP); |
| 408 | add_op(&script, OP_HASH160); |
| 409 | script_push_bytes(&script, &pkhash, sizeof(pkhash)); |
| 410 | add_op(&script, OP_EQUALVERIFY); |
| 411 | add_op(&script, OP_CHECKSIG); |
| 412 | |
| 413 | return script; |
| 414 | } |
| 415 | |
| 416 | bool is_p2pkh(const u8 *script, struct bitcoin_address *addr) |
| 417 | { |
no test coverage detected