mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
opening: use correct dust_limit for reserve floor
Fixes #4140 Reported-By: @PsySc0rpi0n Changelog-Fixed: openingd now uses the correct dust limit for determining the allowable floor for a channel open (affects fundee only)
This commit is contained in:
parent
1b3a9be416
commit
ae825fff26
@ -197,7 +197,7 @@ static void negotiation_failed(struct state *state, bool am_opener,
|
||||
}
|
||||
|
||||
/* We always set channel_reserve_satoshis to 1%, rounded down. */
|
||||
static void set_reserve(struct state *state)
|
||||
static void set_reserve(struct state *state, const struct amount_sat dust_limit)
|
||||
{
|
||||
state->localconf.channel_reserve = amount_sat_div(state->funding, 100);
|
||||
|
||||
@ -206,12 +206,12 @@ static void set_reserve(struct state *state)
|
||||
* The sending node:
|
||||
*...
|
||||
* - MUST set `channel_reserve_satoshis` greater than or equal to
|
||||
* `dust_limit_satoshis`.
|
||||
* `dust_limit_satoshis` from the `open_channel` message.
|
||||
*/
|
||||
if (amount_sat_greater(state->localconf.dust_limit,
|
||||
if (amount_sat_greater(dust_limit,
|
||||
state->localconf.channel_reserve))
|
||||
state->localconf.channel_reserve
|
||||
= state->localconf.dust_limit;
|
||||
= dust_limit;
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
@ -338,7 +338,7 @@ static bool setup_channel_funder(struct state *state)
|
||||
{
|
||||
/*~ For symmetry, we calculate our own reserve even though lightningd
|
||||
* could do it for the we-are-funding case. */
|
||||
set_reserve(state);
|
||||
set_reserve(state, state->localconf.dust_limit);
|
||||
|
||||
/*~ Grab a random ID until the funding tx is created (we can't do that
|
||||
* until we know their funding_pubkey) */
|
||||
@ -891,7 +891,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||
}
|
||||
|
||||
/* This reserves 1% of the channel (rounded up) */
|
||||
set_reserve(state);
|
||||
set_reserve(state, state->remoteconf.dust_limit);
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user