mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
channeld: generalize specific_feerates mesage into config_channel.
1. Add the htlc_max param. 2. Allow parameters to be unset, meaning "don't change". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
33bd251296
commit
4fdcee9a11
@ -3426,18 +3426,31 @@ static void handle_blockheight(struct peer *peer, const u8 *inmsg)
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_specific_feerates(struct peer *peer, const u8 *inmsg)
|
||||
static void handle_config_channel(struct peer *peer, const u8 *inmsg)
|
||||
{
|
||||
u32 base_old = peer->fee_base;
|
||||
u32 per_satoshi_old = peer->fee_per_satoshi;
|
||||
u32 *base, *ppm;
|
||||
struct amount_msat *htlc_max;
|
||||
bool changed;
|
||||
|
||||
if (!fromwire_channeld_specific_feerates(inmsg,
|
||||
&peer->fee_base,
|
||||
&peer->fee_per_satoshi))
|
||||
master_badmsg(WIRE_CHANNELD_SPECIFIC_FEERATES, inmsg);
|
||||
if (!fromwire_channeld_config_channel(inmsg, inmsg, &base, &ppm, &htlc_max))
|
||||
master_badmsg(WIRE_CHANNELD_CONFIG_CHANNEL, inmsg);
|
||||
|
||||
/* only send channel updates if values actually changed */
|
||||
if (peer->fee_base != base_old || peer->fee_per_satoshi != per_satoshi_old)
|
||||
changed = false;
|
||||
if (base && *base != peer->fee_base) {
|
||||
peer->fee_base = *base;
|
||||
changed = true;
|
||||
}
|
||||
if (ppm && *ppm != peer->fee_per_satoshi) {
|
||||
peer->fee_per_satoshi = *ppm;
|
||||
changed = true;
|
||||
}
|
||||
if (htlc_max && !amount_msat_eq(*htlc_max, peer->htlc_maximum_msat)) {
|
||||
peer->htlc_maximum_msat = *htlc_max;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
send_channel_update(peer, 0);
|
||||
}
|
||||
|
||||
@ -3627,10 +3640,10 @@ static void req_in(struct peer *peer, const u8 *msg)
|
||||
return;
|
||||
handle_fail(peer, msg);
|
||||
return;
|
||||
case WIRE_CHANNELD_SPECIFIC_FEERATES:
|
||||
case WIRE_CHANNELD_CONFIG_CHANNEL:
|
||||
if (handle_master_request_later(peer, msg))
|
||||
return;
|
||||
handle_specific_feerates(peer, msg);
|
||||
handle_config_channel(peer, msg);
|
||||
return;
|
||||
case WIRE_CHANNELD_SEND_SHUTDOWN:
|
||||
handle_shutdown_cmd(peer, msg);
|
||||
|
@ -216,10 +216,11 @@ msgtype,channeld_fail_fallen_behind,1028
|
||||
# This is NULL if option_static_remotekey.
|
||||
msgdata,channeld_fail_fallen_behind,remote_per_commitment_point,?pubkey,
|
||||
|
||||
# Handle a channel specific feerate base ppm configuration
|
||||
msgtype,channeld_specific_feerates,1029
|
||||
msgdata,channeld_specific_feerates,feerate_base,u32,
|
||||
msgdata,channeld_specific_feerates,feerate_ppm,u32,
|
||||
# Handle a channel-specific configuration change
|
||||
msgtype,channeld_config_channel,1029
|
||||
msgdata,channeld_config_channel,feerate_base,?u32,
|
||||
msgdata,channeld_config_channel,feerate_ppm,?u32,
|
||||
msgdata,channeld_config_channel,htlc_maximum,?amount_msat,
|
||||
|
||||
# When we receive announcement_signatures for channel announce
|
||||
msgtype,channeld_got_announcement,1017
|
||||
|
Can't render this file because it has a wrong number of fields in line 14.
|
@ -548,7 +548,7 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||
case WIRE_CHANNELD_DEV_REENABLE_COMMIT:
|
||||
case WIRE_CHANNELD_FEERATES:
|
||||
case WIRE_CHANNELD_BLOCKHEIGHT:
|
||||
case WIRE_CHANNELD_SPECIFIC_FEERATES:
|
||||
case WIRE_CHANNELD_CONFIG_CHANNEL:
|
||||
case WIRE_CHANNELD_CHANNEL_UPDATE:
|
||||
case WIRE_CHANNELD_DEV_MEMLEAK:
|
||||
case WIRE_CHANNELD_DEV_QUIESCE:
|
||||
|
@ -2028,7 +2028,8 @@ static void set_channel_fees(struct command *cmd, struct channel *channel,
|
||||
/* tell channeld to make a send_channel_update */
|
||||
if (channel->owner && streq(channel->owner->name, "channeld"))
|
||||
subd_send_msg(channel->owner,
|
||||
take(towire_channeld_specific_feerates(NULL, base, ppm)));
|
||||
take(towire_channeld_config_channel(NULL, &base, &ppm,
|
||||
NULL)));
|
||||
|
||||
/* save values to database */
|
||||
wallet_channel_save(cmd->ld->wallet, channel);
|
||||
|
@ -625,15 +625,15 @@ void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED)
|
||||
/* Generated stub for towire_channel_id */
|
||||
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_config_channel */
|
||||
u8 *towire_channeld_config_channel(const tal_t *ctx UNNEEDED, u32 *feerate_base UNNEEDED, u32 *feerate_ppm UNNEEDED, struct amount_msat *htlc_maximum UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_config_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_dev_memleak */
|
||||
u8 *towire_channeld_dev_memleak(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_dev_memleak called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_dev_reenable_commit */
|
||||
u8 *towire_channeld_dev_reenable_commit(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_dev_reenable_commit called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_specific_feerates */
|
||||
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
||||
/* Generated stub for towire_connectd_peer_final_msg */
|
||||
u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const u8 *msg UNNEEDED)
|
||||
{ fprintf(stderr, "towire_connectd_peer_final_msg called!\n"); abort(); }
|
||||
|
@ -693,6 +693,9 @@ void topology_add_sync_waiter_(const tal_t *ctx UNNEEDED,
|
||||
/* Generated stub for towire_channel_disabled */
|
||||
u8 *towire_channel_disabled(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channel_disabled called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_config_channel */
|
||||
u8 *towire_channeld_config_channel(const tal_t *ctx UNNEEDED, u32 *feerate_base UNNEEDED, u32 *feerate_ppm UNNEEDED, struct amount_msat *htlc_maximum UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_config_channel called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_dev_memleak */
|
||||
u8 *towire_channeld_dev_memleak(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_dev_memleak called!\n"); abort(); }
|
||||
@ -717,9 +720,6 @@ u8 *towire_channeld_offer_htlc(const tal_t *ctx UNNEEDED, struct amount_msat amo
|
||||
/* Generated stub for towire_channeld_sending_commitsig_reply */
|
||||
u8 *towire_channeld_sending_commitsig_reply(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_sending_commitsig_reply called!\n"); abort(); }
|
||||
/* Generated stub for towire_channeld_specific_feerates */
|
||||
u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_base UNNEEDED, u32 feerate_ppm UNNEEDED)
|
||||
{ fprintf(stderr, "towire_channeld_specific_feerates called!\n"); abort(); }
|
||||
/* Generated stub for towire_connectd_peer_disconnected */
|
||||
u8 *towire_connectd_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_connectd_peer_disconnected called!\n"); abort(); }
|
||||
|
Loading…
Reference in New Issue
Block a user