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

Function param_channel_or_peer

lightningd/closing_control.c:562–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560};
561
562static struct command_result *param_channel_or_peer(struct command *cmd,
563 const char *name,
564 const char *buffer,
565 const jsmntok_t *tok,
566 struct some_channel **sc)
567{
568 struct peer *peer = peer_from_json(cmd->ld, buffer, tok);
569 bool more_than_one;
570
571 (*sc)->unsaved_channel = NULL;
572 (*sc)->uc = NULL;
573
574 if (peer) {
575 (*sc)->channel = peer_any_active_channel(peer, &more_than_one);
576 if ((*sc)->channel) {
577 if (more_than_one)
578 goto more_than_one;
579 return NULL;
580 }
581 } else {
582 struct command_result *res;
583 res = command_find_channel(cmd, buffer, tok, &(*sc)->channel);
584 if (res)
585 return res;
586 assert((*sc)->channel);
587 return NULL;
588 }
589
590 /* OK, we have a peer, but no active channels. */
591 (*sc)->uc = peer->uncommitted_channel;
592 if ((*sc)->uc)
593 return NULL;
594
595 (*sc)->unsaved_channel = peer_any_unsaved_channel(peer, &more_than_one);
596 if ((*sc)->unsaved_channel) {
597 if (more_than_one)
598 goto more_than_one;
599 return NULL;
600 }
601
602 return command_fail(cmd, LIGHTNINGD, "Peer has no active channel");
603
604more_than_one:
605 return command_fail(cmd, LIGHTNINGD,
606 "Peer has multiple channels: use channel_id or short_channel_id");
607}
608
609static struct command_result *json_close(struct command *cmd,
610 const char *buffer,

Callers

nothing calls this directly

Calls 5

peer_from_jsonFunction · 0.85
command_find_channelFunction · 0.85
peer_any_unsaved_channelFunction · 0.85
peer_any_active_channelFunction · 0.70
command_failFunction · 0.70

Tested by

no test coverage detected