| 84 | } |
| 85 | |
| 86 | static 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 | |
| 128 | static const struct plugin_hook hooks[] = { |
| 129 | { |
nothing calls this directly
no test coverage detected