mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 17:14:28 +01:00
lightningd: enforce htlc_maximum_msat.
When we let them set it, this matters! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -202,9 +202,10 @@ struct channel {
|
||||
/* Feerate per channel */
|
||||
u32 feerate_base, feerate_ppm;
|
||||
|
||||
/* But allow these feerates up until this time. */
|
||||
/* But allow these feerates/htlcs up until this time. */
|
||||
struct timeabs old_feerate_timeout;
|
||||
u32 old_feerate_base, old_feerate_ppm;
|
||||
struct amount_msat old_htlc_maximum_msat;
|
||||
|
||||
/* If they used option_upfront_shutdown_script. */
|
||||
const u8 *remote_upfront_shutdown_script;
|
||||
|
||||
@@ -2015,6 +2015,7 @@ static void set_channel_fees(struct command *cmd, struct channel *channel,
|
||||
= timeabs_add(time_now(), time_from_sec(delaysecs));
|
||||
channel->old_feerate_base = channel->feerate_base;
|
||||
channel->old_feerate_ppm = channel->feerate_ppm;
|
||||
channel->old_htlc_maximum_msat = channel->htlc_maximum_msat;
|
||||
}
|
||||
|
||||
/* set new values */
|
||||
|
||||
@@ -656,6 +656,18 @@ static void forward_htlc(struct htlc_in *hin,
|
||||
"Allowing payment using older feerate");
|
||||
}
|
||||
|
||||
if (amount_msat_greater(amt_to_forward, next->htlc_maximum_msat)) {
|
||||
/* Are we in old-max grace-period? */
|
||||
if (!time_before(time_now(), next->old_feerate_timeout)
|
||||
|| amount_msat_greater(amt_to_forward, next->old_htlc_maximum_msat)) {
|
||||
failmsg = towire_temporary_channel_failure(tmpctx,
|
||||
get_channel_update(next));
|
||||
goto fail;
|
||||
}
|
||||
log_info(hin->key.channel->log,
|
||||
"Allowing large htlc using older htlc_maximum_msat");
|
||||
}
|
||||
|
||||
if (!check_cltv(hin, cltv_expiry, outgoing_cltv_value,
|
||||
ld->config.cltv_expiry_delta)) {
|
||||
failmsg = towire_incorrect_cltv_expiry(tmpctx, cltv_expiry,
|
||||
|
||||
Reference in New Issue
Block a user