rpc: update getaddresstxids for uniqueness

This commit is contained in:
Braydon Fuller
2016-03-09 19:45:08 -05:00
committed by Braydon Fuller
parent fcac6bcdc8
commit 2500d1d115
2 changed files with 36 additions and 2 deletions

View File

@@ -424,9 +424,15 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp)
if (!GetAddressIndex(hashBytes, type, addressIndex))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
std::set<std::string> txids;
UniValue result(UniValue::VARR);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
result.push_back(it->first.txhash.GetHex());
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
std::string txid = it->first.txhash.GetHex();
if (txids.insert(txid).second) {
result.push_back(txid);
}
}
return result;