mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
topology: don't call gossmap for locall added channels.
This happens in deprecated mode, and we get bogus results. Valgrind caught it! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
82819433bc
commit
8454e4910a
3 changed files with 24 additions and 9 deletions
|
@ -1249,6 +1249,8 @@ void gossmap_chan_get_update_details(const struct gossmap *map,
|
|||
const size_t htlc_maximum_off = fee_prop_off + 4;
|
||||
|
||||
assert(gossmap_chan_set(chan, dir));
|
||||
/* Not allowed on local updates! */
|
||||
assert(chan->cann_off < map->map_size);
|
||||
|
||||
if (timestamp)
|
||||
*timestamp = map_be32(map, timestamp_off);
|
||||
|
|
|
@ -155,7 +155,7 @@ u8 *gossmap_node_get_features(const tal_t *ctx,
|
|||
const struct gossmap_node *n);
|
||||
|
||||
/* Returns details from channel_update (must be gossmap_chan_set, and
|
||||
* does not work for local_updatechan! */
|
||||
* does not work for local_updatechan)! */
|
||||
void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
const struct gossmap_chan *chan,
|
||||
int dir,
|
||||
|
|
|
@ -266,14 +266,27 @@ static void json_add_halfchan(struct json_stream *response,
|
|||
json_add_num(response, "direction", dir);
|
||||
json_add_bool(response, "public", !c->private);
|
||||
|
||||
gossmap_chan_get_update_details(gossmap, c, dir,
|
||||
×tamp,
|
||||
&message_flags,
|
||||
&channel_flags,
|
||||
&fee_base_msat,
|
||||
&fee_proportional_millionths,
|
||||
&htlc_minimum_msat,
|
||||
&htlc_maximum_msat);
|
||||
if (c->private) {
|
||||
/* Local additions don't have a channel_update
|
||||
* in gossmap. This is deprecated anyway, but
|
||||
* fill in values from entry we added. */
|
||||
timestamp = time_now().ts.tv_sec;
|
||||
message_flags = (ROUTING_OPT_HTLC_MAX_MSAT|ROUTING_OPT_DONT_FORWARD);
|
||||
channel_flags = node_id_idx(&node_id[dir], &node_id[!dir]);
|
||||
fee_base_msat = c->half[dir].base_fee;
|
||||
fee_proportional_millionths = c->half[dir].proportional_fee;
|
||||
htlc_minimum_msat = amount_msat(fp16_to_u64(c->half[dir].htlc_min));
|
||||
htlc_maximum_msat = amount_msat(fp16_to_u64(c->half[dir].htlc_max));
|
||||
} else {
|
||||
gossmap_chan_get_update_details(gossmap, c, dir,
|
||||
×tamp,
|
||||
&message_flags,
|
||||
&channel_flags,
|
||||
&fee_base_msat,
|
||||
&fee_proportional_millionths,
|
||||
&htlc_minimum_msat,
|
||||
&htlc_maximum_msat);
|
||||
}
|
||||
|
||||
json_add_amount_sat_msat(response, "amount_msat", capacity);
|
||||
json_add_num(response, "message_flags", message_flags);
|
||||
|
|
Loading…
Add table
Reference in a new issue