Skip to content

Commit

Permalink
channeld: for anchors, use minrelayfee as minimum commit tx fee to al…
Browse files Browse the repository at this point in the history
…low.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jun 29, 2023
1 parent 6087dec commit a9d8f84
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,29 @@
static void update_feerates(struct lightningd *ld, struct channel *channel)
{
u8 *msg;
u32 feerate = unilateral_feerate(ld->topology,
channel_has(channel,
OPT_ANCHOR_OUTPUTS));
u32 min_feerate;
bool anchors = channel_type_has_anchors(channel->type);
u32 feerate = unilateral_feerate(ld->topology, anchors);

/* Nothing to do if we don't know feerate. */
if (!feerate)
return;

/* For anchors, we just need the commitment tx to relay. */
if (anchors)
min_feerate = get_feerate_floor(ld->topology);
else
min_feerate = feerate_min(ld, NULL);

log_debug(ld->log,
"update_feerates: feerate = %u, min=%u, max=%u, penalty=%u",
feerate,
feerate_min(ld, NULL),
min_feerate,
feerate_max(ld, NULL),
penalty_feerate(ld->topology));

msg = towire_channeld_feerates(NULL, feerate,
feerate_min(ld, NULL),
min_feerate,
feerate_max(ld, NULL),
penalty_feerate(ld->topology));
subd_send_msg(channel->owner, take(msg));
Expand Down Expand Up @@ -618,6 +624,7 @@ bool peer_start_channeld(struct channel *channel,
struct secret last_remote_per_commit_secret;
secp256k1_ecdsa_signature *remote_ann_node_sig, *remote_ann_bitcoin_sig;
struct penalty_base *pbases;
u32 min_feerate;

hsmfd = hsm_get_client_fd(ld, &channel->peer->id,
channel->dbid,
Expand Down Expand Up @@ -717,6 +724,12 @@ bool peer_start_channeld(struct channel *channel,
return false;
}

/* For anchors, we just need the commitment tx to relay. */
if (channel_type_has_anchors(channel->type))
min_feerate = get_feerate_floor(ld->topology);
else
min_feerate = feerate_min(ld, NULL);

initmsg = towire_channeld_init(tmpctx,
chainparams,
ld->our_features,
Expand All @@ -730,7 +743,7 @@ bool peer_start_channeld(struct channel *channel,
&channel->our_config,
&channel->channel_info.their_config,
channel->fee_states,
feerate_min(ld, NULL),
min_feerate,
feerate_max(ld, NULL),
penalty_feerate(ld->topology),
&channel->last_sig,
Expand Down

0 comments on commit a9d8f84

Please sign in to comment.