MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sphinx_compressed_onion_deserialize

Function sphinx_compressed_onion_deserialize

common/sphinx.c:964–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

962}
963
964struct sphinx_compressed_onion *
965sphinx_compressed_onion_deserialize(const tal_t *ctx, const u8 *src)
966{
967 const u8 *cursor = src;
968 size_t max = tal_bytelen(src);
969 struct sphinx_compressed_onion *dst =
970 tal(ctx, struct sphinx_compressed_onion);
971
972 /* This is not a compressed onion, so let's not parse it. */
973 if (max > TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE))
974 return tal_free(dst);
975
976 dst->version = fromwire_u8(&cursor, &max);
977 if (dst->version != 0x00)
978 return tal_free(dst);
979
980 fromwire_pubkey(&cursor, &max, &dst->ephemeralkey);
981 dst->routinginfo = fromwire_tal_arrn(dst, &cursor, &max, max - HMAC_SIZE);
982 fromwire_hmac(&cursor, &max, &dst->hmac);
983
984 /* If at any point we failed to pull from the serialized compressed
985 * onion the entire deserialization is considered to have failed. */
986 if (cursor == NULL)
987 return tal_free(dst);
988 return dst;
989}

Callers 1

decompressFunction · 0.85

Calls 6

tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
fromwire_pubkeyFunction · 0.85
fromwire_hmacFunction · 0.70
fromwire_u8Function · 0.50
fromwire_tal_arrnFunction · 0.50

Tested by

no test coverage detected