| 155 | } |
| 156 | |
| 157 | void sphinx_add_hop(struct sphinx_path *path, const struct pubkey *pubkey, |
| 158 | const u8 *payload TAKES) |
| 159 | { |
| 160 | u8 *with_len = tal_arr(NULL, u8, 0); |
| 161 | size_t len = tal_bytelen(payload); |
| 162 | towire_bigsize(&with_len, len); |
| 163 | towire_u8_array(&with_len, payload, len); |
| 164 | tal_free_if_taken(payload); |
| 165 | |
| 166 | if (!sphinx_add_hop_has_length(path, pubkey, take(with_len))) |
| 167 | abort(); |
| 168 | } |
| 169 | |
| 170 | /* Small helper to append data to a buffer and update the position |
| 171 | * into the buffer |