diff --git a/channeld/channeld.c b/channeld/channeld.c index a053b8509..522984bac 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -217,9 +217,6 @@ struct peer { * channel with the real scid. */ bool gossip_scid_announced; - /* Most recent channel_update message. */ - u8 *channel_update; - /* --experimental-upgrade-protocol */ bool experimental_upgrade; }; @@ -5299,15 +5296,6 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) billboard_update(peer); } -static const u8 *get_cupdate(const struct peer *peer) -{ - /* Technically we only need to tell it the first time (unless it's - * changed). But it's not that common. */ - wire_sync_write(MASTER_FD, - take(towire_channeld_used_channel_update(NULL))); - return peer->channel_update; -} - static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) { u8 *msg; @@ -5363,7 +5351,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) peer->htlc_id++; return; case CHANNEL_ERR_INVALID_EXPIRY: - failwiremsg = towire_incorrect_cltv_expiry(inmsg, cltv_expiry, get_cupdate(peer)); + failwiremsg = towire_incorrect_cltv_expiry(inmsg, cltv_expiry, NULL); failstr = tal_fmt(inmsg, "Invalid cltv_expiry %u", cltv_expiry); goto failed; case CHANNEL_ERR_DUPLICATE: @@ -5377,18 +5365,18 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) goto failed; /* FIXME: Fuzz the boundaries a bit to avoid probing? */ case CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED: - failwiremsg = towire_temporary_channel_failure(inmsg, get_cupdate(peer)); + failwiremsg = towire_temporary_channel_failure(inmsg, NULL); failstr = tal_fmt(inmsg, "Capacity exceeded - HTLC fee: %s", fmt_amount_sat(inmsg, htlc_fee)); goto failed; case CHANNEL_ERR_HTLC_BELOW_MINIMUM: - failwiremsg = towire_amount_below_minimum(inmsg, amount, get_cupdate(peer)); + failwiremsg = towire_amount_below_minimum(inmsg, amount, NULL); failstr = tal_fmt(inmsg, "HTLC too small (%s minimum)", type_to_string(tmpctx, struct amount_msat, &peer->channel->config[REMOTE].htlc_minimum)); goto failed; case CHANNEL_ERR_TOO_MANY_HTLCS: - failwiremsg = towire_temporary_channel_failure(inmsg, get_cupdate(peer)); + failwiremsg = towire_temporary_channel_failure(inmsg, NULL); failstr = "Too many HTLCs"; goto failed; case CHANNEL_ERR_DUST_FAILURE: @@ -5398,7 +5386,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) * - SHOULD NOT send this HTLC * - SHOULD fail this HTLC if it's forwarded */ - failwiremsg = towire_temporary_channel_failure(inmsg, get_cupdate(peer)); + failwiremsg = towire_temporary_channel_failure(inmsg, NULL); failstr = "HTLC too dusty, allowed dust limit reached"; goto failed; } @@ -5406,6 +5394,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) abort(); failed: + /* lightningd appends update to this for us */ msg = towire_channeld_offer_htlc_reply(NULL, 0, failwiremsg, failstr); wire_sync_write(MASTER_FD, take(msg)); } @@ -5612,14 +5601,6 @@ static void handle_shutdown_cmd(struct peer *peer, const u8 *inmsg) start_commit_timer(peer); } -/* Lightningd tells us when channel_update has changed. */ -static void handle_channel_update(struct peer *peer, const u8 *msg) -{ - peer->channel_update = tal_free(peer->channel_update); - if (!fromwire_channeld_channel_update(peer, msg, &peer->channel_update)) - master_badmsg(WIRE_CHANNELD_CHANNEL_UPDATE, msg); -} - static void handle_send_error(struct peer *peer, const u8 *msg) { char *reason; @@ -5719,9 +5700,6 @@ static void req_in(struct peer *peer, const u8 *msg) case WIRE_CHANNELD_SEND_ERROR: handle_send_error(peer, msg); return; - case WIRE_CHANNELD_CHANNEL_UPDATE: - handle_channel_update(peer, msg); - return; case WIRE_CHANNELD_SPLICE_INIT: handle_splice_init(peer, msg); return; @@ -5776,7 +5754,6 @@ static void req_in(struct peer *peer, const u8 *msg) case WIRE_CHANNELD_SEND_ERROR_REPLY: case WIRE_CHANNELD_DEV_QUIESCE_REPLY: case WIRE_CHANNELD_UPGRADED: - case WIRE_CHANNELD_USED_CHANNEL_UPDATE: case WIRE_CHANNELD_LOCAL_CHANNEL_UPDATE: case WIRE_CHANNELD_LOCAL_CHANNEL_ANNOUNCEMENT: case WIRE_CHANNELD_LOCAL_PRIVATE_CHANNEL: @@ -5879,7 +5856,6 @@ static void init_channel(struct peer *peer) &peer->dev_disable_commit, &pbases, &reestablish_only, - &peer->channel_update, &peer->experimental_upgrade, &peer->splice_state->inflights)) { master_badmsg(WIRE_CHANNELD_INIT, msg); diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index 5174c18e0..b205a28bd 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -81,8 +81,6 @@ msgdata,channeld_init,dev_disable_commit,?u32, msgdata,channeld_init,num_penalty_bases,u32, msgdata,channeld_init,pbases,penalty_base,num_penalty_bases msgdata,channeld_init,reestablish_only,bool, -msgdata,channeld_init,channel_update_len,u16, -msgdata,channeld_init,channel_update,u8,channel_update_len msgdata,channeld_init,experimental_upgrade,bool, msgdata,channeld_init,num_inflights,u16, msgdata,channeld_init,inflights,inflight,num_inflights @@ -331,14 +329,6 @@ msgdata,channeld_send_error,reason,wirestring, # Tell master channeld has sent the error message. msgtype,channeld_send_error_reply,1108 -# Tell channeld about the latest channel_update -msgtype,channeld_channel_update,1001 -msgdata,channeld_channel_update,len,u16, -msgdata,channeld_channel_update,msg,u8,len - -# Tell lightningd we used the latest channel_update for an error. -msgtype,channeld_used_channel_update,1102 - # Channeld: tell gossipd to make this channel_update. msgtype,channeld_local_channel_update,1013 msgdata,channeld_local_channel_update,short_channel_id,short_channel_id, diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 2220494a3..1cac6339a 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -1240,10 +1240,6 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds) case WIRE_CHANNELD_SEND_ERROR_REPLY: handle_error_channel(sd->channel, msg); break; - case WIRE_CHANNELD_USED_CHANNEL_UPDATE: - /* This tells gossipd we used it. */ - get_channel_update(sd->channel); - break; case WIRE_CHANNELD_LOCAL_CHANNEL_UPDATE: tell_gossipd_local_channel_update(sd->ld, sd->channel, msg); break; @@ -1300,7 +1296,6 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds) case WIRE_CHANNELD_FEERATES: case WIRE_CHANNELD_BLOCKHEIGHT: case WIRE_CHANNELD_CONFIG_CHANNEL: - case WIRE_CHANNELD_CHANNEL_UPDATE: case WIRE_CHANNELD_DEV_MEMLEAK: case WIRE_CHANNELD_DEV_QUIESCE: case WIRE_CHANNELD_GOT_INFLIGHT: @@ -1560,7 +1555,6 @@ bool peer_start_channeld(struct channel *channel, : (u32 *)&ld->dev_disable_commit, pbases, reestablish_only, - channel->channel_update, ld->experimental_upgrade_protocol, cast_const2(const struct inflight **, inflights)); @@ -1837,14 +1831,6 @@ void channel_replace_update(struct channel *channel, u8 *update TAKES) { tal_free(channel->channel_update); channel->channel_update = tal_dup_talarr(channel, u8, update); - - /* Keep channeld up-to-date */ - if (!channel->owner || !streq(channel->owner->name, "channeld")) - return; - - subd_send_msg(channel->owner, - take(towire_channeld_channel_update(NULL, - channel->channel_update))); } static struct command_result *param_channel_for_splice(struct command *cmd, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index ebbaa869e..ea62a190d 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -527,6 +527,11 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU } if (tal_count(failmsg)) { + /* It's our job to append the channel_update */ + if (fromwire_peektype(failmsg) & UPDATE) { + const u8 *update = get_channel_update(hout->key.channel); + towire(&failmsg, update, tal_bytelen(update)); + } hout->failmsg = tal_steal(hout, failmsg); if (hout->am_origin) { char *localfail = tal_fmt(msg, "%s: %s",