mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
BOLT12: reject zero-length blinded paths.
This is a good idea, but also specifically called out in the latest BOLT spec. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
18fc1b82b0
commit
2ecf5e6bd5
1 changed files with 22 additions and 0 deletions
|
@ -228,6 +228,17 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
|
|||
return tal_free(offer);
|
||||
}
|
||||
|
||||
/* BOLT-offers #12:
|
||||
* - if `num_hops` is 0 in any `blinded_path` in `offer_paths`:
|
||||
* - MUST NOT respond to the offer.
|
||||
*/
|
||||
for (size_t i = 0; i < tal_count(offer->offer_paths); i++) {
|
||||
if (tal_count(offer->offer_paths[i]->path) == 0) {
|
||||
*fail = tal_strdup(ctx, "Offer contains an empty offer_path");
|
||||
return tal_free(offer);
|
||||
}
|
||||
}
|
||||
|
||||
return offer;
|
||||
}
|
||||
|
||||
|
@ -285,6 +296,17 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
|
|||
return tal_free(invrequest);
|
||||
}
|
||||
|
||||
/* BOLT-offers #12:
|
||||
* - if `num_hops` is 0 in any `blinded_path` in `invreq_paths`:
|
||||
* - MUST fail the request.
|
||||
*/
|
||||
for (size_t i = 0; i < tal_count(invrequest->invreq_paths); i++) {
|
||||
if (tal_count(invrequest->invreq_paths[i]->path) == 0) {
|
||||
*fail = tal_strdup(ctx, "Invoice request contains an empty invreq_path");
|
||||
return tal_free(invrequest);
|
||||
}
|
||||
}
|
||||
|
||||
return invrequest;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue