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

Function send_next

openingd/dualopend.c:1083–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081}
1082
1083static bool send_next(struct state *state,
1084 struct tx_state *tx_state,
1085 struct wally_psbt **psbt)
1086{
1087 u8 *msg;
1088 bool finished = false;
1089 struct wally_psbt *updated_psbt;
1090 struct psbt_changeset *cs = tx_state->changeset;
1091
1092 /* First we check our cached changes */
1093 msg = psbt_changeset_get_next(tmpctx, &state->channel_id, cs);
1094 if (msg)
1095 goto sendmsg;
1096
1097 /* If we don't have any changes cached, go ask Alice for
1098 * what changes they've got for us */
1099 updated_psbt = fetch_psbt_changes(state, tx_state, *psbt);
1100
1101 /* We should always get a updated psbt back */
1102 if (!updated_psbt)
1103 open_err_fatal(state, "%s", "Uncaught error");
1104
1105 tx_state->changeset = tal_free(tx_state->changeset);
1106 tx_state->changeset = psbt_get_changeset(tx_state, *psbt, updated_psbt);
1107
1108 /* We want this old psbt to be cleaned up when the changeset is freed */
1109 tal_steal(tx_state->changeset, notleak(*psbt));
1110 *psbt = tal_steal(tx_state, updated_psbt);
1111 msg = psbt_changeset_get_next(tmpctx, &state->channel_id,
1112 tx_state->changeset);
1113 /*
1114 * If there's no more moves, we send tx_complete
1115 * and reply that we're finished */
1116 if (!msg) {
1117 msg = towire_tx_complete(tmpctx, &state->channel_id);
1118 finished = true;
1119 }
1120
1121sendmsg:
1122 peer_write(state->pps, msg);
1123
1124 return !finished;
1125}
1126
1127static void init_changeset(struct tx_state *tx_state, struct wally_psbt *psbt)
1128{

Callers 3

run_tx_interactiveFunction · 0.85
opener_startFunction · 0.85
rbf_wrap_upFunction · 0.85

Calls 6

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

Tested by

no test coverage detected