main: sort address index utxos by height
This commit is contained in:
committed by
Braydon Fuller
parent
d0483c9aa0
commit
1bd65a5c4b
@@ -431,8 +431,11 @@ bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint16
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool heightSort(std::pair<CAddressUnspentKey, CAddressUnspentValue> a,
|
||||
std::pair<CAddressUnspentKey, CAddressUnspentValue> b) {
|
||||
return a.second.blockHeight < b.second.blockHeight;
|
||||
}
|
||||
|
||||
UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
||||
@@ -468,6 +471,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort);
|
||||
|
||||
UniValue result(UniValue::VARR);
|
||||
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) {
|
||||
@@ -478,6 +483,7 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
||||
output.push_back(Pair("outputIndex", it->first.index));
|
||||
output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end())));
|
||||
output.push_back(Pair("satoshis", it->second.satoshis));
|
||||
output.push_back(Pair("height", it->second.blockHeight));
|
||||
result.push_back(output);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user