| 107 | struct onion_message_hook_payload *); |
| 108 | |
| 109 | void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg) |
| 110 | { |
| 111 | struct onion_message_hook_payload *payload; |
| 112 | u8 *submsg; |
| 113 | struct secret *self_id; |
| 114 | size_t submsglen; |
| 115 | const u8 *subptr; |
| 116 | |
| 117 | payload = tal(tmpctx, struct onion_message_hook_payload); |
| 118 | payload->our_alias = tal(payload, struct pubkey); |
| 119 | |
| 120 | if (!fromwire_connectd_got_onionmsg_to_us(payload, msg, |
| 121 | payload->our_alias, |
| 122 | &self_id, |
| 123 | &payload->reply_blinding, |
| 124 | &payload->reply_first_node, |
| 125 | &payload->reply_path, |
| 126 | &submsg)) { |
| 127 | log_broken(ld->log, "bad got_onionmsg_tous: %s", |
| 128 | tal_hex(tmpctx, msg)); |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | #if DEVELOPER |
| 133 | if (ld->dev_ignore_modern_onion) |
| 134 | return; |
| 135 | #endif |
| 136 | |
| 137 | /* If there's no self_id, or it's not correct, ignore alias: alias |
| 138 | * means we created the path it's using. */ |
| 139 | if (!self_id || !secret_eq_consttime(self_id, &ld->onion_reply_secret)) |
| 140 | payload->our_alias = tal_free(payload->our_alias); |
| 141 | tal_free(self_id); |
| 142 | |
| 143 | submsglen = tal_bytelen(submsg); |
| 144 | subptr = submsg; |
| 145 | payload->om = fromwire_tlv_onionmsg_payload(payload, &subptr, &submsglen); |
| 146 | if (!payload->om) { |
| 147 | log_broken(ld->log, "bad got_onionmsg_tous om: %s", |
| 148 | tal_hex(tmpctx, msg)); |
| 149 | return; |
| 150 | } |
| 151 | tal_free(submsg); |
| 152 | |
| 153 | /* Make sure connectd gets this right. */ |
| 154 | if (payload->reply_path |
| 155 | && (!payload->reply_blinding || !payload->reply_first_node)) { |
| 156 | log_broken(ld->log, |
| 157 | "No reply blinding/first_node, ignoring reply path"); |
| 158 | payload->reply_path = tal_free(payload->reply_path); |
| 159 | } |
| 160 | |
| 161 | log_debug(ld->log, "Got onionmsg%s%s", |
| 162 | payload->our_alias ? " via-ourpath": "", |
| 163 | payload->reply_path ? " reply_path": ""); |
| 164 | |
| 165 | /* We'll free this on return */ |
| 166 | tal_steal(ld, payload); |
no test coverage detected