| 947 | } |
| 948 | |
| 949 | struct sphinx_compressed_onion * |
| 950 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
| 951 | const struct sphinx_path *path) |
| 952 | { |
| 953 | struct sphinx_compressed_onion *res; |
| 954 | size_t payloads_size = sphinx_path_payloads_size(path); |
| 955 | |
| 956 | /* We can't compress an onion that doesn't have a rendez-vous node. */ |
| 957 | if (path->rendezvous_id == NULL) |
| 958 | return NULL; |
| 959 | |
| 960 | res = tal(ctx, struct sphinx_compressed_onion); |
| 961 | res->version = packet->version; |
| 962 | res->ephemeralkey = packet->ephemeralkey; |
| 963 | res->hmac = packet->hmac; |
| 964 | |
| 965 | res->routinginfo = tal_arr(res, u8, payloads_size); |
| 966 | memcpy(res->routinginfo, packet->routinginfo, payloads_size); |
| 967 | |
| 968 | return res; |
| 969 | } |
| 970 | |
| 971 | u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion) |
| 972 | { |
no test coverage detected