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

Function run_tx_interactive

openingd/dualopend.c:1312–1661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1310}
1311
1312static bool run_tx_interactive(struct state *state,
1313 struct tx_state *tx_state,
1314 struct wally_psbt **orig_psbt,
1315 enum tx_role our_role)
1316{
1317 /* Opener always sends the first utxo info */
1318 bool we_complete = false, they_complete = false;
1319 u8 *msg;
1320 struct wally_psbt *psbt = *orig_psbt;
1321
1322 while (!(we_complete && they_complete)) {
1323 struct channel_id cid;
1324 enum peer_wire t;
1325 u64 serial_id;
1326
1327 /* Reset their_complete to false every round,
1328 * they have to re-affirm every time */
1329 they_complete = false;
1330
1331 msg = opening_negotiate_msg(tmpctx, state);
1332 if (!msg)
1333 return false;
1334 t = fromwire_peektype(msg);
1335 switch (t) {
1336 case WIRE_TX_ADD_INPUT: {
1337 const u8 *tx_bytes, *redeemscript;
1338 u32 sequence;
1339 size_t len;
1340 struct bitcoin_tx *tx;
1341 struct bitcoin_outpoint outpoint;
1342 struct amount_sat amt;
1343
1344 if (!fromwire_tx_add_input(tmpctx, msg, &cid,
1345 &serial_id,
1346 cast_const2(u8 **,
1347 &tx_bytes),
1348 &outpoint.n, &sequence,
1349 cast_const2(u8 **,
1350 &redeemscript)))
1351 open_err_fatal(state,
1352 "Parsing tx_add_input %s",
1353 tal_hex(tmpctx, msg));
1354
1355 check_channel_id(state, &cid, &state->channel_id);
1356
1357 /*
1358 * BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
1359 * The receiving node: ...
1360 * - MUST fail the negotiation if: ...
1361 * - if has received 4096 `tx_add_input`
1362 * messages during this negotiation
1363 */
1364 if (++tx_state->tx_msg_count[TX_ADD_INPUT] > MAX_TX_MSG_RCVD)
1365 open_err_warn(state, "Too many `tx_add_input`s"
1366 " received %d", MAX_TX_MSG_RCVD);
1367 /*
1368 * BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
1369 * The receiving node: ...

Callers 3

accepter_startFunction · 0.85
opener_startFunction · 0.85
rbf_wrap_upFunction · 0.85

Calls 15

open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
check_channel_idFunction · 0.85
open_err_warnFunction · 0.85
psbt_find_serial_inputFunction · 0.85
tal_bytelenFunction · 0.85
pull_bitcoin_txFunction · 0.85
is_segwit_outputFunction · 0.85
psbt_has_inputFunction · 0.85
tal_wally_startFunction · 0.85
tal_wally_endFunction · 0.85
is_elementsFunction · 0.85

Tested by

no test coverage detected