X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=bab881d270312f626000a55583decd32b4f5d109;hb=4a6759691d71bf2a7d2a0a9e4710f0887e66ab02;hp=7ad807e23006319b14debebc83fd7ae805be47eb;hpb=62b3df9c02e86432aa73f8b475900946bb348816;p=novacoin.git diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 7ad807e..bab881d 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -463,16 +463,14 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getreceivedbyaddress [minconf=1]\n" - "Returns the total amount received by in transactions with at least [minconf] confirmations."); + "getreceivedbyaddress [minconf=1]\n" + "Returns the total amount received by in transactions with at least [minconf] confirmations."); // Bitcoin address CBitcoinAddress address = CBitcoinAddress(params[0].get_str()); - CScript scriptPubKey; if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address"); - scriptPubKey.SetDestination(address.Get()); - if (!IsMine(*pwalletMain,scriptPubKey)) + if (!IsMine(*pwalletMain,address)) return 0.0; // Minimum confirmations @@ -480,24 +478,26 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) if (params.size() > 1) nMinDepth = params[1].get_int(); - // Tally int64_t nAmount = 0; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal()) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) + { + CBitcoinAddress addressRet; + if (!pwalletMain->ExtractAddress(txout.scriptPubKey, addressRet)) + continue; + if (addressRet == address) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; + } } return ValueFromAmount(nAmount); } - void GetAccountAddresses(string strAccount, set& setAddress) { BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& item, pwalletMain->mapAddressBook) @@ -1862,7 +1862,7 @@ Value resendtx(const Array& params, bool fHelp) "Re-send unconfirmed transactions.\n" ); - ResendWalletTransactions(); + ResendWalletTransactions(true); return Value::null; }