BOLT #3: * * #### Offered HTLC Outputs * * This output sends funds to either an HTLC-timeout transaction after the * HTLC-timeout or to the remote node using the payment preimage or the * revocation key. The output is a P2WSH, with a witness script (no * option_anchors): * * # To remote node with revocation key * OP_DUP OP_HASH160 OP_EQUAL *
| 602 | * OP_ENDIF |
| 603 | */ |
| 604 | u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, |
| 605 | const struct pubkey *localhtlckey, |
| 606 | const struct pubkey *remotehtlckey, |
| 607 | const struct ripemd160 *payment_ripemd, |
| 608 | const struct pubkey *revocationkey, |
| 609 | bool option_anchor_outputs) |
| 610 | { |
| 611 | u8 *script = tal_arr(ctx, u8, 0); |
| 612 | struct ripemd160 ripemd; |
| 613 | |
| 614 | add_op(&script, OP_DUP); |
| 615 | add_op(&script, OP_HASH160); |
| 616 | pubkey_to_hash160(revocationkey, &ripemd); |
| 617 | script_push_bytes(&script, &ripemd, sizeof(ripemd)); |
| 618 | add_op(&script, OP_EQUAL); |
| 619 | add_op(&script, OP_IF); |
| 620 | add_op(&script, OP_CHECKSIG); |
| 621 | add_op(&script, OP_ELSE); |
| 622 | add_push_key(&script, remotehtlckey); |
| 623 | add_op(&script, OP_SWAP); |
| 624 | add_op(&script, OP_SIZE); |
| 625 | add_number(&script, 32); |
| 626 | add_op(&script, OP_EQUAL); |
| 627 | add_op(&script, OP_NOTIF); |
| 628 | add_op(&script, OP_DROP); |
| 629 | add_number(&script, 2); |
| 630 | add_op(&script, OP_SWAP); |
| 631 | add_push_key(&script, localhtlckey); |
| 632 | add_number(&script, 2); |
| 633 | add_op(&script, OP_CHECKMULTISIG); |
| 634 | add_op(&script, OP_ELSE); |
| 635 | add_op(&script, OP_HASH160); |
| 636 | script_push_bytes(&script, |
| 637 | payment_ripemd->u.u8, sizeof(payment_ripemd->u.u8)); |
| 638 | add_op(&script, OP_EQUALVERIFY); |
| 639 | add_op(&script, OP_CHECKSIG); |
| 640 | add_op(&script, OP_ENDIF); |
| 641 | if (option_anchor_outputs) { |
| 642 | add_number(&script, 1); |
| 643 | add_op(&script, OP_CHECKSEQUENCEVERIFY); |
| 644 | add_op(&script, OP_DROP); |
| 645 | } |
| 646 | add_op(&script, OP_ENDIF); |
| 647 | |
| 648 | return script; |
| 649 | } |
| 650 | |
| 651 | u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, |
| 652 | const struct pubkey *localhtlckey, |
no test coverage detected