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

Function handle_custommsg

plugins/commando.c:577–611  ·  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 handle_incmd(&peer, idnum, msg, len,
600 mtype == COMMANDO_MSG_CMD_TERM);
601 break;
602 case COMMANDO_MSG_REPLY_CONTINUES:
603 case COMMANDO_MSG_REPLY_TERM:
604 handle_reply(&peer, idnum, msg, len,
605 mtype == COMMANDO_MSG_REPLY_TERM);
606 break;
607 }
608 }
609
610 return command_hook_success(cmd);
611}
612
613static const struct plugin_hook hooks[] = {
614 {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected