| 913 | } |
| 914 | |
| 915 | struct sphinx_compressed_onion * |
| 916 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
| 917 | const struct sphinx_path *path) |
| 918 | { |
| 919 | struct sphinx_compressed_onion *res; |
| 920 | size_t payloads_size = sphinx_path_payloads_size(path); |
| 921 | |
| 922 | /* We can't compress an onion that doesn't have a rendez-vous node. */ |
| 923 | if (path->rendezvous_id == NULL) |
| 924 | return NULL; |
| 925 | |
| 926 | res = tal(ctx, struct sphinx_compressed_onion); |
| 927 | res->version = packet->version; |
| 928 | res->ephemeralkey = packet->ephemeralkey; |
| 929 | res->hmac = packet->hmac; |
| 930 | |
| 931 | res->routinginfo = tal_arr(res, u8, payloads_size); |
| 932 | memcpy(res->routinginfo, packet->routinginfo, payloads_size); |
| 933 | |
| 934 | return res; |
| 935 | } |
| 936 | |
| 937 | u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion) |
| 938 | { |
no test coverage detected