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

Function send_next

openingd/dualopend.c:1467–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1465}
1466
1467static bool send_next(struct state *state,
1468 struct tx_state *tx_state,
1469 struct wally_psbt **psbt,
1470 bool *aborted)
1471{
1472 u8 *msg;
1473 bool finished = false;
1474 struct wally_psbt *updated_psbt;
1475 struct psbt_changeset *cs = tx_state->changeset;
1476 *aborted = false;
1477
1478 /* First we check our cached changes */
1479 msg = psbt_changeset_get_next(tmpctx, &state->channel_id, cs);
1480 if (msg)
1481 goto sendmsg;
1482
1483 /* If we don't have any changes cached, go ask Alice for
1484 * what changes they've got for us */
1485 if (!fetch_psbt_changes(state, tx_state, *psbt,
1486 &updated_psbt)) {
1487 *aborted = true;
1488 return !finished;
1489 }
1490
1491 tx_state->changeset = tal_free(tx_state->changeset);
1492 tx_state->changeset = psbt_get_changeset(tx_state, *psbt, updated_psbt);
1493
1494 /* We want this old psbt to be cleaned up when the changeset is freed */
1495 tal_steal(tx_state->changeset, notleak(*psbt));
1496 *psbt = tal_steal(tx_state, updated_psbt);
1497 msg = psbt_changeset_get_next(tmpctx, &state->channel_id,
1498 tx_state->changeset);
1499 /*
1500 * If there's no more moves, we send tx_complete
1501 * and reply that we're finished */
1502 if (!msg) {
1503 msg = towire_tx_complete(tmpctx, &state->channel_id);
1504 finished = true;
1505 }
1506
1507sendmsg:
1508 peer_write(state->pps, msg);
1509
1510 return !finished;
1511}
1512
1513static void init_changeset(struct tx_state *tx_state, struct wally_psbt *psbt)
1514{

Callers 3

run_tx_interactiveFunction · 0.70
opener_startFunction · 0.70
rbf_wrap_upFunction · 0.70

Calls 5

psbt_changeset_get_nextFunction · 0.85
fetch_psbt_changesFunction · 0.85
tal_freeFunction · 0.85
psbt_get_changesetFunction · 0.85
peer_writeFunction · 0.85

Tested by

no test coverage detected