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

Function mfc_cleanup_

plugins/spender/multifundchannel.c:233–323  ·  view source on GitHub ↗

Core cleanup function. */

Source from the content-addressed store, hash-verified

231
232/* Core cleanup function. */
233static struct command_result *
234mfc_cleanup_(struct multifundchannel_command *mfc,
235 struct command_result *(*cb)(void *arg),
236 void *arg)
237{
238 struct multifundchannel_cleanup *cleanup;
239 unsigned int i;
240
241 plugin_log(mfc->cmd->plugin, LOG_DBG,
242 "mfc %"PRIu64": cleanup!", mfc->id);
243
244 cleanup = tal(mfc, struct multifundchannel_cleanup);
245 cleanup->pending = 0;
246 cleanup->cb = cb;
247 cleanup->arg = arg;
248
249 /* If there's commitments, anywhere, we have to fail/restart.
250 * We also cleanup the PSBT if there's no v2's around */
251 if (mfc->psbt) {
252 plugin_log(mfc->cmd->plugin, LOG_DBG,
253 "mfc %"PRIu64": unreserveinputs task.", mfc->id);
254
255 ++cleanup->pending;
256 mfc_cleanup_psbt(mfc->cmd, cleanup, mfc->psbt);
257 }
258 for (i = 0; i < tal_count(mfc->destinations); ++i) {
259 struct multifundchannel_destination *dest;
260 dest = &mfc->destinations[i];
261
262 switch (dest->state) {
263 case MULTIFUNDCHANNEL_STARTED:
264 /* v1 handling */
265 if (!is_v2(dest)) {
266 plugin_log(mfc->cmd->plugin, LOG_DBG,
267 "mfc %"PRIu64", dest %u: "
268 "fundchannel_cancel task.",
269 mfc->id, dest->index);
270 ++cleanup->pending;
271 mfc_cleanup_fc(mfc->cmd, cleanup, dest);
272 } else { /* v2 handling */
273 plugin_log(mfc->cmd->plugin, LOG_DBG,
274 "mfc %"PRIu64", dest %u:"
275 " openchannel_abort task.",
276 mfc->id, dest->index);
277 ++cleanup->pending;
278 mfc_cleanup_oc(mfc->cmd, cleanup, dest);
279 }
280 continue;
281 case MULTIFUNDCHANNEL_COMPLETED:
282 /* Definitely a v1 */
283 plugin_log(mfc->cmd->plugin, LOG_DBG,
284 "mfc %"PRIu64", dest %u: "
285 "fundchannel_cancel task.",
286 mfc->id, dest->index);
287 ++cleanup->pending;
288 mfc_cleanup_fc(mfc->cmd, cleanup, dest);
289 continue;
290 case MULTIFUNDCHANNEL_UPDATED:

Callers

nothing calls this directly

Calls 8

mfc_cleanup_psbtFunction · 0.85
is_v2Function · 0.85
mfc_cleanup_fcFunction · 0.85
mfc_cleanup_ocFunction · 0.85
abortFunction · 0.85
mfc_cleanup_completeFunction · 0.85
plugin_logFunction · 0.50
command_still_pendingFunction · 0.50

Tested by

no test coverage detected