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

Function mfc_cleanup_

plugins/spender/multifundchannel.c:239–329  ·  view source on GitHub ↗

Core cleanup function. */

Source from the content-addressed store, hash-verified

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