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

Function json_openchannel_abort

lightningd/dual_open_control.c:2591–2654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2589}
2590
2591static struct command_result *
2592json_openchannel_abort(struct command *cmd,
2593 const char *buffer,
2594 const jsmntok_t *obj UNNEEDED,
2595 const jsmntok_t *params)
2596{
2597 struct channel_id *cid;
2598 struct channel *channel;
2599 u8 *msg;
2600
2601 if (!param_check(cmd, buffer, params,
2602 p_req("channel_id", param_channel_id, &cid),
2603 NULL))
2604 return command_param_failed();
2605
2606 channel = channel_by_cid(cmd->ld, cid);
2607 if (!channel)
2608 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
2609 "Unknown channel %s",
2610 fmt_channel_id(tmpctx, cid));
2611
2612 if (!channel->owner)
2613 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
2614 "Peer not connected");
2615
2616 if (!channel->open_attempt) {
2617 if (list_empty(&channel->inflights))
2618 return command_fail(cmd, FUNDING_STATE_INVALID,
2619 "Channel open not in progress");
2620 /* Commitments may already be stored; we can still abort
2621 * until we have sent tx_signatures. */
2622 if (channel_funding_sigs_sent(channel))
2623 return command_fail(cmd, FUNDING_STATE_INVALID,
2624 "Already sent sigs, can't cancel");
2625 } else if (channel->open_attempt->cmd) {
2626 return command_fail(cmd, FUNDING_STATE_INVALID,
2627 "Another openchannel command"
2628 " is in progress");
2629 }
2630
2631 if (channel->openchannel_signed_cmd)
2632 return command_fail(cmd, FUNDING_STATE_INVALID,
2633 "Already sent sigs, waiting for peer's");
2634
2635 if (command_check_only(cmd))
2636 return command_check_done(cmd);
2637
2638 /* If commitments were already exchanged there's no open_attempt;
2639 * make one to park the command on, so we respond with the actual
2640 * outcome once the abort completes. */
2641 if (!channel->open_attempt)
2642 channel->open_attempt = new_channel_open_attempt(channel);
2643
2644 /* Mark it as aborted so when we clean-up, we send the
2645 * correct response */
2646 channel->open_attempt->aborted = true;
2647 channel->open_attempt->cmd = cmd;
2648

Callers

nothing calls this directly

Calls 11

param_checkFunction · 0.85
new_channel_open_attemptFunction · 0.85
command_param_failedFunction · 0.70
channel_by_cidFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
subd_send_msgFunction · 0.70
command_still_pendingFunction · 0.70
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected