GambleCoin-Project / GambleCoin

GambleCoin (GMCN) Official Core Project
http://www.gamblecoin-info.com/
MIT License
5 stars 6 forks source link

Fix backwards compatibility issue in autocombinerewards #27

Closed CaveSpectre11 closed 5 years ago

CaveSpectre11 commented 5 years ago

Those with an autocombinereward record in their wallet, will get a wallet.dat corruption error on startup. This needs to be handled.

https://github.com/PIVX-Project/PIVX/pull/873

bool getAutocombineSettings()
{
    bool fAutocombineException = false;

    try {
        std::pair<std::pair<bool, CAmount>,int> pSettings;
        ssValue >> pSettings;
        pwallet->fCombineDust = pSettings.first.first;
        pwallet->nAutoCombineThreshold = pSettings.first.second;
        pwallet->nAutoCombineBlockFrequency = pSettings.second;
    } catch (...) {
        fAutocombineException = true;
    }

    if (fAutocombineException) {
        try {
            pwallet->fCombineDust = pSettings.first;
            pwallet->nAutoCombineThreshold = pSettings.second;
            pwallet->nAutoCombineBlockFrequency = 15;  // interpret for new functionality
            // include notification to user in an attempt to get them to redo their autocombinereward 
        } catch (...) {
            return false;
        }
    }
    return true;
}
CaveSpectre11 commented 5 years ago

Fixed with PR #37 . Anyone using the alpha version of the new wallet, and this feature, may have to re-establish their settings. Anyone having used the feature in the old wallet, however, will not see any adverse effect of the autocombinerewards improvements (whereas without this fix, they will have experienced non-critical wallet.dat load errors on wallet startup until they re-issued autocombinerewards.