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>
This commit is contained in:
Rusty Russell
2023-04-07 16:24:26 +09:30
parent fdf9b13bdb
commit dfa6c0ca52
5 changed files with 17 additions and 15 deletions

View File

@@ -23,7 +23,7 @@ CCANDIR := ccan
# Where we keep the BOLT RFCs
BOLTDIR := ../bolts/
DEFAULT_BOLTVERSION := fc40879995ebc61cc50dfd729512f17afb15b355
DEFAULT_BOLTVERSION := b38156b9510c0562cf50f8758a64602cc0315c19
# Can be overridden on cmdline.
BOLTVERSION := $(DEFAULT_BOLTVERSION)

View File

@@ -284,7 +284,7 @@ static const char *decode_x(struct bolt11 *b11,
/* BOLT #11:
*
* `c` (24): `data_length` variable. `min_final_cltv_expiry` to use for the
* `c` (24): `data_length` variable. `min_final_cltv_expiry_delta` to use for the
* last HTLC in the route. Default is 18 if not specified.
*/
static const char *decode_c(struct bolt11 *b11,
@@ -594,7 +594,7 @@ struct bolt11 *new_bolt11(const tal_t *ctx,
b11->expiry = DEFAULT_X;
b11->features = tal_arr(b11, u8, 0);
/* BOLT #11:
* - if the `c` field (`min_final_cltv_expiry`) is not provided:
* - if the `c` field (`min_final_cltv_expiry_delta`) is not provided:
* - MUST use an expiry delta of at least 18 when making the payment
*/
b11->min_final_cltv_expiry = 18;
@@ -1009,7 +1009,7 @@ static void push_field(u5 **data, char type, const void *src, size_t nbits)
*
* - if `x` is included:
* - SHOULD use the minimum `data_length` possible.
* - MUST include one `c` field (`min_final_cltv_expiry`).
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
*...
* - SHOULD use the minimum `data_length` possible.
*/
@@ -1278,7 +1278,7 @@ char *bolt11_encode_(const tal_t *ctx,
encode_x(&data, b11->expiry);
/* BOLT #11:
* - MUST include one `c` field (`min_final_cltv_expiry`).
* - MUST include one `c` field (`min_final_cltv_expiry_delta`).
*/
encode_c(&data, b11->min_final_cltv_expiry);

View File

@@ -13,7 +13,7 @@
/* BOLT #11:
* * `c` (24): `data_length` variable.
* `min_final_cltv_expiry` to use for the last HTLC in the route.
* `min_final_cltv_expiry_delta` to use for the last HTLC in the route.
* Default is 18 if not specified.
*/
#define DEFAULT_FINAL_CLTV_DELTA 18

View File

@@ -527,9 +527,9 @@ int main(int argc, char *argv[])
* * `x`: expiry time
* * `qy`: `data_length` (`q` = 0, `y` = 2; 0 * 32 + 4 == 4)
* * `jw5q`: 604800 seconds (`j` = 18, `w` = 14, `5` = 20, `q` = 0; 18 * 32^3 + 14 * 32^2 + 20 * 32 + 0 == 604800)
* * `c`: `min_final_cltv_expiry`
* * `c`: `min_final_cltv_expiry_delta`
* * `qp`: `data_length` (`q` = 0, `p` = 1; 0 * 32 + 1 == 1)
* * `2`: min_final_cltv_expiry = 10
* * `2`: min_final_cltv_expiry_delta = 10
* * `r`: tagged field: route information
* * `zj`: `data_length` (`z` = 2, `j` = 18; 2 * 32 + 18 == 82)
* * `q0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q`:

View File

@@ -311,6 +311,11 @@ static bool check_fwd_amount(struct htlc_in *hin,
* - MUST return an error if:
* ...
* - `cltv_expiry` - `cltv_expiry_delta` < `outgoing_cltv_value`
* - if it is the final node:
*...
* - MUST return an error if:
*...
* - incoming `cltv_expiry` < `outgoing_cltv_value`.
*/
static bool check_cltv(struct htlc_in *hin,
u32 cltv_expiry, u32 outgoing_cltv_value, u32 delta)
@@ -381,9 +386,9 @@ static void handle_localpay(struct htlc_in *hin,
* - MUST treat `total_msat` as if it were equal to `amt_to_forward` if it
* is not present.
* - MUST return an error if:
* - incoming `amount_msat` != `amt_to_forward`.
* - incoming `amount_msat` < `amt_to_forward`.
*/
if (!amount_msat_eq(amt_to_forward, hin->msat)) {
if (amount_msat_less(hin->msat, amt_to_forward)) {
log_debug(hin->key.channel->log,
"HTLC %"PRIu64" final incorrect amount:"
" %s in, %s expected",
@@ -408,7 +413,7 @@ static void handle_localpay(struct htlc_in *hin,
* is not present.
* - MUST return an error if:
*...
* - incoming `cltv_expiry` != `cltv_expiry_delta`.
* - incoming `cltv_expiry` < `outgoing_cltv_value`.
*/
if (!check_cltv(hin, hin->cltv_expiry, outgoing_cltv_value, 0)) {
/* BOLT #4:
@@ -426,10 +431,7 @@ static void handle_localpay(struct htlc_in *hin,
/* BOLT #4:
*
* - if the `cltv_expiry` value is unreasonably near the present:
* - MUST fail the HTLC.
* - MUST return an `incorrect_or_unknown_payment_details` error.
*/
* incoming `cltv_expiry` < `current_block_height` + `min_final_cltv_expiry_delta`. */
if (get_block_height(ld->topology) + ld->config.cltv_final
> hin->cltv_expiry) {
log_debug(hin->key.channel->log,