Create scriptcode (fake witness, basically) for P2WPKH */
| 453 | |
| 454 | /* Create scriptcode (fake witness, basically) for P2WPKH */ |
| 455 | u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key) |
| 456 | { |
| 457 | struct ripemd160 pkhash; |
| 458 | u8 *script = tal_arr(ctx, u8, 0); |
| 459 | pubkey_to_hash160(key, &pkhash); |
| 460 | |
| 461 | /* BIP143: |
| 462 | * |
| 463 | * For P2WPKH witness program, the scriptCode is |
| 464 | * 0x1976a914{20-byte-pubkey-hash}88ac. |
| 465 | */ |
| 466 | |
| 467 | /* PUSH(25): OP_DUP OP_HASH160 PUSH(20) 20-byte-pubkey-hash |
| 468 | * OP_EQUALVERIFY OP_CHECKSIG */ |
| 469 | add_op(&script, OP_DUP); |
| 470 | add_op(&script, OP_HASH160); |
| 471 | script_push_bytes(&script, &pkhash, sizeof(pkhash)); |
| 472 | add_op(&script, OP_EQUALVERIFY); |
| 473 | add_op(&script, OP_CHECKSIG); |
| 474 | |
| 475 | return script; |
| 476 | } |
| 477 | |
| 478 | bool is_p2pkh(const u8 *script, size_t script_len, struct bitcoin_address *addr) |
| 479 | { |
no test coverage detected