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

Function sphinx_add_hop_has_length

common/sphinx.c:107–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool sphinx_add_hop_has_length(struct sphinx_path *path, const struct pubkey *pubkey,
108 const u8 *payload TAKES)
109{
110 struct sphinx_hop sp;
111 bigsize_t lenlen, prepended_len;
112
113 /* You promised size was prepended! */
114 if (tal_bytelen(payload) == 0)
115 return false;
116 lenlen = bigsize_get(payload, tal_bytelen(payload), &prepended_len);
117 if (add_overflows_u64(lenlen, prepended_len))
118 return false;
119 if (lenlen + prepended_len != tal_bytelen(payload))
120 return false;
121
122 sp.raw_payload = tal_dup_talarr(path, u8, payload);
123 sp.pubkey = *pubkey;
124 tal_arr_expand(&path->hops, sp);
125 return true;
126}
127
128void sphinx_add_hop(struct sphinx_path *path, const struct pubkey *pubkey,
129 const u8 *payload TAKES)

Callers 4

send_paymentFunction · 0.85
json_createonionFunction · 0.85
sphinx_add_hopFunction · 0.85
do_generateFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
add_overflows_u64Function · 0.85
bigsize_getFunction · 0.70

Tested by

no test coverage detected