Returns which htlcs it chose to use of matches[] */
| 1973 | |
| 1974 | /* Returns which htlcs it chose to use of matches[] */ |
| 1975 | static size_t resolve_their_htlc(struct tracked_output *out, |
| 1976 | const size_t *matches, |
| 1977 | const struct htlc_stub *htlcs, |
| 1978 | u8 **htlc_scripts) |
| 1979 | { |
| 1980 | size_t which_htlc; |
| 1981 | |
| 1982 | /* BOLT #5: |
| 1983 | * |
| 1984 | * If not otherwise resolved, once the HTLC output has expired, it is |
| 1985 | * considered *irrevocably resolved*. |
| 1986 | */ |
| 1987 | |
| 1988 | /* BOLT #5: |
| 1989 | * |
| 1990 | * If it's NOT otherwise resolved, once the HTLC output has expired, it is |
| 1991 | * considered *irrevocably resolved*. |
| 1992 | */ |
| 1993 | |
| 1994 | /* The two cases are identical as far as default handling goes. |
| 1995 | * But in the remote commitment / remote offer (ie. caller is |
| 1996 | * handle_their_unilateral), htlcs which match may have different cltvs. |
| 1997 | * So wait until the worst case (largest HTLC). */ |
| 1998 | assert(tal_count(matches)); |
| 1999 | which_htlc = matches[0]; |
| 2000 | for (size_t i = 1; i < tal_count(matches); i++) { |
| 2001 | if (htlcs[matches[i]].cltv_expiry > htlcs[which_htlc].cltv_expiry) |
| 2002 | which_htlc = matches[i]; |
| 2003 | } |
| 2004 | |
| 2005 | /* If we hit timeout depth, resolve by ignoring. */ |
| 2006 | propose_ignore(out, htlcs[which_htlc].cltv_expiry, |
| 2007 | THEIR_HTLC_TIMEOUT_TO_THEM); |
| 2008 | return which_htlc; |
| 2009 | } |
| 2010 | |
| 2011 | /* Return tal_arr of htlc indexes. */ |
| 2012 | static const size_t *match_htlc_output(const tal_t *ctx, |
no test coverage detected