| 835 | } |
| 836 | |
| 837 | struct sphinx_compressed_onion * |
| 838 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
| 839 | const struct sphinx_path *path) |
| 840 | { |
| 841 | struct sphinx_compressed_onion *res; |
| 842 | size_t payloads_size = sphinx_path_payloads_size(path); |
| 843 | |
| 844 | /* We can't compress an onion that doesn't have a rendez-vous node. */ |
| 845 | if (path->rendezvous_id == NULL) |
| 846 | return NULL; |
| 847 | |
| 848 | res = tal(ctx, struct sphinx_compressed_onion); |
| 849 | res->version = packet->version; |
| 850 | res->ephemeralkey = packet->ephemeralkey; |
| 851 | res->hmac = packet->hmac; |
| 852 | |
| 853 | res->routinginfo = tal_arr(res, u8, payloads_size); |
| 854 | memcpy(res->routinginfo, packet->routinginfo, payloads_size); |
| 855 | |
| 856 | return res; |
| 857 | } |
| 858 | |
| 859 | u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion) |
| 860 | { |
no test coverage detected