mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
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>
This commit is contained in:
parent
8cc7f31d44
commit
3a9c559dc6
@ -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;
|
||||
|
@ -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…
Reference in New Issue
Block a user