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

Function hop_append

plugins/xpay/xpay.c:1371–1391  ·  view source on GitHub ↗

hop has size prepended, so this isn't a simple "append" */

Source from the content-addressed store, hash-verified

1369
1370/* hop has size prepended, so this isn't a simple "append" */
1371static void hop_append(u8 **hop, const u8 *appendme)
1372{
1373 bigsize_t prepended_len;
1374 const u8 *cursor = *hop;
1375 size_t tlvs_len = tal_bytelen(*hop);
1376 u8 *result;
1377
1378 /* Pull off length */
1379 prepended_len = fromwire_bigsize(&cursor, &tlvs_len);
1380 assert(cursor);
1381 assert(prepended_len == tlvs_len);
1382
1383 /* Rewrite: length + contents */
1384 result = tal_arr(tal_parent(*hop), u8, 0);
1385 towire_bigsize(&result, tlvs_len + tal_bytelen(appendme));
1386 towire(&result, cursor, tlvs_len);
1387 towire(&result, appendme, tal_bytelen(appendme));
1388
1389 tal_free(*hop);
1390 *hop = result;
1391}
1392
1393static const u8 *create_onion(const tal_t *ctx,
1394 struct attempt *attempt,

Callers 1

create_onionFunction · 0.85

Calls 6

tal_bytelenFunction · 0.85
tal_parentFunction · 0.85
tal_freeFunction · 0.85
fromwire_bigsizeFunction · 0.50
towire_bigsizeFunction · 0.50
towireFunction · 0.50

Tested by

no test coverage detected