X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=bab881d270312f626000a55583decd32b4f5d109;hb=4a6759691d71bf2a7d2a0a9e4710f0887e66ab02;hp=a0e6afc476400bd958198e245a01e10cee6b073a;hpb=fbd44e84d5841867d36d295d4f347fd5e55d293f;p=novacoin.git diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index a0e6afc..bab881d 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -329,20 +329,7 @@ Value sendtoaddress(const Array& params, bool fHelp) CBitcoinAddress address(strAddress); if (address.IsValid()) - { - if (!address.IsPair()) - scriptPubKey.SetDestination(address.Get()); - else - { - CMalleablePubKey mpk; - if (!mpk.setvch(address.GetData())) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address"); - - CPubKey R, pubKeyVariant; - mpk.GetVariant(R, pubKeyVariant); - scriptPubKey.SetDestination(R, pubKeyVariant); - } - } + scriptPubKey.SetAddress(address); else throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address"); @@ -476,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 @@ -493,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) @@ -721,20 +708,7 @@ Value sendfrom(const Array& params, bool fHelp) CBitcoinAddress address(strAddress); if (address.IsValid()) - { - if (!address.IsPair()) - scriptPubKey.SetDestination(address.Get()); - else - { - CMalleablePubKey mpk; - if (!mpk.setvch(address.GetData())) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address"); - - CPubKey R, pubKeyVariant; - mpk.GetVariant(R, pubKeyVariant); - scriptPubKey.SetDestination(R, pubKeyVariant); - } - } + scriptPubKey.SetAddress(address); else throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address"); @@ -800,12 +774,15 @@ Value sendmany(const Array& params, bool fHelp) if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid NovaCoin address: ")+s.name_); - if (setAddress.count(address)) - throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_); - setAddress.insert(address); + if (!address.IsPair()) + { + if (setAddress.count(address)) + throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_); + setAddress.insert(address); + } CScript scriptPubKey; - scriptPubKey.SetDestination(address.Get()); + scriptPubKey.SetAddress(address); int64_t nAmount = AmountFromValue(s.value_); if (nAmount < nMinimumInputValue) @@ -1885,7 +1862,7 @@ Value resendtx(const Array& params, bool fHelp) "Re-send unconfirmed transactions.\n" ); - ResendWalletTransactions(); + ResendWalletTransactions(true); return Value::null; }