wallet/wallet: assume not current if best height is 0

This is done to avoid the birthday rescan to fail if the chain backend
reports a bestheight of 0.

Earlier it could happen that we attempted to sync to the birthday, but
since only the genesis block was available, which would be rejected as
birthday block because of the timestamp, it would fail to find a block
and the sync would fail.
This commit is contained in:
Johan T. Halseth 2019-02-06 11:26:20 +01:00
parent ba03278a64
commit eef81a4124
No known key found for this signature in database
GPG key ID: 15BAADA29DA20D26

View file

@ -471,6 +471,12 @@ func (w *Wallet) scanChain(startHeight int32,
Checkpoints[len(w.chainParams.Checkpoints)-1].Height
}
isCurrent := func(bestHeight int32) bool {
// If the best height is zero, we assume the chain backend
// still is looking for peers to sync to.
if bestHeight == 0 {
return false
}
switch c := chainClient.(type) {
case *chain.NeutrinoClient:
return c.CS.IsCurrent()