This is to track the regression introduced in master, which needs fixing for 0.14. See #9240, #9371, etc.
{
    LOCK2(cs_main, cs_wallet);
    CWalletDB walletdb(strWalletFile, "r+");
    std::set<uint256> todo;
    std::set<uint256> done;
    
    assert(mapWallet.count(hashTx));
    CWalletTx& origtx = mapWallet[hashTx];
    if (origtx.GetDepthInMainChain() > 0 || origtx.InMempool()) {
        return false;
    }