Browse Source

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.
travis-debug
Christian Decker 5 years ago
parent
commit
62e9ad1139
  1. 9
      devtools/onion.c

9
devtools/onion.c

@ -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…
Cancel
Save