An output has been spent: see if it resolves something we care about. */
| 1713 | |
| 1714 | /* An output has been spent: see if it resolves something we care about. */ |
| 1715 | static void output_spent(struct tracked_output ***outs, |
| 1716 | const struct tx_parts *tx_parts, |
| 1717 | u32 input_num, |
| 1718 | u32 tx_blockheight) |
| 1719 | { |
| 1720 | for (size_t i = 0; i < tal_count(*outs); i++) { |
| 1721 | struct tracked_output *out = (*outs)[i]; |
| 1722 | struct bitcoin_outpoint htlc_outpoint; |
| 1723 | |
| 1724 | if (out->resolved) |
| 1725 | continue; |
| 1726 | |
| 1727 | if (!wally_tx_input_spends(tx_parts->inputs[input_num], |
| 1728 | &out->outpoint)) |
| 1729 | continue; |
| 1730 | |
| 1731 | /* Was this our resolution? */ |
| 1732 | if (resolved_by_proposal(out, tx_parts)) { |
| 1733 | /* If it's our htlc tx, we need to resolve that, too. */ |
| 1734 | if (out->resolved->tx_type == OUR_HTLC_SUCCESS_TX |
| 1735 | || out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX) |
| 1736 | resolve_htlc_tx(outs, i, tx_parts, input_num, |
| 1737 | tx_blockheight); |
| 1738 | |
| 1739 | record_coin_movements(out, tx_blockheight, |
| 1740 | out->proposal->tx, |
| 1741 | &tx_parts->txid); |
| 1742 | return; |
| 1743 | } |
| 1744 | |
| 1745 | htlc_outpoint.txid = tx_parts->txid; |
| 1746 | htlc_outpoint.n = input_num; |
| 1747 | |
| 1748 | switch (out->output_type) { |
| 1749 | case OUTPUT_TO_US: |
| 1750 | case DELAYED_OUTPUT_TO_US: |
| 1751 | unknown_spend(out, tx_parts); |
| 1752 | record_external_deposit(out, out->tx_blockheight, |
| 1753 | PENALIZED); |
| 1754 | break; |
| 1755 | |
| 1756 | case THEIR_HTLC: |
| 1757 | if (out->tx_type == THEIR_REVOKED_UNILATERAL) { |
| 1758 | enum mvt_tag *tags; |
| 1759 | tags = new_tag_arr(NULL, HTLC_TIMEOUT); |
| 1760 | tal_arr_expand(&tags, STEALABLE); |
| 1761 | |
| 1762 | record_external_deposit_tags(out, out->tx_blockheight, |
| 1763 | /* This takes tags */ |
| 1764 | tal_dup_talarr(NULL, |
| 1765 | enum mvt_tag, |
| 1766 | tags)); |
| 1767 | record_external_spend_tags(&tx_parts->txid, |
| 1768 | out, |
| 1769 | tx_blockheight, |
| 1770 | tags); |
| 1771 | |
| 1772 | /* we've actually got a 'new' output here */ |
no test coverage detected