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

Function steal_htlc_tx

onchaind/onchaind.c:1655–1698  ·  view source on GitHub ↗

BOLT #5: * * - MUST *resolve* the _remote node's HTLC-timeout transaction_ by spending it * using the revocation private key. * - MUST *resolve* the _remote node's HTLC-success transaction_ by spending it * using the revocation private key. */

Source from the content-addressed store, hash-verified

1653 * using the revocation private key.
1654 */
1655static void steal_htlc_tx(struct tracked_output *out,
1656 struct tracked_output ***outs,
1657 const struct tx_parts *htlc_tx,
1658 u32 htlc_tx_blockheight,
1659 enum tx_type htlc_tx_type,
1660 const struct bitcoin_outpoint *htlc_outpoint)
1661{
1662 struct bitcoin_tx *tx;
1663 enum tx_type tx_type = OUR_PENALTY_TX;
1664 struct tracked_output *htlc_out;
1665 struct amount_asset asset;
1666 struct amount_sat htlc_out_amt;
1667
1668 u8 *wscript = bitcoin_wscript_htlc_tx(htlc_tx, to_self_delay[REMOTE],
1669 &keyset->self_revocation_key,
1670 &keyset->self_delayed_payment_key);
1671
1672 asset = wally_tx_output_get_amount(htlc_tx->outputs[htlc_outpoint->n]);
1673 assert(amount_asset_is_main(&asset));
1674 htlc_out_amt = amount_asset_to_sat(&asset);
1675
1676 htlc_out = new_tracked_output(outs,
1677 htlc_outpoint, htlc_tx_blockheight,
1678 htlc_tx_type,
1679 htlc_out_amt,
1680 DELAYED_CHEAT_OUTPUT_TO_THEM,
1681 &out->htlc, wscript, NULL);
1682 /* BOLT #3:
1683 *
1684 * To spend this via penalty, the remote node uses a witness stack
1685 * `<revocationsig> 1`
1686 */
1687 tx = tx_to_us(htlc_out, penalty_to_us, htlc_out,
1688 BITCOIN_TX_RBF_SEQUENCE, 0,
1689 &ONE, sizeof(ONE),
1690 htlc_out->wscript,
1691 &tx_type, penalty_feerate);
1692
1693 /* mark commitment tx htlc output as 'resolved by them' */
1694 resolved_by_other(out, &htlc_tx->txid, htlc_tx_type);
1695
1696 /* annnd done! */
1697 propose_resolution(htlc_out, tx, 0, tx_type);
1698}
1699
1700static void onchain_annotate_txout(const struct bitcoin_outpoint *outpoint,
1701 enum wallet_tx_type type)

Callers 1

output_spentFunction · 0.85

Calls 8

bitcoin_wscript_htlc_txFunction · 0.85
new_tracked_outputFunction · 0.85
tx_to_usFunction · 0.85
resolved_by_otherFunction · 0.85
propose_resolutionFunction · 0.85
amount_asset_is_mainFunction · 0.50
amount_asset_to_satFunction · 0.50

Tested by

no test coverage detected