This is to track the regression introduced in master, which needs fixing for 0.14. See #9240, #9371, etc.
{
    
    CKey key;                      
    CExtKey masterKey;             
    CExtKey accountKey;            
    CExtKey externalChainChildKey; 
    CExtKey childKey;              
    
    if (!GetKey(hdChain.masterKeyID, key))
        throw std::runtime_error(std::string(__func__) + ": Master key not found");
    masterKey.SetMaster(key.begin(), key.size());
    
    
    masterKey.Derive(accountKey, BIP32_HARDENED_KEY_LIMIT);
    
    accountKey.Derive(externalChainChildKey, BIP32_HARDENED_KEY_LIMIT);
    
    do {
        
        
        
        externalChainChildKey.Derive(childKey, hdChain.nExternalChainCounter | BIP32_HARDENED_KEY_LIMIT);
        metadata.hdKeypath = "m/0'/0'/" + std::to_string(hdChain.nExternalChainCounter) + "'";
        metadata.hdMasterKeyID = hdChain.masterKeyID;