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 *
| 680 | * OP_ENDIF |
| 681 | */ |
| 682 | u8 *bitcoin_wscript_htlc_offer_ripemd160(const tal_t *ctx, |
| 683 | const struct pubkey *localhtlckey, |
| 684 | const struct pubkey *remotehtlckey, |
| 685 | const struct ripemd160 *payment_ripemd, |
| 686 | const struct pubkey *revocationkey, |
| 687 | bool option_anchor_outputs, |
| 688 | bool option_anchors_zero_fee_htlc_tx) |
| 689 | { |
| 690 | u8 *script = tal_arr(ctx, u8, 0); |
| 691 | struct ripemd160 ripemd; |
| 692 | |
| 693 | add_op(&script, OP_DUP); |
| 694 | add_op(&script, OP_HASH160); |
| 695 | pubkey_to_hash160(revocationkey, &ripemd); |
| 696 | script_push_bytes(&script, &ripemd, sizeof(ripemd)); |
| 697 | add_op(&script, OP_EQUAL); |
| 698 | add_op(&script, OP_IF); |
| 699 | add_op(&script, OP_CHECKSIG); |
| 700 | add_op(&script, OP_ELSE); |
| 701 | add_push_key(&script, remotehtlckey); |
| 702 | add_op(&script, OP_SWAP); |
| 703 | add_op(&script, OP_SIZE); |
| 704 | add_number(&script, 32); |
| 705 | add_op(&script, OP_EQUAL); |
| 706 | add_op(&script, OP_NOTIF); |
| 707 | add_op(&script, OP_DROP); |
| 708 | add_number(&script, 2); |
| 709 | add_op(&script, OP_SWAP); |
| 710 | add_push_key(&script, localhtlckey); |
| 711 | add_number(&script, 2); |
| 712 | add_op(&script, OP_CHECKMULTISIG); |
| 713 | add_op(&script, OP_ELSE); |
| 714 | add_op(&script, OP_HASH160); |
| 715 | script_push_bytes(&script, |
| 716 | payment_ripemd->u.u8, sizeof(payment_ripemd->u.u8)); |
| 717 | add_op(&script, OP_EQUALVERIFY); |
| 718 | add_op(&script, OP_CHECKSIG); |
| 719 | add_op(&script, OP_ENDIF); |
| 720 | if (option_anchor_outputs || option_anchors_zero_fee_htlc_tx) { |
| 721 | add_number(&script, 1); |
| 722 | add_op(&script, OP_CHECKSEQUENCEVERIFY); |
| 723 | add_op(&script, OP_DROP); |
| 724 | } |
| 725 | add_op(&script, OP_ENDIF); |
| 726 | |
| 727 | return script; |
| 728 | } |
| 729 | |
| 730 | u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, |
| 731 | const struct pubkey *localhtlckey, |
no test coverage detected