Browse Source

lightningd/channel: quote BOLT #2 for checking expiry.

https://github.com/lightningnetwork/lightning-rfc/pull/138:

	 BOLT 2: htlc-cltv must be in blocks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
3a9c559dc6
  1. 9
      lightningd/channel.c
  2. 4
      lightningd/channel.h

9
lightningd/channel.c

@ -227,7 +227,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
enum side sender,
u64 id,
u64 msatoshi,
u32 expiry,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 routing[1254])
{
@ -248,7 +248,12 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
htlc->state = RCVD_ADD_HTLC;
htlc->id = id;
htlc->msatoshi = msatoshi;
if (!blocks_to_abs_locktime(expiry, &htlc->expiry))
/* BOLT #2:
*
* A receiving node SHOULD fail the channel if a sending node... sets
* `cltv-expiry` to greater or equal to 500000000.
*/
if (!blocks_to_abs_locktime(cltv_expiry, &htlc->expiry))
return CHANNEL_ERR_INVALID_EXPIRY;
htlc->rhash = *payment_hash;
htlc->r = NULL;

4
lightningd/channel.h

@ -207,7 +207,7 @@ enum channel_add_err {
* @offerer: the side offering the HTLC (to the other side).
* @id: unique HTLC id.
* @msatoshi: amount in millisatoshi.
* @expiry: block number when HTLC can no longer be redeemed.
* @cltv_expiry: block number when HTLC can no longer be redeemed.
* @payment_hash: hash whose preimage can redeem HTLC.
* @routing: routing information (copied)
*
@ -219,7 +219,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
enum side sender,
u64 id,
u64 msatoshi,
u32 expiry,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 routing[1254]);

Loading…
Cancel
Save