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

Function handle_custommsg

plugins/commando.c:577–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577static struct command_result *handle_custommsg(struct command *cmd,
578 const char *buf,
579 const jsmntok_t *params)
580{
581 struct node_id peer;
582 const u8 *msg;
583 size_t len;
584 enum commando_msgtype mtype;
585 u64 idnum;
586
587 json_to_node_id(buf, json_get_member(buf, params, "peer_id"), &peer);
588 msg = json_tok_bin_from_hex(cmd, buf,
589 json_get_member(buf, params, "payload"));
590
591 len = tal_bytelen(msg);
592 mtype = fromwire_u16(&msg, &len);
593 idnum = fromwire_u64(&msg, &len);
594
595 if (msg) {
596 switch (mtype) {
597 case COMMANDO_MSG_CMD_CONTINUES:
598 case COMMANDO_MSG_CMD_TERM:
599 return handle_incmd(cmd, &peer, idnum, msg, len,
600 mtype == COMMANDO_MSG_CMD_TERM);
601 case COMMANDO_MSG_REPLY_CONTINUES:
602 case COMMANDO_MSG_REPLY_TERM:
603 handle_reply(&peer, idnum, msg, len,
604 mtype == COMMANDO_MSG_REPLY_TERM);
605 break;
606 }
607 }
608
609 return command_hook_success(cmd);
610}
611
612static u64 custommsg_types[] = {
613 COMMANDO_MSG_CMD_CONTINUES,

Callers

nothing calls this directly

Calls 9

json_get_memberFunction · 0.85
tal_bytelenFunction · 0.85
handle_incmdFunction · 0.85
handle_replyFunction · 0.85
command_hook_successFunction · 0.70
json_to_node_idFunction · 0.50
json_tok_bin_from_hexFunction · 0.50
fromwire_u16Function · 0.50
fromwire_u64Function · 0.50

Tested by

no test coverage detected