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

Function bitcoin_wscript_to_local

bitcoin/script.c:620–636  ·  view source on GitHub ↗

BOLT #3: * * This output sends funds back to the owner of this commitment transaction and * thus must be timelocked using `OP_CHECKSEQUENCEVERIFY`. It can be claimed, without delay, * by the other party if they know the revocation private key. The output is a * version-0 P2WSH, with a witness script: * * OP_IF * # Penalty transaction * * OP_ELSE

Source from the content-addressed store, hash-verified

618 * OP_CHECKSIG
619 */
620u8 *bitcoin_wscript_to_local(const tal_t *ctx, u16 to_self_delay,
621 u32 lease_remaining,
622 const struct pubkey *revocation_pubkey,
623 const struct pubkey *local_delayedkey)
624{
625 u8 *script = tal_arr(ctx, u8, 0);
626 add_op(&script, OP_IF);
627 add_push_key(&script, revocation_pubkey);
628 add_op(&script, OP_ELSE);
629 add_number(&script, max_unsigned(lease_remaining, to_self_delay));
630 add_op(&script, OP_CHECKSEQUENCEVERIFY);
631 add_op(&script, OP_DROP);
632 add_push_key(&script, local_delayedkey);
633 add_op(&script, OP_ENDIF);
634 add_op(&script, OP_CHECKSIG);
635 return script;
636}
637
638/* BOLT #3:
639 *

Callers 3

steal_to_them_outputFunction · 0.85
penalty_tx_createFunction · 0.85
to_self_wscriptFunction · 0.85

Calls 3

add_opFunction · 0.85
add_push_keyFunction · 0.85
add_numberFunction · 0.85

Tested by

no test coverage detected