| 104 | |
| 105 | |
| 106 | void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg) |
| 107 | { |
| 108 | struct onion_message_hook_payload *payload; |
| 109 | u8 *submsg; |
| 110 | size_t submsglen; |
| 111 | const u8 *subptr; |
| 112 | |
| 113 | payload = tal(tmpctx, struct onion_message_hook_payload); |
| 114 | if (!fromwire_connectd_got_onionmsg_to_us(payload, msg, |
| 115 | &payload->pathsecret, |
| 116 | &payload->reply_path, |
| 117 | &submsg)) { |
| 118 | log_broken(ld->log, "bad got_onionmsg_tous: %s", |
| 119 | tal_hex(tmpctx, msg)); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | if (ld->dev_ignore_modern_onion) |
| 124 | return; |
| 125 | |
| 126 | submsglen = tal_bytelen(submsg); |
| 127 | subptr = submsg; |
| 128 | payload->om = fromwire_tlv_onionmsg_tlv(payload, &subptr, &submsglen); |
| 129 | if (!payload->om) { |
| 130 | log_broken(ld->log, "bad got_onionmsg_tous om: %s", |
| 131 | tal_hex(tmpctx, msg)); |
| 132 | return; |
| 133 | } |
| 134 | tal_free(submsg); |
| 135 | |
| 136 | /* Make sure connectd gets this right. */ |
| 137 | log_debug(ld->log, "Got onionmsg%s%s", |
| 138 | payload->pathsecret ? " with pathsecret": "", |
| 139 | payload->reply_path ? " reply_path": ""); |
| 140 | |
| 141 | /* We'll free this on return */ |
| 142 | tal_steal(ld, payload); |
| 143 | if (payload->pathsecret) |
| 144 | plugin_hook_call_onion_message_recv_secret(ld, NULL, payload); |
| 145 | else |
| 146 | plugin_hook_call_onion_message_recv(ld, NULL, payload); |
| 147 | } |
| 148 | |
| 149 | static void inject_onionmsg_reply(struct subd *connectd, |
| 150 | const u8 *reply, |
no test coverage detected