Skip to content

Commit dfa6c0c

Browse files
committed
Makefile: bolt version b38156b9510c0562cf50f8758a64602cc0315c19
"Allow nodes to overshoot final htlc amount and expiry (#1032)" Note that this also renamed `min_final_cltv_expiry` to the more-correct `min_final_cltv_expiry_delta`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent fdf9b13 commit dfa6c0c

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CCANDIR := ccan
2323

2424
# Where we keep the BOLT RFCs
2525
BOLTDIR := ../bolts/
26-
DEFAULT_BOLTVERSION := fc40879995ebc61cc50dfd729512f17afb15b355
26+
DEFAULT_BOLTVERSION := b38156b9510c0562cf50f8758a64602cc0315c19
2727
# Can be overridden on cmdline.
2828
BOLTVERSION := $(DEFAULT_BOLTVERSION)
2929

common/bolt11.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static const char *decode_x(struct bolt11 *b11,
284284

285285
/* BOLT #11:
286286
*
287-
* `c` (24): `data_length` variable. `min_final_cltv_expiry` to use for the
287+
* `c` (24): `data_length` variable. `min_final_cltv_expiry_delta` to use for the
288288
* last HTLC in the route. Default is 18 if not specified.
289289
*/
290290
static const char *decode_c(struct bolt11 *b11,
@@ -594,7 +594,7 @@ struct bolt11 *new_bolt11(const tal_t *ctx,
594594
b11->expiry = DEFAULT_X;
595595
b11->features = tal_arr(b11, u8, 0);
596596
/* BOLT #11:
597-
* - if the `c` field (`min_final_cltv_expiry`) is not provided:
597+
* - if the `c` field (`min_final_cltv_expiry_delta`) is not provided:
598598
* - MUST use an expiry delta of at least 18 when making the payment
599599
*/
600600
b11->min_final_cltv_expiry = 18;
@@ -1009,7 +1009,7 @@ static void push_field(u5 **data, char type, const void *src, size_t nbits)
10091009
*
10101010
* - if `x` is included:
10111011
* - SHOULD use the minimum `data_length` possible.
1012-
* - MUST include one `c` field (`min_final_cltv_expiry`).
1012+
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
10131013
*...
10141014
* - SHOULD use the minimum `data_length` possible.
10151015
*/
@@ -1278,7 +1278,7 @@ char *bolt11_encode_(const tal_t *ctx,
12781278
encode_x(&data, b11->expiry);
12791279

12801280
/* BOLT #11:
1281-
* - MUST include one `c` field (`min_final_cltv_expiry`).
1281+
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
12821282
*/
12831283
encode_c(&data, b11->min_final_cltv_expiry);
12841284

common/bolt11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/* BOLT #11:
1515
* * `c` (24): `data_length` variable.
16-
* `min_final_cltv_expiry` to use for the last HTLC in the route.
16+
* `min_final_cltv_expiry_delta` to use for the last HTLC in the route.
1717
* Default is 18 if not specified.
1818
*/
1919
#define DEFAULT_FINAL_CLTV_DELTA 18

common/test/run-bolt11.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ int main(int argc, char *argv[])
527527
* * `x`: expiry time
528528
* * `qy`: `data_length` (`q` = 0, `y` = 2; 0 * 32 + 4 == 4)
529529
* * `jw5q`: 604800 seconds (`j` = 18, `w` = 14, `5` = 20, `q` = 0; 18 * 32^3 + 14 * 32^2 + 20 * 32 + 0 == 604800)
530-
* * `c`: `min_final_cltv_expiry`
530+
* * `c`: `min_final_cltv_expiry_delta`
531531
* * `qp`: `data_length` (`q` = 0, `p` = 1; 0 * 32 + 1 == 1)
532-
* * `2`: min_final_cltv_expiry = 10
532+
* * `2`: min_final_cltv_expiry_delta = 10
533533
* * `r`: tagged field: route information
534534
* * `zj`: `data_length` (`z` = 2, `j` = 18; 2 * 32 + 18 == 82)
535535
* * `q0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q`:

lightningd/peer_htlcs.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ static bool check_fwd_amount(struct htlc_in *hin,
311311
* - MUST return an error if:
312312
* ...
313313
* - `cltv_expiry` - `cltv_expiry_delta` < `outgoing_cltv_value`
314+
* - if it is the final node:
315+
*...
316+
* - MUST return an error if:
317+
*...
318+
* - incoming `cltv_expiry` < `outgoing_cltv_value`.
314319
*/
315320
static bool check_cltv(struct htlc_in *hin,
316321
u32 cltv_expiry, u32 outgoing_cltv_value, u32 delta)
@@ -381,9 +386,9 @@ static void handle_localpay(struct htlc_in *hin,
381386
* - MUST treat `total_msat` as if it were equal to `amt_to_forward` if it
382387
* is not present.
383388
* - MUST return an error if:
384-
* - incoming `amount_msat` != `amt_to_forward`.
389+
* - incoming `amount_msat` < `amt_to_forward`.
385390
*/
386-
if (!amount_msat_eq(amt_to_forward, hin->msat)) {
391+
if (amount_msat_less(hin->msat, amt_to_forward)) {
387392
log_debug(hin->key.channel->log,
388393
"HTLC %"PRIu64" final incorrect amount:"
389394
" %s in, %s expected",
@@ -408,7 +413,7 @@ static void handle_localpay(struct htlc_in *hin,
408413
* is not present.
409414
* - MUST return an error if:
410415
*...
411-
* - incoming `cltv_expiry` != `cltv_expiry_delta`.
416+
* - incoming `cltv_expiry` < `outgoing_cltv_value`.
412417
*/
413418
if (!check_cltv(hin, hin->cltv_expiry, outgoing_cltv_value, 0)) {
414419
/* BOLT #4:
@@ -426,10 +431,7 @@ static void handle_localpay(struct htlc_in *hin,
426431

427432
/* BOLT #4:
428433
*
429-
* - if the `cltv_expiry` value is unreasonably near the present:
430-
* - MUST fail the HTLC.
431-
* - MUST return an `incorrect_or_unknown_payment_details` error.
432-
*/
434+
* incoming `cltv_expiry` < `current_block_height` + `min_final_cltv_expiry_delta`. */
433435
if (get_block_height(ld->topology) + ld->config.cltv_final
434436
> hin->cltv_expiry) {
435437
log_debug(hin->key.channel->log,

0 commit comments

Comments
 (0)