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

Function bitcoin_wscript_to_local

bitcoin/script.c:542–558  ·  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

540 * OP_CHECKSIG
541 */
542u8 *bitcoin_wscript_to_local(const tal_t *ctx, u16 to_self_delay,
543 u32 lease_remaining,
544 const struct pubkey *revocation_pubkey,
545 const struct pubkey *local_delayedkey)
546{
547 u8 *script = tal_arr(ctx, u8, 0);
548 add_op(&script, OP_IF);
549 add_push_key(&script, revocation_pubkey);
550 add_op(&script, OP_ELSE);
551 add_number(&script, max_unsigned(lease_remaining, to_self_delay));
552 add_op(&script, OP_CHECKSEQUENCEVERIFY);
553 add_op(&script, OP_DROP);
554 add_push_key(&script, local_delayedkey);
555 add_op(&script, OP_ENDIF);
556 add_op(&script, OP_CHECKSIG);
557 return script;
558}
559
560/* BOLT #3:
561 *

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