| 1339 | } |
| 1340 | |
| 1341 | static void update_resolution_depth(struct tracked_output *out, u32 depth) |
| 1342 | { |
| 1343 | bool reached_reasonable_depth; |
| 1344 | |
| 1345 | status_debug("%s/%s->%s depth %u", |
| 1346 | tx_type_name(out->tx_type), |
| 1347 | output_type_name(out->output_type), |
| 1348 | tx_type_name(out->resolved->tx_type), |
| 1349 | depth); |
| 1350 | |
| 1351 | /* We only set this once. */ |
| 1352 | reached_reasonable_depth = (out->resolved->depth < reasonable_depth |
| 1353 | && depth >= reasonable_depth); |
| 1354 | |
| 1355 | /* BOLT #5: |
| 1356 | * |
| 1357 | * - if the commitment transaction HTLC output has *timed out* and |
| 1358 | * hasn't been *resolved*: |
| 1359 | * - MUST *resolve* the output by spending it using the HTLC-timeout |
| 1360 | * transaction. |
| 1361 | * - once the resolving transaction has reached reasonable depth: |
| 1362 | * - MUST fail the corresponding incoming HTLC (if any). |
| 1363 | */ |
| 1364 | if ((out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX |
| 1365 | || out->resolved->tx_type == OUR_HTLC_TIMEOUT_TO_US) |
| 1366 | && reached_reasonable_depth) { |
| 1367 | u8 *msg; |
| 1368 | status_debug("%s/%s reached reasonable depth %u", |
| 1369 | tx_type_name(out->tx_type), |
| 1370 | output_type_name(out->output_type), |
| 1371 | depth); |
| 1372 | msg = towire_onchaind_htlc_timeout(out, &out->htlc); |
| 1373 | wire_sync_write(REQ_FD, take(msg)); |
| 1374 | } |
| 1375 | out->resolved->depth = depth; |
| 1376 | } |
| 1377 | |
| 1378 | static void tx_new_depth(struct tracked_output **outs, |
| 1379 | const struct bitcoin_txid *txid, u32 depth) |
no test coverage detected