X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fwallet.cpp;h=fb12cb0c96589f0e1d2e113e08ba1d97a456cbd7;hp=f53f3444fd90f59f0359dfd5803b7698e60c22ca;hb=b0368da0e15b5506548da3462e14b038ca21ae69;hpb=580fa137c61abe24c56b440e62fa21657227e9a2 diff --git a/src/wallet.cpp b/src/wallet.cpp index f53f344..fb12cb0 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -386,7 +386,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock) printf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString().c_str()); else if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n])) { - printf("WalletUpdateSpent found spent coin %snvc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); + printf("WalletUpdateSpent found spent coin %snvc %s\n", FormatMoney(wtx.GetCredit(false)).c_str(), wtx.GetHash().ToString().c_str()); wtx.MarkSpent(txin.prevout.n); wtx.WriteToDisk(); NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED); @@ -697,7 +697,7 @@ void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, l if (GetBlocksToMaturity() > 0) nGeneratedImmature = pwallet->GetCredit(*this); else - nGeneratedMature = GetCredit(); + nGeneratedMature = GetCredit(false); return; } @@ -921,7 +921,7 @@ void CWallet::ReacceptWalletTransactions() } if (fUpdated) { - printf("ReacceptWalletTransactions found spent coin %snvc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); + printf("ReacceptWalletTransactions found spent coin %snvc %s\n", FormatMoney(wtx.GetCredit(false)).c_str(), wtx.GetHash().ToString().c_str()); wtx.MarkDirty(); wtx.WriteToDisk(); } @@ -1034,13 +1034,28 @@ int64 CWallet::GetBalance() const { const CWalletTx* pcoin = &(*it).second; if (pcoin->IsTrusted()) - nTotal += pcoin->GetAvailableCredit(); + nTotal += pcoin->GetAvailableCredit(false); } } return nTotal; } +void CWallet::GetBalance(int64 &nTotal, int64 &nWatchOnly) const +{ + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsTrusted()) { + nWatchOnly += pcoin->GetAvailableCredit(true); + nTotal += pcoin->GetAvailableCredit(false); + } + } + } +} + int64 CWallet::GetUnconfirmedBalance() const { int64 nTotal = 0; @@ -1050,7 +1065,7 @@ int64 CWallet::GetUnconfirmedBalance() const { const CWalletTx* pcoin = &(*it).second; if (!pcoin->IsFinal() || !pcoin->IsTrusted()) - nTotal += pcoin->GetAvailableCredit(); + nTotal += pcoin->GetAvailableCredit(false); } } return nTotal; @@ -2036,12 +2051,12 @@ void CWallet::PrintWallet(const CBlock& block) if (block.IsProofOfWork() && mapWallet.count(block.vtx[0].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()]; - printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(false)); } if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()]; - printf(" stake: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" stake: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(false)); } }