diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index d606b57b5..6df2751ae 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -201,7 +201,7 @@ static void gossipd_new_blockheight_reply(struct subd *gossipd, } /* Now, finally update getinfo's blockheight */ - gossipd->ld->blockheight = ptr2int(blockheight); + gossipd->ld->gossip_blockheight = ptr2int(blockheight); } void gossip_notify_new_block(struct lightningd *ld, u32 blockheight) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index b4771d98c..981cf1ea9 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -244,7 +244,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) /*~ This is detailed in chaintopology.c */ ld->topology = new_topology(ld, ld->log); - ld->blockheight = 0; + ld->gossip_blockheight = 0; ld->daemon_parent_fd = -1; ld->proxyaddr = NULL; ld->always_use_proxy = false; diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 8a0f53e2b..b071bc741 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -198,7 +198,7 @@ struct lightningd { struct chain_topology *topology; /* Blockheight (as acknowledged by gossipd) */ - u32 blockheight; + u32 gossip_blockheight; /* HTLCs in flight. */ struct htlc_in_map *htlcs_in; diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index c0a18cef8..f32eb2917 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2418,7 +2418,16 @@ static struct command_result *json_getinfo(struct command *cmd, json_array_end(response); json_add_string(response, "version", version()); - json_add_num(response, "blockheight", cmd->ld->blockheight); + /* If we're still syncing, put the height we're up to here, so + * they can see progress! Otherwise use the height gossipd knows + * about, so tests work properly. */ + if (!topology_synced(cmd->ld->topology)) { + json_add_num(response, "blockheight", + get_block_height(cmd->ld->topology)); + } else { + json_add_num(response, "blockheight", + cmd->ld->gossip_blockheight); + } json_add_string(response, "network", chainparams->network_name); json_add_amount_msat_compat(response, wallet_total_forward_fees(cmd->ld->wallet),