Returns which htlcs it chose to use of matches[] */
| 2437 | |
| 2438 | /* Returns which htlcs it chose to use of matches[] */ |
| 2439 | static size_t resolve_their_htlc(struct tracked_output *out, |
| 2440 | const size_t *matches, |
| 2441 | const struct htlc_stub *htlcs, |
| 2442 | u8 **htlc_scripts) |
| 2443 | { |
| 2444 | size_t which_htlc; |
| 2445 | |
| 2446 | /* BOLT #5: |
| 2447 | * |
| 2448 | * ## HTLC Output Handling: Remote Commitment, Remote Offers |
| 2449 | *... |
| 2450 | * ### Requirements |
| 2451 | *... |
| 2452 | * If not otherwise resolved, once the HTLC output has expired, it is |
| 2453 | * considered *irrevocably resolved*. |
| 2454 | */ |
| 2455 | |
| 2456 | /* BOLT #5: |
| 2457 | * |
| 2458 | * ## HTLC Output Handling: Local Commitment, Remote Offers |
| 2459 | *... |
| 2460 | * ### Requirements |
| 2461 | *... |
| 2462 | * If not otherwise resolved, once the HTLC output has expired, it is |
| 2463 | * considered *irrevocably resolved*. |
| 2464 | */ |
| 2465 | |
| 2466 | /* The two cases are identical as far as default handling goes. |
| 2467 | * But in the remote commitment / remote offer (ie. caller is |
| 2468 | * handle_their_unilateral), htlcs which match may have different cltvs. |
| 2469 | * So wait until the worst case (largest HTLC). */ |
| 2470 | assert(tal_count(matches)); |
| 2471 | which_htlc = matches[0]; |
| 2472 | for (size_t i = 1; i < tal_count(matches); i++) { |
| 2473 | if (htlcs[matches[i]].cltv_expiry > htlcs[which_htlc].cltv_expiry) |
| 2474 | which_htlc = matches[i]; |
| 2475 | } |
| 2476 | |
| 2477 | /* If we hit timeout depth, resolve by ignoring. */ |
| 2478 | propose_resolution_at_block(out, NULL, htlcs[which_htlc].cltv_expiry, |
| 2479 | THEIR_HTLC_TIMEOUT_TO_THEM); |
| 2480 | return which_htlc; |
| 2481 | } |
| 2482 | |
| 2483 | /* Return tal_arr of htlc indexes. */ |
| 2484 | static const size_t *match_htlc_output(const tal_t *ctx, |
no test coverage detected