From e70fafc0f90dcc2f2d55eb82be49e79cadd75d6f Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Wed, 17 Jul 2013 15:09:13 -0300 Subject: [PATCH] removing stuff --- src/main.cpp | 24 --------- src/main.h | 5 -- src/rpcwallet.cpp | 133 +++++++--------------------------------------- src/wallet.cpp | 75 -------------------------- 4 files changed, 18 insertions(+), 219 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 904ae21d..62e6b4a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -408,22 +408,6 @@ bool IsStandardTx(const CTransaction& tx, string& reason) return true; } -/** Amount of bitcoins spent by the transaction. - @return sum of all outputs (note: does not include fees) - */ -int64 GetValueOut(const CTransaction& tx) -{ - int64 nValueOut = 0; - /* [MF] - BOOST_FOREACH(const CTxOut& txout, tx.vout) - { - nValueOut += txout.nValue; - if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut)) - throw std::runtime_error("GetValueOut() : value out of range"); - } */ - return nValueOut; -} - // // Check transaction inputs, and make sure any // pay-to-script-hash transactions are evaluating IsStandard scripts @@ -1283,14 +1267,6 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) return true; } -/* [MF] -bool CScriptCheck::operator()() const { - const CScript &scriptSig = ptxTo->vin[nIn].scriptSig; - if (!VerifyScript(scriptSig, scriptPubKey, *ptxTo, nIn, nFlags, nHashType)) - return error("CScriptCheck() : %s VerifySignature failed", ptxTo->GetHash().ToString().c_str()); - return true; -} -*/ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) { diff --git a/src/main.h b/src/main.h index 01655931..5909276c 100644 --- a/src/main.h +++ b/src/main.h @@ -317,11 +317,6 @@ bool CheckTransaction(const CTransaction& tx, CValidationState& state); */ bool IsStandardTx(const CTransaction& tx, std::string& reason); -/** Amount of bitcoins spent by the transaction. - @return sum of all outputs (note: does not include fees) - */ -int64 GetValueOut(const CTransaction& tx); - /** Undo information for a CBlock */ class CBlockUndo { diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 401de7db..8c56f376 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -476,20 +476,7 @@ int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinD { int64 nBalance = 0; - // Tally wallet transactions - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - int64 nReceived, nSent, nFee; - wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee); - - if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) - nBalance += nReceived; - nBalance -= nSent + nFee; - } - - // Tally internal accounting entries - nBalance += walletdb.GetAccountCreditDebit(strAccount); + //if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) return nBalance; } @@ -516,37 +503,7 @@ Value getbalance(const Array& params, bool fHelp) if (params.size() > 1) nMinDepth = params[1].get_int(); - if (params[0].get_str() == "*") { - // Calculate total balance a different way from GetBalance() - // (GetBalance() sums up all unspent TxOuts) - // getbalance and getbalance '*' 0 should return the same number - int64 nBalance = 0; - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (!wtx.IsConfirmed()) - continue; - - int64 allFee; - string strSentAccount; - list > listReceived; - list > listSent; - wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount); - if (wtx.GetDepthInMainChain() >= nMinDepth) - { - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived) - nBalance += r.second; - } - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listSent) - nBalance -= r.second; - nBalance -= allFee; - } - return ValueFromAmount(nBalance); - } - - string strAccount = AccountFromValue(params[0]); - - int64 nBalance = GetAccountBalance(strAccount, nMinDepth); + int64 nBalance = 0; return ValueFromAmount(nBalance); } @@ -955,62 +912,27 @@ Value listreceivedbyaccount(const Array& params, bool fHelp) void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret) { - int64 nFee; - string strSentAccount; - list > listReceived; - list > listSent; - - wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); - bool fAllAccounts = (strAccount == string("*")); // Sent - if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) + //if ((fAllAccounts || strAccount == strSentAccount)) { - BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent) - { - Object entry; - entry.push_back(Pair("account", strSentAccount)); - entry.push_back(Pair("address", CBitcoinAddress(s.first).ToString())); - entry.push_back(Pair("category", "send")); - entry.push_back(Pair("amount", ValueFromAmount(-s.second))); - entry.push_back(Pair("fee", ValueFromAmount(-nFee))); - if (fLong) - WalletTxToJSON(wtx, entry); - ret.push_back(entry); - } + Object entry; + //entry.push_back(Pair("account", strSentAccount)); + //entry.push_back(Pair("address", CBitcoinAddress(s.first).ToString())); + if (fLong) + WalletTxToJSON(wtx, entry); + ret.push_back(entry); } - // Received - if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) + if (wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived) - { - string account; - if (pwalletMain->mapAddressBook.count(r.first)) - account = pwalletMain->mapAddressBook[r.first]; - if (fAllAccounts || (account == strAccount)) - { - Object entry; - entry.push_back(Pair("account", account)); - entry.push_back(Pair("address", CBitcoinAddress(r.first).ToString())); - if (wtx.IsSpamMessage()) - { - if (wtx.GetDepthInMainChain() < 1) - entry.push_back(Pair("category", "orphan")); - else if (wtx.GetBlocksToMaturity() > 0) - entry.push_back(Pair("category", "immature")); - else - entry.push_back(Pair("category", "generate")); - } - else - entry.push_back(Pair("category", "receive")); - entry.push_back(Pair("amount", ValueFromAmount(r.second))); - if (fLong) - WalletTxToJSON(wtx, entry); - ret.push_back(entry); - } - } + Object entry; + //entry.push_back(Pair("account", account)); + //entry.push_back(Pair("address", CBitcoinAddress(r.first).ToString())); + if (fLong) + WalletTxToJSON(wtx, entry); + ret.push_back(entry); } } @@ -1109,21 +1031,9 @@ Value listaccounts(const Array& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - int64 nFee; - string strSentAccount; - list > listReceived; - list > listSent; - wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); - mapAccountBalances[strSentAccount] -= nFee; - BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent) - mapAccountBalances[strSentAccount] -= s.second; + if (wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived) - if (pwalletMain->mapAddressBook.count(r.first)) - mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second; - else - mapAccountBalances[""] += r.second; } } @@ -1217,14 +1127,7 @@ Value gettransaction(const Array& params, bool fHelp) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); const CWalletTx& wtx = pwalletMain->mapWallet[hash]; - int64 nCredit = wtx.GetCredit(); - int64 nDebit = wtx.GetDebit(); - int64 nNet = nCredit - nDebit; - int64 nFee = (wtx.IsFromMe() ? GetValueOut(wtx) - nDebit : 0); - - entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); - if (wtx.IsFromMe()) - entry.push_back(Pair("fee", ValueFromAmount(nFee))); + //entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); WalletTxToJSON(wtx, entry); diff --git a/src/wallet.cpp b/src/wallet.cpp index e3ea06da..10fad746 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -662,81 +662,6 @@ int CWalletTx::GetRequestCount() const return nRequests; } -void CWalletTx::GetAmounts(list >& listReceived, - list >& listSent, int64& nFee, string& strSentAccount) const -{ - nFee = 0; - listReceived.clear(); - listSent.clear(); - strSentAccount = strFromAccount; - - // Compute fee: - int64 nDebit = GetDebit(); - if (nDebit > 0) // debit>0 means we signed/sent this transaction - { - int64 nValueOut = GetValueOut(*this); - nFee = nDebit - nValueOut; - } - - /* - // Sent/received. - BOOST_FOREACH(const CTxOut& txout, vout) - { - CTxDestination address; - vector vchPubKey; - if (!ExtractDestination(txout.scriptPubKey, address)) - { - printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n", - this->GetHash().ToString().c_str()); - } - - // Don't report 'change' txouts - if (nDebit > 0 && pwallet->IsChange(txout)) - continue; - - if (nDebit > 0) - listSent.push_back(make_pair(address, txout.nValue)); - - if (pwallet->IsMine(txout)) - listReceived.push_back(make_pair(address, txout.nValue)); - } -*/ -} - -void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nReceived, - int64& nSent, int64& nFee) const -{ - nReceived = nSent = nFee = 0; - - int64 allFee; - string strSentAccount; - list > listReceived; - list > listSent; - GetAmounts(listReceived, listSent, allFee, strSentAccount); - - if (strAccount == strSentAccount) - { - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& s, listSent) - nSent += s.second; - nFee = allFee; - } - { - LOCK(pwallet->cs_wallet); - BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived) - { - if (pwallet->mapAddressBook.count(r.first)) - { - map::const_iterator mi = pwallet->mapAddressBook.find(r.first); - if (mi != pwallet->mapAddressBook.end() && (*mi).second == strAccount) - nReceived += r.second; - } - else if (strAccount.empty()) - { - nReceived += r.second; - } - } - } -} void CWalletTx::AddSupportingTransactions() {