lightningd: update to add wire_expiry_too_far.

From recently-merged BOLT update.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-11-01 12:51:00 +10:30 committed by Christian Decker
parent 1ae57fb72c
commit 860a76b1c9
2 changed files with 10 additions and 3 deletions

View File

@ -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;
}

View File

@ -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