| 1833 | } |
| 1834 | |
| 1835 | static bool run_tx_interactive(struct state *state, |
| 1836 | struct tx_state *tx_state, |
| 1837 | struct wally_psbt **orig_psbt, |
| 1838 | enum tx_role our_role) |
| 1839 | { |
| 1840 | /* Opener always sends the first utxo info */ |
| 1841 | bool we_complete = false, they_complete = false; |
| 1842 | u8 *msg; |
| 1843 | struct wally_psbt *psbt = *orig_psbt; |
| 1844 | |
| 1845 | while (!(we_complete && they_complete)) { |
| 1846 | struct channel_id cid; |
| 1847 | enum peer_wire t; |
| 1848 | u64 serial_id; |
| 1849 | bool aborted; |
| 1850 | |
| 1851 | /* Reset their_complete to false every round, |
| 1852 | * they have to re-affirm every time */ |
| 1853 | they_complete = false; |
| 1854 | |
| 1855 | msg = opening_negotiate_msg(tmpctx, state); |
| 1856 | if (!msg) |
| 1857 | return false; |
| 1858 | t = fromwire_peektype(msg); |
| 1859 | switch (t) { |
| 1860 | case WIRE_TX_ADD_INPUT: { |
| 1861 | const u8 *tx_bytes; |
| 1862 | u32 sequence; |
| 1863 | size_t len; |
| 1864 | struct bitcoin_tx *tx; |
| 1865 | struct bitcoin_outpoint outpoint; |
| 1866 | struct amount_sat amt; |
| 1867 | struct tlv_tx_add_input_tlvs *tlvs; |
| 1868 | |
| 1869 | if (!fromwire_tx_add_input(tmpctx, msg, &cid, |
| 1870 | &serial_id, |
| 1871 | cast_const2(u8 **, |
| 1872 | &tx_bytes), |
| 1873 | &outpoint.n, &sequence, |
| 1874 | &tlvs)) |
| 1875 | open_err_fatal(state, |
| 1876 | "Parsing tx_add_input %s", |
| 1877 | tal_hex(tmpctx, msg)); |
| 1878 | |
| 1879 | check_channel_id(state, &cid, &state->channel_id); |
| 1880 | |
| 1881 | /* |
| 1882 | * BOLT #2: |
| 1883 | * The receiving node: ... |
| 1884 | * - MUST fail the negotiation if: ... |
| 1885 | * - if has received 4096 `tx_add_input` |
| 1886 | * messages during this negotiation |
| 1887 | */ |
| 1888 | if (++tx_state->tx_msg_count[TX_ADD_INPUT] > MAX_TX_MSG_RCVD) { |
| 1889 | open_abort(state, "Too many `tx_add_input`s" |
| 1890 | " received %d", MAX_TX_MSG_RCVD); |
| 1891 | return false; |
| 1892 | } |
no test coverage detected