Broken out from #28122
BIP352 requires the smallest output lexicographically, which is my primary motivation for adding this as the default way of compare COutPoint
s (e.g. https://github.com/bitcoin/bitcoin/blob/5b06ccf1dc63f56dbc35368a37b9a72af671f15f/src/common/bip352.cpp#L149)
Outside of needing this for #28122 , I think it makes more sense to compare COutPoints
by their serialization for any use case that needs ordering since the serialization is what appears in the final transaction. I also didn’t see any existing places in the code where we order outpoints, so this change doesn’t conflict with any current use cases that I can see. If there is a need to order inputs by their vout
field (e.g. for an RPC output), something like
0std::sort(outpoints.begin(), outpoints.end(), [](const COutPoint& a, const COutPoint& b) { return a.vout < b.vout; });
seems preferable, rather than first comparing a.hash < b.hash
.