MCPcopy Create free account
hub / github.com/ElementsProject/lightning / tx_new_depth

Function tx_new_depth

onchaind/onchaind.c:1378–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1376}
1377
1378static void tx_new_depth(struct tracked_output **outs,
1379 const struct bitcoin_txid *txid, u32 depth)
1380{
1381 size_t i;
1382
1383 /* BOLT #5:
1384 * - for any committed HTLC that does NOT have an output in this
1385 * commitment transaction:
1386 *...
1387 * - otherwise:
1388 * - once the commitment transaction has reached reasonable depth:
1389 * - MUST fail the corresponding incoming HTLC (if any).
1390 */
1391 if (bitcoin_txid_eq(&outs[0]->resolved->txid, txid)
1392 && depth >= reasonable_depth
1393 && missing_htlc_msgs) {
1394 status_debug("Sending %zu missing htlc messages",
1395 tal_count(missing_htlc_msgs));
1396 for (i = 0; i < tal_count(missing_htlc_msgs); i++)
1397 wire_sync_write(REQ_FD, missing_htlc_msgs[i]);
1398 /* Don't do it again. */
1399 missing_htlc_msgs = tal_free(missing_htlc_msgs);
1400 }
1401
1402 for (i = 0; i < tal_count(outs); i++) {
1403 /* Is this tx resolving an output? */
1404 if (outs[i]->resolved) {
1405 if (bitcoin_txid_eq(&outs[i]->resolved->txid, txid)) {
1406 update_resolution_depth(outs[i], depth);
1407 }
1408 continue;
1409 }
1410
1411 /* Does it match this output? */
1412 if (!bitcoin_txid_eq(&outs[i]->outpoint.txid, txid))
1413 continue;
1414
1415 outs[i]->depth = depth;
1416
1417 /* Are we supposed to ignore it now? */
1418 if (outs[i]->proposal
1419 && depth >= outs[i]->proposal->depth_required
1420 && !outs[i]->proposal->welements) {
1421 ignore_output(outs[i]);
1422
1423 if (outs[i]->proposal->tx_type == THEIR_HTLC_TIMEOUT_TO_THEM)
1424 record_external_deposit(outs[i], outs[i]->tx_blockheight,
1425 mk_mvt_tags(MVT_HTLC_TIMEOUT));
1426 }
1427 }
1428}
1429
1430/* BOLT #5:
1431 *

Callers 1

handle_onchaind_depthFunction · 0.85

Calls 5

tal_freeFunction · 0.85
update_resolution_depthFunction · 0.85
ignore_outputFunction · 0.85
record_external_depositFunction · 0.85
wire_sync_writeFunction · 0.50

Tested by

no test coverage detected