| 1712 | } |
| 1713 | |
| 1714 | static bool run_tx_interactive(struct state *state, |
| 1715 | struct tx_state *tx_state, |
| 1716 | struct wally_psbt **orig_psbt, |
| 1717 | enum tx_role our_role) |
| 1718 | { |
| 1719 | /* Opener always sends the first utxo info */ |
| 1720 | bool we_complete = false, they_complete = false; |
| 1721 | u8 *msg; |
| 1722 | struct wally_psbt *psbt = *orig_psbt; |
| 1723 | |
| 1724 | while (!(we_complete && they_complete)) { |
| 1725 | struct channel_id cid; |
| 1726 | enum peer_wire t; |
| 1727 | u64 serial_id; |
| 1728 | bool aborted; |
| 1729 | |
| 1730 | /* Reset their_complete to false every round, |
| 1731 | * they have to re-affirm every time */ |
| 1732 | they_complete = false; |
| 1733 | |
| 1734 | msg = opening_negotiate_msg(tmpctx, state); |
| 1735 | if (!msg) |
| 1736 | return false; |
| 1737 | t = fromwire_peektype(msg); |
| 1738 | switch (t) { |
| 1739 | case WIRE_TX_ADD_INPUT: { |
| 1740 | const u8 *tx_bytes; |
| 1741 | u32 sequence; |
| 1742 | size_t len; |
| 1743 | struct bitcoin_tx *tx; |
| 1744 | struct bitcoin_outpoint outpoint; |
| 1745 | struct amount_sat amt; |
| 1746 | struct tlv_tx_add_input_tlvs *tlvs; |
| 1747 | |
| 1748 | if (!fromwire_tx_add_input(tmpctx, msg, &cid, |
| 1749 | &serial_id, |
| 1750 | cast_const2(u8 **, |
| 1751 | &tx_bytes), |
| 1752 | &outpoint.n, &sequence, |
| 1753 | &tlvs)) |
| 1754 | open_err_fatal(state, |
| 1755 | "Parsing tx_add_input %s", |
| 1756 | tal_hex(tmpctx, msg)); |
| 1757 | |
| 1758 | check_channel_id(state, &cid, &state->channel_id); |
| 1759 | |
| 1760 | /* |
| 1761 | * BOLT #2: |
| 1762 | * The receiving node: ... |
| 1763 | * - MUST fail the negotiation if: ... |
| 1764 | * - if has received 4096 `tx_add_input` |
| 1765 | * messages during this negotiation |
| 1766 | */ |
| 1767 | if (++tx_state->tx_msg_count[TX_ADD_INPUT] > MAX_TX_MSG_RCVD) { |
| 1768 | open_abort(state, "Too many `tx_add_input`s" |
| 1769 | " received %d", MAX_TX_MSG_RCVD); |
| 1770 | return false; |
| 1771 | } |
no test coverage detected