Right now to recover from a backup with an encrypted HD wallet the user must do something like unlock the wallet with a really long time out and manually trigger a rescan,  otherwise they risk missing some keys when auto-topup cannot run.
return -1 * (GetLastBlockHeight() - conf->conflicting_block_height + 1);
    } else {
        return 0;
    }
}
int CWalletGetTxBlocksToMaturity(const CWalletTx& wtx) const
{
    AssertLockHeld(cs_);
    if (!wtx.IsCoinBase()) {
        return 0;
    }
    int chain_depth = GetTxDepthInMainChain(wtx);
    assert(chain_depth >= 0); // coinbase tx should not be conflicted
    return stdmax(0, (COINBASE_MATURITY+1) - chain_depth);
}
bool CWalletIsTxImmatureCoinBase(const CWalletTx& wtx) const
{
    AssertLockHeld(cs_);
    // note GetBlocksToMaturity is 0 for non-coinbase tx
    return GetTxBlocksToMaturity(wtx) > 0;
}
bool CWalletIsCrypted() const
{
    return HasEncryptionKeys();
}
bool CWalletIsLocked() const
{
    if (!IsCrypted()) {
        return false;
    }