From b1093efa833376a7883deb0cbcddd0aed364de84 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Mon, 20 Aug 2012 13:43:33 -0400 Subject: Change CWallet addressgrouping to use CTxDestination instead of strings. This is cleanup for the listaddressgroupings code. Also add some real help text. --- src/rpcrawtransaction.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/rpcrawtransaction.cpp') diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index d6fb30cac..2b6f4f7a4 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -140,7 +140,7 @@ Value listunspent(const Array& params, bool fHelp) { if (fHelp || params.size() > 3) throw runtime_error( - "listunspent [minconf=1] [maxconf=9999999] ['addr1','addr2',...]\n" + "listunspent [minconf=1] [maxconf=9999999] [\"address\",...]\n" "Returns array of unspent transaction outputs\n" "with between minconf and maxconf (inclusive) confirmations.\n" "Optionally filtered to only include txouts paid to specified addresses.\n" @@ -165,7 +165,7 @@ Value listunspent(const Array& params, bool fHelp) { CBitcoinAddress address(input.get_str()); if (!address.IsValid()) - throw JSONRPCError(-5, string("Invalid Bitcoin address:")+input.get_str()); + throw JSONRPCError(-5, string("Invalid Bitcoin address: ")+input.get_str()); if (setAddress.count(address)) throw JSONRPCError(-8, string("Invalid parameter, duplicated address: ")+input.get_str()); setAddress.insert(address); @@ -180,8 +180,15 @@ Value listunspent(const Array& params, bool fHelp) if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; - if (setAddress.size() && !setAddress.count(out.tx->GetAddressOfTxOut(out.i))) - continue; + if(setAddress.size()) + { + CTxDestination address; + if(!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + continue; + + if (!setAddress.count(address)) + continue; + } int64 nValue = out.tx->vout[out.i].nValue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; @@ -243,7 +250,7 @@ Value createrawtransaction(const Array& params, bool fHelp) { CBitcoinAddress address(s.name_); if (!address.IsValid()) - throw JSONRPCError(-5, string("Invalid Bitcoin address:")+s.name_); + throw JSONRPCError(-5, string("Invalid Bitcoin address: ")+s.name_); if (setAddress.count(address)) throw JSONRPCError(-8, string("Invalid parameter, duplicated address: ")+s.name_); -- cgit v1.2.3