| 13 | #include <wire/peer_wire.h> |
| 14 | |
| 15 | void onionmsg_req(struct daemon *daemon, const u8 *msg) |
| 16 | { |
| 17 | struct node_id id; |
| 18 | u8 *onionmsg; |
| 19 | struct pubkey path_key; |
| 20 | struct peer *peer; |
| 21 | |
| 22 | if (!fromwire_connectd_send_onionmsg(msg, msg, &id, &onionmsg, &path_key)) |
| 23 | master_badmsg(WIRE_CONNECTD_SEND_ONIONMSG, msg); |
| 24 | |
| 25 | /* Even though lightningd checks for valid ids, there's a race |
| 26 | * where it might vanish before we read this command. */ |
| 27 | peer = peer_htable_get(daemon->peers, &id); |
| 28 | if (peer) { |
| 29 | u8 *omsg = towire_onion_message(NULL, &path_key, onionmsg); |
| 30 | inject_peer_msg(peer, take(omsg)); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /* Source is NULL if we're injecting, otherwise it's a forward */ |
| 35 | static const char *handle_onion(const tal_t *ctx, |
no test coverage detected