Skip to content

Commit d332a97

Browse files
committed
lightningd/channel: quote BOLT #2 for checking expiry.
lightning/bolts#138: BOLT 2: htlc-cltv must be in blocks. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent f63cdab commit d332a97

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lightningd/channel.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
227227
enum side sender,
228228
u64 id,
229229
u64 msatoshi,
230-
u32 expiry,
230+
u32 cltv_expiry,
231231
const struct sha256 *payment_hash,
232232
const u8 routing[1254])
233233
{
@@ -248,7 +248,12 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
248248
htlc->state = RCVD_ADD_HTLC;
249249
htlc->id = id;
250250
htlc->msatoshi = msatoshi;
251-
if (!blocks_to_abs_locktime(expiry, &htlc->expiry))
251+
/* BOLT #2:
252+
*
253+
* A receiving node SHOULD fail the channel if a sending node... sets
254+
* `cltv-expiry` to greater or equal to 500000000.
255+
*/
256+
if (!blocks_to_abs_locktime(cltv_expiry, &htlc->expiry))
252257
return CHANNEL_ERR_INVALID_EXPIRY;
253258
htlc->rhash = *payment_hash;
254259
htlc->r = NULL;

lightningd/channel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ enum channel_add_err {
207207
* @offerer: the side offering the HTLC (to the other side).
208208
* @id: unique HTLC id.
209209
* @msatoshi: amount in millisatoshi.
210-
* @expiry: block number when HTLC can no longer be redeemed.
210+
* @cltv_expiry: block number when HTLC can no longer be redeemed.
211211
* @payment_hash: hash whose preimage can redeem HTLC.
212212
* @routing: routing information (copied)
213213
*
@@ -219,7 +219,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
219219
enum side sender,
220220
u64 id,
221221
u64 msatoshi,
222-
u32 expiry,
222+
u32 cltv_expiry,
223223
const struct sha256 *payment_hash,
224224
const u8 routing[1254]);
225225

0 commit comments

Comments
 (0)