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

Function resolve_our_htlc_theircommit

onchaind/onchaind.c:2102–2133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2100}
2101
2102static size_t resolve_our_htlc_theircommit(struct tracked_output *out,
2103 const size_t *matches,
2104 const struct htlc_stub *htlcs,
2105 u8 **htlc_scripts)
2106{
2107 const u8 *msg;
2108 u32 cltv_expiry = matches_cltv(matches, htlcs);
2109 /* They're all equivalent: might as well use first one. */
2110 const struct htlc_stub *htlc = &htlcs[matches[0]];
2111
2112 /* BOLT #5:
2113 *
2114 * A local node:
2115 * ...
2116 * - if the commitment transaction HTLC output has *timed out* AND NOT
2117 * been *resolved*:
2118 * - MUST *resolve* the output, by spending it to a convenient
2119 * address.
2120 */
2121 msg = towire_onchaind_spend_htlc_expired(NULL,
2122 &out->outpoint, out->sat,
2123 htlc->id,
2124 cltv_expiry,
2125 remote_per_commitment_point,
2126 htlc_scripts[matches[0]]);
2127 propose_resolution_to_master(out, take(msg),
2128 /* nLocktime: we have to be *after* that block! */
2129 cltv_expiry + 1,
2130 OUR_HTLC_TIMEOUT_TO_US);
2131
2132 return matches[0];
2133}
2134
2135/* Returns which htlcs it chose to use of matches[] */
2136static size_t resolve_their_htlc(struct tracked_output *out,

Callers 1

handle_their_unilateralFunction · 0.85

Calls 3

matches_cltvFunction · 0.85

Tested by

no test coverage detected