| 2100 | } |
| 2101 | |
| 2102 | static 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[] */ |
| 2136 | static size_t resolve_their_htlc(struct tracked_output *out, |
no test coverage detected