Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion common/gossmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 21 additions & 8 deletions plugins/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
&timestamp,
&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,
&timestamp,
&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);
Expand Down
3 changes: 3 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):

bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: l1.rpc.listpeerchannels()['channels'] == [])
wait_for(lambda: l2.rpc.listpeerchannels()['channels'] == [])

# TEST 2: Cheat from post-upgrade.
Expand Down Expand Up @@ -3817,6 +3818,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):

bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeers() is empty:
wait_for(lambda: len(l1.rpc.listpeerchannels()['channels']) == 0)
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)

# TEST 3: Unilateral close from pre-upgrade
Expand Down Expand Up @@ -3852,6 +3854,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
bitcoind.generate_block(100, wait_for_mempool=txid)

# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: len(l1.rpc.listpeerchannels()['channels']) == 0)
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)

# TEST 4: Unilateral close from post-upgrade
Expand Down