BOLT #5: * * A node: * - once it has broadcast a funding transaction OR sent a commitment signature * for a commitment transaction that contains an HTLC output: * - until all outputs are *irrevocably resolved*: * - MUST monitor the blockchain for transactions that spend any output that * is NOT *irrevocably resolved*. * - MUST *resolve* all outputs, as specified below. *
| 1768 | * reorganizations. |
| 1769 | */ |
| 1770 | static void wait_for_resolved(struct tracked_output **outs) |
| 1771 | { |
| 1772 | billboard_update(outs); |
| 1773 | |
| 1774 | while (num_not_irrevocably_resolved(outs) != 0) { |
| 1775 | const u8 *msg; |
| 1776 | enum onchaind_wire mtype; |
| 1777 | |
| 1778 | if (tal_count(queued_msgs)) { |
| 1779 | msg = tal_steal(outs, queued_msgs[0]); |
| 1780 | tal_arr_remove(&queued_msgs, 0); |
| 1781 | } else |
| 1782 | msg = wire_sync_read(outs, REQ_FD); |
| 1783 | |
| 1784 | mtype = fromwire_peektype(msg); |
| 1785 | status_debug("Got new message %s", onchaind_wire_name(mtype)); |
| 1786 | |
| 1787 | switch (mtype) { |
| 1788 | case WIRE_ONCHAIND_DEPTH: |
| 1789 | handle_onchaind_depth(&outs, msg); |
| 1790 | goto handled; |
| 1791 | case WIRE_ONCHAIND_SPENT: |
| 1792 | handle_onchaind_spent(&outs, msg); |
| 1793 | goto handled; |
| 1794 | case WIRE_ONCHAIND_KNOWN_PREIMAGE: |
| 1795 | handle_onchaind_known_preimage(&outs, msg); |
| 1796 | goto handled; |
| 1797 | case WIRE_ONCHAIND_DEV_MEMLEAK: |
| 1798 | handle_dev_memleak(&outs, msg); |
| 1799 | goto handled; |
| 1800 | |
| 1801 | /* Unexpected messages */ |
| 1802 | case WIRE_ONCHAIND_INIT: |
| 1803 | case WIRE_ONCHAIND_HTLCS: |
| 1804 | case WIRE_ONCHAIND_SPEND_CREATED: |
| 1805 | |
| 1806 | /* We send these, not receive! */ |
| 1807 | case WIRE_ONCHAIND_INIT_REPLY: |
| 1808 | case WIRE_ONCHAIND_SPENT_REPLY: |
| 1809 | case WIRE_ONCHAIND_EXTRACTED_PREIMAGE: |
| 1810 | case WIRE_ONCHAIND_MISSING_HTLC_OUTPUT: |
| 1811 | case WIRE_ONCHAIND_HTLC_TIMEOUT: |
| 1812 | case WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED: |
| 1813 | case WIRE_ONCHAIND_ADD_UTXO: |
| 1814 | case WIRE_ONCHAIND_DEV_MEMLEAK_REPLY: |
| 1815 | case WIRE_ONCHAIND_ANNOTATE_TXOUT: |
| 1816 | case WIRE_ONCHAIND_ANNOTATE_TXIN: |
| 1817 | case WIRE_ONCHAIND_NOTIFY_COIN_MVT: |
| 1818 | case WIRE_ONCHAIND_NOTIFY_PENALTY_ADJ: |
| 1819 | case WIRE_ONCHAIND_SPEND_TO_US: |
| 1820 | case WIRE_ONCHAIND_SPEND_PENALTY: |
| 1821 | case WIRE_ONCHAIND_SPEND_HTLC_SUCCESS: |
| 1822 | case WIRE_ONCHAIND_SPEND_HTLC_TIMEOUT: |
| 1823 | case WIRE_ONCHAIND_SPEND_FULFILL: |
| 1824 | case WIRE_ONCHAIND_SPEND_HTLC_EXPIRED: |
| 1825 | break; |
| 1826 | } |
| 1827 | master_badmsg(-1, msg); |
no test coverage detected