Post
Topic
Board Announcements (Altcoins)
Re: [ANN][LOC]LOCO|Quark|PoW/PoS|HiPos|Masternodes|Tor|NO ICO|10K Dev Fund[LOC][ANN]
by
jc12345
on 20/04/2016, 14:45:07 UTC
just checked small tx staking - can't confirm minimum weight limit, it's staked after 1470 confs with weight=3+.
can't imagine what makes megadestruct61's wallet stake every tx exactly at weight=6.
unless he has some special wallet version (club edition  Grin)

Staked coins for Loco mature after 200 blocks after which they become available for use. For staking purposes however, coins mature only after 1440 blocks after which the weight start to increase.

Code:
uint64_t CWallet::GetStakeWeight() const
{
    // Choose coins to use
    int64_t nBalance = GetBalance();

    if (nBalance <= nReserveBalance)
        return 0;

    vector vwtxPrev;

    set > setCoins;
    int64_t nValueIn = 0;

    if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn))
        return 0;

    if (setCoins.empty())
        return 0;

    uint64_t nWeight = 0;

    int64_t nCurrentTime = GetTime();
    CTxDB txdb("r");

    LOCK2(cs_main, cs_wallet);
    int nStakeMinConfirmations = 0;

    nStakeMinConfirmations = 1440;


    BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
    {
        CTxIndex txindex;
        if (pcoin.first->GetDepthInMainChain() >= nStakeMinConfirmations)
            nWeight += pcoin.first->vout[pcoin.second].nValue;
    }

    return nWeight;
}

and

Code:
// ppcoin: total coin age spent in transaction, in the unit of coin-days.
// Only those coins meeting minimum age requirement counts. As those
// transactions not in main chain are not currently indexed so we
// might not find out about their coin age. Older transactions are
// guaranteed to be in main chain by sync-checkpoint. This rule is
// introduced to help nodes establish a consistent view of the coin
// age (trust score) of competing branches.
bool CTransaction::GetCoinAge(CTxDB& txdb, const CBlockIndex* pindexPrev, uint64_t& nCoinAge) const
{
    CBigNum bnCentSecond = 0;  // coin age in the unit of cent-seconds
    nCoinAge = 0;
    int nStakeMinConfirmations = 0;

    if (IsCoinBase())
        return true;

    BOOST_FOREACH(const CTxIn& txin, vin)
    {
        // First try finding the previous transaction in database
        CTransaction txPrev;
        CTxIndex txindex;
        if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
            continue;  // previous transaction not in main chain
        if (nTime < txPrev.nTime)
            return false;  // Transaction timestamp violation

        int nSpendDepth;
        
nStakeMinConfirmations = 1440;


        if (IsConfirmedInNPrevBlocks(txindex, pindexPrev, nStakeMinConfirmations - 1, nSpendDepth))
        {
            LogPrint("coinage", "coin age skip nSpendDepth=%d\n", nSpendDepth + 1);
            continue; // only count coins meeting min confirmations requirement
        }

        int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
        bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT;

        LogPrint("coinage", "coin age nValueIn=%d nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString());
    }

    CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60);
    LogPrint("coinage", "coin age bnCoinDay=%s\n", bnCoinDay.ToString());
    nCoinAge = bnCoinDay.getuint64();
    return true;
}

and

Code:
void CWallet::AvailableCoinsForStaking(vector& vCoins, unsigned int nSpendTime) const
{
    vCoins.clear();

    {
        LOCK2(cs_main, cs_wallet);
        int nStakeMinConfirmations = 0;
        for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
        {
            const CWalletTx* pcoin = &(*it).second;

            int nDepth = pcoin->GetDepthInMainChain();
            if (nDepth < 1)
                continue;


            nStakeMinConfirmations = 1440;


            if (nDepth < nStakeMinConfirmations)
            {
                continue;
            }    
            else
            {
            // Filtering by tx timestamp instead of block timestamp may give false positives but never false negatives
            if (pcoin->nTime + nStakeMinAge > nSpendTime)
               continue;
            }
            
            if (pcoin->GetBlocksToMaturity() > 0)
                continue;

            for (unsigned int i = 0; i < pcoin->vout.size(); i++)
                if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue >= nMinimumInputValue)
                    vCoins.push_back(COutput(pcoin, i, nDepth, true));
        }
    }
}