obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits)));
obj.push_back(Pair("netmhashps", dNetworkMhps));
- obj.push_back(Pair("netstakeweight", nNetworkWeight));
+ obj.push_back(Pair("netstakeweight", (uint64_t) nNetworkWeight));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
- obj.push_back(Pair("stakeweight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain)));
+ obj.push_back(Pair("stakeweight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_NORMAL)));
+ obj.push_back(Pair("minweight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_MINWEIGHT)));
+ obj.push_back(Pair("maxweight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_MAXWEIGHT)));
+ obj.push_back(Pair("passiveweight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_BELOWMIN)));
obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetTime(), true)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
// NovaCoin: get current stake generation power
-uint64 CWallet::GetStakeMintPower(const CKeyStore& keystore)
+uint64 CWallet::GetStakeMintPower(const CKeyStore& keystore, enum StakeWeightMode mode)
{
LOCK2(cs_main, cs_wallet);
if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex))
continue;
- // Do not count input that is still too young
- if (pcoin.first->nTime + nStakeMaxAge > GetTime())
- continue;
+ switch(mode)
+ {
+ case STAKE_NORMAL:
+ // Do not count input that is still less than 30 days old
+ if (pcoin.first->nTime + nStakeMinAge > GetTime())
+ continue;
+ break;
+ case STAKE_MAXWEIGHT:
+ // Do not count input that is still less than 90 days old
+ if (pcoin.first->nTime + nStakeMaxAge > GetTime())
+ continue;
+ break;
+ case STAKE_MINWEIGHT:
+ // Count only inputs with suitable age (from 30 to 90 days old)
+ if (pcoin.first->nTime + nStakeMaxAge < GetTime())
+ continue;
+ if (pcoin.first->nTime + nStakeMinAge > GetTime())
+ continue;
+ break;
+ case STAKE_BELOWMIN:
+ // Count only inputs with suitable age (less than 30 days old)
+ if (pcoin.first->nTime + nStakeMinAge < GetTime())
+ continue;
+ break;
+ }
CBigNum bnCentSecond = CBigNum(pcoin.first->vout[pcoin.second].nValue) * (GetTime()-pcoin.first->nTime) / CENT;
CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60);
FEATURE_LATEST = 60000
};
+/** Stake weight calculation mode */
+enum StakeWeightMode
+{
+ STAKE_NORMAL = 0, // all 30+ days old inputs
+ STAKE_MAXWEIGHT = 1, // only 90+ days old inputs
+ STAKE_MINWEIGHT = 3, // only [30-90] days old inputs
+ STAKE_BELOWMIN = 4 // only less than 30 days old inputs
+};
/** A key pool entry */
class CKeyPool
bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
- uint64 GetStakeMintPower(const CKeyStore& keystore);
+ uint64 GetStakeMintPower(const CKeyStore& keystore, enum StakeWeightMode mode=STAKE_NORMAL);
bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew);
std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);