This is to track the regression introduced in master, which needs fixing for 0.14. See #9240, #9371, etc.
{
        nChange += GetChange(txout);
        if (!MoneyRange(nChange))
            throw std::runtime_error(std::string(__func__) + ": value out of range");
    }
    return nChange;
}
CPubKey CWallet::GenerateNewHDMasterKey()
{
    CKey key;
    key.MakeNewKey(true);
    int64_t nCreationTime = GetTime();
    CKeyMetadata metadata(nCreationTime);
    
    CPubKey pubkey = key.GetPubKey();
    assert(key.VerifyPubKey(pubkey));
    
    metadata.hdKeypath     = "m";
    metadata.hdMasterKeyID = pubkey.GetID();
    {
        LOCK(cs_wallet);
        
        mapKeyMetadata[pubkey.GetID()] = metadata;
        
        if (!AddKeyPubKey(key, pubkey))
            throw std::runtime_error(std::string(__func__) + ": AddKeyPubKey failed");
    }
    return pubkey;
}
bool CWallet::SetHDMasterKey(const CPubKey& pubkey)