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

Function run_tx_interactive

openingd/dualopend.c:1806–2198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1804}
1805
1806static bool run_tx_interactive(struct state *state,
1807 struct tx_state *tx_state,
1808 struct wally_psbt **orig_psbt,
1809 enum tx_role our_role)
1810{
1811 /* Opener always sends the first utxo info */
1812 bool we_complete = false, they_complete = false;
1813 u8 *msg;
1814 struct wally_psbt *psbt = *orig_psbt;
1815
1816 while (!(we_complete && they_complete)) {
1817 struct channel_id cid;
1818 enum peer_wire t;
1819 u64 serial_id;
1820 bool aborted;
1821
1822 /* Reset their_complete to false every round,
1823 * they have to re-affirm every time */
1824 they_complete = false;
1825
1826 msg = opening_negotiate_msg(tmpctx, state);
1827 if (!msg)
1828 return false;
1829 t = fromwire_peektype(msg);
1830 switch (t) {
1831 case WIRE_TX_ADD_INPUT: {
1832 const u8 *tx_bytes;
1833 u32 sequence;
1834 size_t len;
1835 struct bitcoin_tx *tx;
1836 struct bitcoin_outpoint outpoint;
1837 struct amount_sat amt;
1838 struct tlv_tx_add_input_tlvs *tlvs;
1839
1840 if (!fromwire_tx_add_input(tmpctx, msg, &cid,
1841 &serial_id,
1842 cast_const2(u8 **,
1843 &tx_bytes),
1844 &outpoint.n, &sequence,
1845 &tlvs))
1846 open_err_fatal(state,
1847 "Parsing tx_add_input %s",
1848 tal_hex(tmpctx, msg));
1849
1850 check_channel_id(state, &cid, &state->channel_id);
1851
1852 /*
1853 * BOLT #2:
1854 * The receiving node: ...
1855 * - MUST fail the negotiation if: ...
1856 * - if has received 4096 `tx_add_input`
1857 * messages during this negotiation
1858 */
1859 if (++tx_state->tx_msg_count[TX_ADD_INPUT] > MAX_TX_MSG_RCVD) {
1860 open_abort(state, "Too many `tx_add_input`s"
1861 " received %d", MAX_TX_MSG_RCVD);
1862 return false;
1863 }

Callers 3

accepter_startFunction · 0.85
opener_startFunction · 0.85
rbf_wrap_upFunction · 0.85

Calls 15

fromwire_peektypeFunction · 0.85
open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
check_channel_idFunction · 0.85
open_abortFunction · 0.85
psbt_find_serial_inputFunction · 0.85
tal_bytelenFunction · 0.85
pull_bitcoin_tx_onlyFunction · 0.85
fmt_bitcoin_txFunction · 0.85
psbt_has_inputFunction · 0.85
fmt_bitcoin_outpointFunction · 0.85
psbt_append_inputFunction · 0.85

Tested by

no test coverage detected