| 126 | } |
| 127 | |
| 128 | void sphinx_add_hop(struct sphinx_path *path, const struct pubkey *pubkey, |
| 129 | const u8 *payload TAKES) |
| 130 | { |
| 131 | u8 *with_len = tal_arr(NULL, u8, 0); |
| 132 | size_t len = tal_bytelen(payload); |
| 133 | towire_bigsize(&with_len, len); |
| 134 | towire_u8_array(&with_len, payload, len); |
| 135 | if (taken(payload)) |
| 136 | tal_free(payload); |
| 137 | |
| 138 | if (!sphinx_add_hop_has_length(path, pubkey, take(with_len))) |
| 139 | abort(); |
| 140 | } |
| 141 | |
| 142 | /* Small helper to append data to a buffer and update the position |
| 143 | * into the buffer |