| 1468 | } |
| 1469 | |
| 1470 | static void update_resolution_depth(struct tracked_output *out, u32 depth) |
| 1471 | { |
| 1472 | bool reached_reasonable_depth; |
| 1473 | |
| 1474 | status_debug("%s/%s->%s depth %u", |
| 1475 | tx_type_name(out->tx_type), |
| 1476 | output_type_name(out->output_type), |
| 1477 | tx_type_name(out->resolved->tx_type), |
| 1478 | depth); |
| 1479 | |
| 1480 | /* We only set this once. */ |
| 1481 | reached_reasonable_depth = (out->resolved->depth < reasonable_depth |
| 1482 | && depth >= reasonable_depth); |
| 1483 | |
| 1484 | /* BOLT #5: |
| 1485 | * |
| 1486 | * - if the commitment transaction HTLC output has *timed out* and |
| 1487 | * hasn't been *resolved*: |
| 1488 | * - MUST *resolve* the output by spending it using the HTLC-timeout |
| 1489 | * transaction. |
| 1490 | * - once the resolving transaction has reached reasonable depth: |
| 1491 | * - MUST fail the corresponding incoming HTLC (if any). |
| 1492 | */ |
| 1493 | if ((out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX |
| 1494 | || out->resolved->tx_type == OUR_HTLC_TIMEOUT_TO_US) |
| 1495 | && reached_reasonable_depth) { |
| 1496 | u8 *msg; |
| 1497 | status_debug("%s/%s reached reasonable depth %u", |
| 1498 | tx_type_name(out->tx_type), |
| 1499 | output_type_name(out->output_type), |
| 1500 | depth); |
| 1501 | msg = towire_onchaind_htlc_timeout(out, &out->htlc); |
| 1502 | wire_sync_write(REQ_FD, take(msg)); |
| 1503 | } |
| 1504 | out->resolved->depth = depth; |
| 1505 | } |
| 1506 | |
| 1507 | static void tx_new_depth(struct tracked_output **outs, |
| 1508 | const struct bitcoin_txid *txid, u32 depth) |
no test coverage detected