Browse Source

lightningd: update to add `wire_expiry_too_far`.

From recently-merged BOLT update.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
860a76b1c9
  1. 12
      lightningd/peer_htlcs.c
  2. 1
      wire/gen_onion_wire_csv

12
lightningd/peer_htlcs.c

@ -153,6 +153,8 @@ static u8 *make_failmsg(const tal_t *ctx,
return towire_incorrect_cltv_expiry(ctx, 0, channel_update);
case WIRE_EXPIRY_TOO_SOON:
return towire_expiry_too_soon(ctx, channel_update);
case WIRE_EXPIRY_TOO_FAR:
return towire_expiry_too_far(ctx);
case WIRE_UNKNOWN_PAYMENT_HASH:
return towire_unknown_payment_hash(ctx);
case WIRE_INCORRECT_PAYMENT_AMOUNT:
@ -545,7 +547,12 @@ static void forward_htlc(struct htlc_in *hin,
goto fail;
}
/* FIXME: Add this to BOLT! */
/* BOLT #4:
*
* If the `cltv_expiry` is unreasonably far, we can also report an error:
*
* 1. type: 21 (`expiry_too_far`)
*/
if (get_block_height(next->ld->topology)
+ next->ld->config.max_htlc_expiry < outgoing_cltv_value) {
log_debug(hin->key.peer->log,
@ -553,8 +560,7 @@ static void forward_htlc(struct htlc_in *hin,
outgoing_cltv_value,
get_block_height(next->ld->topology),
next->ld->config.max_htlc_expiry);
/* FIXME: WIRE_EXPIRY_TOO_FAR? */
failcode = WIRE_TEMPORARY_CHANNEL_FAILURE;
failcode = WIRE_EXPIRY_TOO_FAR;
goto fail;
}

1
wire/gen_onion_wire_csv

@ -30,6 +30,7 @@ incorrect_cltv_expiry,6,channel_update,len
expiry_too_soon,UPDATE|14
expiry_too_soon,0,len,2
expiry_too_soon,2,channel_update,len
expiry_too_far,21
channel_disabled,UPDATE|20
unknown_payment_hash,PERM|15
incorrect_payment_amount,PERM|16

Loading…
Cancel
Save