mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
sphinx: Fix the broken legacy payload loading from test-vectors
We were for some reason encoding all payloads as raw payloads instead of loading legacy payloads into a padded array.
This commit is contained in:
parent
9038364c63
commit
62e9ad1139
1 changed files with 5 additions and 4 deletions
|
@ -220,15 +220,16 @@ static void runtest(const char *filename)
|
|||
json_to_pubkey(buffer, pubkeytok, &pubkey);
|
||||
if (!typetok || json_tok_streq(buffer, typetok, "legacy")) {
|
||||
/* Legacy has a single 0 prepended as "realm" byte */
|
||||
full = tal_arrz(ctx, u8, 1);
|
||||
full = tal_arrz(ctx, u8, 33);
|
||||
memcpy(full + 1, payload, tal_bytelen(payload));
|
||||
} else {
|
||||
/* TLV has length prepended */
|
||||
full = tal_arr(ctx, u8, 0);
|
||||
towire_bigsize(&full, tal_bytelen(payload));
|
||||
prepended = tal_bytelen(full);
|
||||
tal_resize(&full, prepended + tal_bytelen(payload));
|
||||
memcpy(full + prepended, payload, tal_bytelen(payload));
|
||||
}
|
||||
prepended = tal_bytelen(full);
|
||||
tal_resize(&full, prepended + tal_bytelen(payload));
|
||||
memcpy(full + prepended, payload, tal_bytelen(payload));
|
||||
sphinx_add_hop(path, &pubkey, full);
|
||||
}
|
||||
res = create_onionpacket(ctx, path, &shared_secrets);
|
||||
|
|
Loading…
Add table
Reference in a new issue