| 1310 | } |
| 1311 | |
| 1312 | static 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: ... |
no test coverage detected