void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
int64& nSent, int64& nFee) const
{
- nReceived = nSent = nFee = 0;
+ nGenerated = nReceived = nSent = nFee = 0;
int64 allGeneratedImmature, allGeneratedMature, allFee;
+ allGeneratedImmature = allGeneratedMature = allFee = 0;
string strSentAccount;
list<pair<CTxDestination, int64> > listReceived;
list<pair<CTxDestination, int64> > listSent;
if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
continue;
+ if(pcoin->IsCoinStake() && 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 > 0)
vCoins.push_back(COutput(pcoin, i, pcoin->GetDepthInMainChain()));
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;
+
+ CBigNum bnCentSecond = CBigNum(pcoin.first->vout[pcoin.second].nValue) * (GetTime()-pcoin.first->nTime) / CENT;
+ CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60);
+
+
+ nCoinAge += bnCoinDay.getuint64();
+ }
+
+ if (fDebug && GetBoolArg("-printcoinage"))
+ printf("StakePower bnCoinDay=%"PRI64d"\n", nCoinAge);
+
+ return nCoinAge;
+}
+
// ppcoin: create coin stake transaction
bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew)
{
CTxDB txdb("r");
if (!txNew.GetCoinAge(txdb, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");
- nCredit += GetProofOfStakeReward(nCoinAge);
+ nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
}
int64 nMinFee = 0;
CWalletDB walletdb(strWalletFile);
walletdb.ErasePool(nIndex);
}
- printf("keypool keep %"PRI64d"\n", nIndex);
+ if(fDebug)
+ printf("keypool keep %"PRI64d"\n", nIndex);
}
void CWallet::ReturnKey(int64 nIndex)
LOCK(cs_wallet);
setKeyPool.insert(nIndex);
}
- printf("keypool return %"PRI64d"\n", nIndex);
+ if(fDebug)
+ printf("keypool return %"PRI64d"\n", nIndex);
}
bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse)