diff --git a/channeld/channeld.c b/channeld/channeld.c index 5e20d71e7..51a39c6fe 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -369,14 +369,16 @@ static void send_channel_update(struct peer *peer, int disable_flag) assert(peer->short_channel_ids[LOCAL].u64); msg = towire_channeld_local_channel_update(NULL, - &peer->short_channel_ids[LOCAL], - disable_flag - == ROUTING_FLAGS_DISABLED, - peer->cltv_delta, - peer->htlc_minimum_msat, - peer->fee_base, - peer->fee_per_satoshi, - peer->htlc_maximum_msat); + &peer->short_channel_ids[LOCAL], + disable_flag + == ROUTING_FLAGS_DISABLED, + peer->cltv_delta, + peer->htlc_minimum_msat, + peer->fee_base, + peer->fee_per_satoshi, + peer->htlc_maximum_msat, + peer->channel_flags + & CHANNEL_FLAGS_ANNOUNCE_CHANNEL); wire_sync_write(MASTER_FD, take(msg)); } diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index 78abd7341..8827fa7b8 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -256,6 +256,7 @@ msgdata,channeld_local_channel_update,htlc_minimum_msat,amount_msat, msgdata,channeld_local_channel_update,fee_base_msat,u32, msgdata,channeld_local_channel_update,fee_proportional_millionths,u32, msgdata,channeld_local_channel_update,htlc_maximum_msat,amount_msat, +msgdata,channeld_local_channel_update,public,bool, # Channeld: tell gossipd about our channel_announcement msgtype,channeld_local_channel_announcement,1014 diff --git a/gossipd/gossip_generation.c b/gossipd/gossip_generation.c index 1ac944110..44c4afa8b 100644 --- a/gossipd/gossip_generation.c +++ b/gossipd/gossip_generation.c @@ -513,7 +513,8 @@ static u8 *create_unsigned_update(const tal_t *ctx, struct amount_msat htlc_minimum, struct amount_msat htlc_maximum, u32 fee_base_msat, - u32 fee_proportional_millionths) + u32 fee_proportional_millionths, + bool public) { secp256k1_ecdsa_signature dummy_sig; u8 message_flags, channel_flags; @@ -548,6 +549,8 @@ static u8 *create_unsigned_update(const tal_t *ctx, * | 1 | `dont_forward` | */ message_flags = ROUTING_OPT_HTLC_MAX_MSAT; + if (!public) + message_flags |= ROUTING_OPT_DONT_FORWARD; /* We create an update with a dummy signature and timestamp. */ return towire_channel_update(ctx, @@ -771,7 +774,8 @@ void refresh_local_channel(struct daemon *daemon, false, cltv_expiry_delta, htlc_minimum, htlc_maximum, fee_base_msat, - fee_proportional_millionths); + fee_proportional_millionths, + !(message_flags & ROUTING_OPT_DONT_FORWARD)); sign_timestamp_and_apply_update(daemon, chan, direction, take(update)); } @@ -788,6 +792,7 @@ void handle_local_channel_update(struct daemon *daemon, const u8 *msg) int direction; u8 *unsigned_update; const struct half_chan *hc; + bool public; if (!fromwire_gossipd_local_channel_update(msg, &id, @@ -797,7 +802,8 @@ void handle_local_channel_update(struct daemon *daemon, const u8 *msg) &htlc_minimum, &fee_base_msat, &fee_proportional_millionths, - &htlc_maximum)) { + &htlc_maximum, + &public)) { master_badmsg(WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE, msg); } @@ -822,7 +828,8 @@ void handle_local_channel_update(struct daemon *daemon, const u8 *msg) disable, cltv_expiry_delta, htlc_minimum, htlc_maximum, fee_base_msat, - fee_proportional_millionths); + fee_proportional_millionths, + public); hc = &chan->half[direction]; diff --git a/gossipd/gossipd_wire.csv b/gossipd/gossipd_wire.csv index c058a1dfb..35594b633 100644 --- a/gossipd/gossipd_wire.csv +++ b/gossipd/gossipd_wire.csv @@ -103,6 +103,7 @@ msgdata,gossipd_local_channel_update,htlc_minimum_msat,amount_msat, msgdata,gossipd_local_channel_update,fee_base_msat,u32, msgdata,gossipd_local_channel_update,fee_proportional_millionths,u32, msgdata,gossipd_local_channel_update,htlc_maximum_msat,amount_msat, +msgdata,gossipd_local_channel_update,public,bool, # Send this channel_announcement msgtype,gossipd_local_channel_announcement,3006 diff --git a/gossipd/test/run-check_node_announcement.c b/gossipd/test/run-check_node_announcement.c index b7245bee3..a1119f775 100644 --- a/gossipd/test/run-check_node_announcement.c +++ b/gossipd/test/run-check_node_announcement.c @@ -34,7 +34,7 @@ void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED) struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "find_peer called!\n"); abort(); } /* Generated stub for fromwire_gossipd_local_channel_update */ -bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED) +bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED, bool *public UNNEEDED) { fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); } /* Generated stub for fromwire_gossipd_used_local_channel_update */ bool fromwire_gossipd_used_local_channel_update(const void *p UNNEEDED, struct short_channel_id *scid UNNEEDED) diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 0420958ed..2a8c197f6 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -55,7 +55,7 @@ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) { fprintf(stderr, "fromwire_gossipd_dev_set_max_scids_encode_size called!\n"); abort(); } /* Generated stub for fromwire_gossipd_local_channel_update */ -bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED) +bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED, bool *public UNNEEDED) { fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); } /* Generated stub for fromwire_gossipd_used_local_channel_update */ bool fromwire_gossipd_used_local_channel_update(const void *p UNNEEDED, struct short_channel_id *scid UNNEEDED) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 5f3c933cd..23b5eb8ee 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -286,7 +286,7 @@ void tell_gossipd_local_channel_update(struct lightningd *ld, const u8 *msg) { struct short_channel_id scid; - bool disable; + bool disable, public; u16 cltv_expiry_delta; struct amount_msat htlc_minimum_msat; u32 fee_base_msat, fee_proportional_millionths; @@ -297,7 +297,7 @@ void tell_gossipd_local_channel_update(struct lightningd *ld, &htlc_minimum_msat, &fee_base_msat, &fee_proportional_millionths, - &htlc_maximum_msat)) { + &htlc_maximum_msat, &public)) { channel_internal_error(channel, "bad channeld_local_channel_update %s", tal_hex(channel, msg)); @@ -317,7 +317,9 @@ void tell_gossipd_local_channel_update(struct lightningd *ld, cltv_expiry_delta, htlc_minimum_msat, fee_base_msat, - fee_proportional_millionths, htlc_maximum_msat))); + fee_proportional_millionths, + htlc_maximum_msat, + public))); } void tell_gossipd_local_channel_announce(struct lightningd *ld,