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

Function resolve_our_htlc_theircommit

onchaind/onchaind.c:1941–1972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939}
1940
1941static size_t resolve_our_htlc_theircommit(struct tracked_output *out,
1942 const size_t *matches,
1943 const struct htlc_stub *htlcs,
1944 u8 **htlc_scripts)
1945{
1946 const u8 *msg;
1947 u32 cltv_expiry = matches_cltv(matches, htlcs);
1948 /* They're all equivalent: might as well use first one. */
1949 const struct htlc_stub *htlc = &htlcs[matches[0]];
1950
1951 /* BOLT #5:
1952 *
1953 * A local node:
1954 * ...
1955 * - if the commitment transaction HTLC output has *timed out* AND NOT
1956 * been *resolved*:
1957 * - MUST *resolve* the output, by spending it to a convenient
1958 * address.
1959 */
1960 msg = towire_onchaind_spend_htlc_expired(NULL,
1961 &out->outpoint, out->sat,
1962 htlc->id,
1963 cltv_expiry,
1964 remote_per_commitment_point,
1965 htlc_scripts[matches[0]]);
1966 propose_resolution_to_master(out, take(msg),
1967 /* nLocktime: we have to be *after* that block! */
1968 cltv_expiry + 1,
1969 OUR_HTLC_TIMEOUT_TO_US);
1970
1971 return matches[0];
1972}
1973
1974/* Returns which htlcs it chose to use of matches[] */
1975static 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