mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
sphinx: Use the new fromwire_tlv_payload function
We wire in the code-generated function, which removes the upfront validation and add the validation back after the `htlc_accepted` hook returns. If a plugin wanted to handle the onion in a special way it'll not have told us to just continue.
This commit is contained in:
committed by
Rusty Russell
parent
2519f934aa
commit
d69a43780c
@@ -591,9 +591,13 @@ static void sphinx_parse_payload(struct route_step *step, const u8 *src)
|
||||
const u8 *tlv = step->raw_payload;
|
||||
size_t max = tal_bytelen(tlv);
|
||||
step->payload.tlv = tlv_tlv_payload_new(step);
|
||||
if (!fromwire_tlvs(&tlv, &max, tlvs_tlv_payload,
|
||||
TLVS_TLV_PAYLOAD_ARRAY_SIZE,
|
||||
step->payload.tlv)) {
|
||||
|
||||
/* The raw payload includes the length / realm prefix, Consume
|
||||
* the length off of the payload, so the decoding can strat
|
||||
* correctly. */
|
||||
fromwire_varint(&tlv, &max);
|
||||
|
||||
if (!fromwire_tlv_payload(&tlv, &max, step->payload.tlv)) {
|
||||
/* FIXME: record offset of violation for error! */
|
||||
step->type = SPHINX_INVALID_PAYLOAD;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user