obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
+ obj.push_back(Pair("stakepower", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet);
}
+// NovaCoin: get current stake generation power
+uint64 CWallet::GetStakeMintPower(const CKeyStore& keystore)
+{
+ LOCK2(cs_main, cs_wallet);
+
+ // Choose coins to use
+ int64 nBalance = GetBalance();
+ int64 nReserveBalance = 0;
+ uint64 nCoinAge = 0;
+
+ if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
+ {
+ error("CreateCoinStake : invalid reserve balance amount");
+ return 0;
+ }
+
+ if (nBalance <= nReserveBalance)
+ return 0;
+
+ set<pair<const CWalletTx*,unsigned int> > setCoins;
+ vector<const CWalletTx*> vwtxPrev;
+ int64 nValueIn = 0;
+ if (!SelectCoins(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn))
+ return 0;
+ if (setCoins.empty())
+ return 0;
+
+ BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
+ {
+ CTxDB txdb("r");
+ CTxIndex txindex;
+ if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex))
+ continue;
+
+ // Do not count input that is still too young
+ if (pcoin.first->nTime + nStakeMaxAge > GetTime())
+ continue;
+
+ uint64 unCoinAge;
+ pcoin.first->GetCoinAge(txdb, unCoinAge);
+ nCoinAge += unCoinAge;
+ }
+
+ return nCoinAge;
+}
+
// ppcoin: create coin stake transaction
bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew)
{
bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
+
+ uint64 GetStakeMintPower(const CKeyStore& keystore);
bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew);
+
std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);