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

Function onion_message_modern_call

plugins/offers.c:86–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86static struct command_result *onion_message_modern_call(struct command *cmd,
87 const char *buf,
88 const jsmntok_t *params)
89{
90 const jsmntok_t *om, *replytok, *invreqtok, *invtok;
91 struct tlv_onionmsg_payload_reply_path *reply_path = NULL;
92
93 if (!offers_enabled)
94 return command_hook_success(cmd);
95
96 om = json_get_member(buf, params, "onion_message");
97 replytok = json_get_member(buf, om, "reply_blindedpath");
98 if (replytok) {
99 reply_path = json_to_reply_path(cmd, buf, replytok);
100 if (!reply_path)
101 plugin_err(cmd->plugin, "Invalid reply path %.*s?",
102 json_tok_full_len(replytok),
103 json_tok_full(buf, replytok));
104 }
105
106 invreqtok = json_get_member(buf, om, "invoice_request");
107 if (invreqtok) {
108 const u8 *invreqbin = json_tok_bin_from_hex(tmpctx, buf, invreqtok);
109 if (reply_path)
110 return handle_invoice_request(cmd,
111 invreqbin,
112 reply_path);
113 else
114 plugin_log(cmd->plugin, LOG_DBG,
115 "invoice_request without reply_path");
116 }
117
118 invtok = json_get_member(buf, om, "invoice");
119 if (invtok) {
120 const u8 *invbin = json_tok_bin_from_hex(tmpctx, buf, invtok);
121 if (invbin)
122 return handle_invoice(cmd, invbin, reply_path);
123 }
124
125 return command_hook_success(cmd);
126}
127
128static const struct plugin_hook hooks[] = {
129 {

Callers

nothing calls this directly

Calls 10

command_hook_successFunction · 0.85
json_to_reply_pathFunction · 0.85
handle_invoice_requestFunction · 0.85
handle_invoiceFunction · 0.85
plugin_errFunction · 0.70
plugin_logFunction · 0.70
json_get_memberFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected