MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitcoin_wscript_htlc_receive_ripemd

Function bitcoin_wscript_htlc_receive_ripemd

bitcoin/script.c:795–845  ·  view source on GitHub ↗

BOLT #3: * * #### Received HTLC Outputs * * This output sends funds to either the remote node after the HTLC-timeout or * using the revocation key, or to an HTLC-success transaction with a * successful payment preimage. The output is a P2WSH, with a witness script * (no `option_anchors`): * * # To remote node with revocation key * OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpub

Source from the content-addressed store, hash-verified

793 * OP_ENDIF
794 */
795u8 *bitcoin_wscript_htlc_receive_ripemd(const tal_t *ctx,
796 const struct abs_locktime *htlc_abstimeout,
797 const struct pubkey *localhtlckey,
798 const struct pubkey *remotehtlckey,
799 const struct ripemd160 *payment_ripemd,
800 const struct pubkey *revocationkey,
801 bool option_anchor_outputs,
802 bool option_anchors_zero_fee_htlc_tx)
803{
804 u8 *script = tal_arr(ctx, u8, 0);
805 struct ripemd160 ripemd;
806
807 add_op(&script, OP_DUP);
808 add_op(&script, OP_HASH160);
809 pubkey_to_hash160(revocationkey, &ripemd);
810 script_push_bytes(&script, &ripemd, sizeof(ripemd));
811 add_op(&script, OP_EQUAL);
812 add_op(&script, OP_IF);
813 add_op(&script, OP_CHECKSIG);
814 add_op(&script, OP_ELSE);
815 add_push_key(&script, remotehtlckey);
816 add_op(&script, OP_SWAP);
817 add_op(&script, OP_SIZE);
818 add_number(&script, 32);
819 add_op(&script, OP_EQUAL);
820 add_op(&script, OP_IF);
821 add_op(&script, OP_HASH160);
822 script_push_bytes(&script,
823 payment_ripemd->u.u8, sizeof(payment_ripemd->u.u8));
824 add_op(&script, OP_EQUALVERIFY);
825 add_number(&script, 2);
826 add_op(&script, OP_SWAP);
827 add_push_key(&script, localhtlckey);
828 add_number(&script, 2);
829 add_op(&script, OP_CHECKMULTISIG);
830 add_op(&script, OP_ELSE);
831 add_op(&script, OP_DROP);
832 add_number(&script, htlc_abstimeout->locktime);
833 add_op(&script, OP_CHECKLOCKTIMEVERIFY);
834 add_op(&script, OP_DROP);
835 add_op(&script, OP_CHECKSIG);
836 add_op(&script, OP_ENDIF);
837 if (option_anchor_outputs || option_anchors_zero_fee_htlc_tx) {
838 add_number(&script, 1);
839 add_op(&script, OP_CHECKSEQUENCEVERIFY);
840 add_op(&script, OP_DROP);
841 }
842 add_op(&script, OP_ENDIF);
843
844 return script;
845}
846
847u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
848 const struct abs_locktime *htlc_abstimeout,

Callers 2

htlc_received_wscriptFunction · 0.85

Calls 5

add_opFunction · 0.85
pubkey_to_hash160Function · 0.85
script_push_bytesFunction · 0.85
add_push_keyFunction · 0.85
add_numberFunction · 0.85

Tested by

no test coverage detected