From 2e17ac83c65b65fe2037b8c8941c25e288905903 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 22 Dec 2011 15:51:44 -0500 Subject: Fix broken ExtractAddress (refactored, made callers check for addresses in keystore if they care) --- src/bitcoinrpc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/bitcoinrpc.cpp') diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index bed90d4f6c..c1e8ef7690 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -689,7 +689,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp) BOOST_FOREACH(const CTxOut& txout, wtx.vout) { CBitcoinAddress address; - if (ExtractAddress(txout.scriptPubKey, pwalletMain, address) && setAddress.count(address)) + if (ExtractAddress(txout.scriptPubKey, address) && pwalletMain->HaveKey(address) && setAddress.count(address)) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; } @@ -1033,6 +1033,7 @@ Value ListReceived(const Array& params, bool fByAccounts) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || !wtx.IsFinal()) continue; @@ -1043,7 +1044,7 @@ Value ListReceived(const Array& params, bool fByAccounts) BOOST_FOREACH(const CTxOut& txout, wtx.vout) { CBitcoinAddress address; - if (!ExtractAddress(txout.scriptPubKey, pwalletMain, address) || !address.IsValid()) + if (!ExtractAddress(txout.scriptPubKey, address) || !pwalletMain->HaveKey(address) || !address.IsValid()) continue; tallyitem& item = mapTally[address]; @@ -1142,6 +1143,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe string strSentAccount; list > listReceived; list > listSent; + wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount); bool fAllAccounts = (strAccount == string("*")); @@ -1682,7 +1684,7 @@ Value validateaddress(const Array& params, bool fHelp) std::vector addresses; txnouttype whichType; int nRequired; - ExtractAddresses(subscript, pwalletMain, whichType, addresses, nRequired); + ExtractAddresses(subscript, whichType, addresses, nRequired); ret.push_back(Pair("script", GetTxnOutputType(whichType))); Array a; BOOST_FOREACH(const CBitcoinAddress& addr, addresses) -- cgit v1.2.3