closingd: allow higher closing fee if anchor_outputs.

This follows https://github.com/lightningnetwork/lightning-rfc/pull/847.

For anchor_outputs, we pass down a max_feerate to closingd, and set the
fee ceiling to MAX.  It uses that to estimate the desired closing fee.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: Anchor output mutual close allow a fee higher than the final commitment transaction (as per lightning-rfc #847)
This commit is contained in:
Rusty Russell
2021-09-08 14:10:29 +09:30
parent 79d7e83f51
commit 1752616386
5 changed files with 98 additions and 36 deletions

View File

@@ -193,7 +193,7 @@ void peer_start_closingd(struct channel *channel,
struct per_peer_state *pps)
{
u8 *initmsg;
u32 feerate;
u32 feerate, *max_feerate;
struct amount_msat their_msat;
struct amount_sat feelimit;
int hsmfd;
@@ -253,6 +253,19 @@ void peer_start_closingd(struct channel *channel,
feerate = feerate_floor();
}
/* We use a feerate if anchor_outputs, otherwise max fee is set by
* the final unilateral. */
if (channel->option_anchor_outputs) {
max_feerate = tal(tmpctx, u32);
/* Aim for reasonable max, but use final if we don't know. */
*max_feerate = unilateral_feerate(ld->topology);
if (!*max_feerate)
*max_feerate = final_commit_feerate;
/* No other limit on fees */
feelimit = channel->funding;
} else
max_feerate = NULL;
/* BOLT #3:
*
* Each node offering a signature:
@@ -285,7 +298,9 @@ void peer_start_closingd(struct channel *channel,
amount_msat_to_sat_round_down(channel->our_msat),
amount_msat_to_sat_round_down(their_msat),
channel->our_config.dust_limit,
feerate_min(ld, NULL), feerate, feelimit,
feerate_min(ld, NULL), feerate,
max_feerate,
feelimit,
channel->shutdown_scriptpubkey[LOCAL],
channel->shutdown_scriptpubkey[REMOTE],
channel->closing_fee_negotiation_step,