https://travis-ci.org/github/bitcoin/bitcoin/jobs/679885530#L8791
}
    
    std::map<CKeyID, const CWalletTx::Confirmation*> mapKeyFirstBlock;
    CWalletTx::Confirmation max_confirm;
    max_confirm.block_height = GetLastBlockHeight() > 144 ? GetLastBlockHeight() - 144 : 0; 
    CHECK_NONFATAL(chain().findAncestorByHeight(GetLastBlockHash(), max_confirm.block_height, FoundBlock().hash(max_confirm.hashBlock)));
    for (const CKeyID &keyid : spk_man->GetKeys()) {
        if (mapKeyBirth.count(keyid) == 0)
            mapKeyFirstBlock[keyid] = &max_confirm;
    }
    
    if (mapKeyFirstBlock.empty())
        return;
    
    for (const auto& entry : mapWallet) {
        
        const CWalletTx &wtx = entry.second;
        if (wtx.m_confirm.status == CWalletTx::CONFIRMED) {
            
            for (const CTxOut &txout : wtx.tx->vout) {
                
                for (const auto &keyid : GetAffectedKeys(txout.scriptPubKey, *spk_man)) {
                    
                    auto rit = mapKeyFirstBlock.find(keyid);
                    if (rit != mapKeyFirstBlock.end() && wtx.m_confirm.block_height < rit->second->block_height) {
                        rit->second = &wtx.m_confirm;
                    }
                }
            }
        }