Skip to content

Commit

Permalink
gossipd: set no_forward bit on channel_update for private channels.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Added: Protocol: We now set the `dont_forward` bit on private channel_update's message_flags (as per latest BOLTs).
  • Loading branch information
rustyrussell committed Sep 24, 2022
1 parent bb49e1b commit bfc21cb
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
18 changes: 10 additions & 8 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
1 change: 1 addition & 0 deletions channeld/channeld_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions gossipd/gossip_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
}

Expand All @@ -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,
Expand All @@ -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);
}

Expand All @@ -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];

Expand Down
1 change: 1 addition & 0 deletions gossipd/gossipd_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gossipd/test/run-check_node_announcement.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gossipd/test/run-crc32_of_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions lightningd/gossip_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand All @@ -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,
Expand Down

0 comments on commit bfc21cb

Please sign in to comment.