We use the same type for txids and wtxids, uint256
. In places where we want the ability to pass either one, we distinguish them using GenTxid
.
The (overloaded) CTxMemPool::exists()
function is defined as follows:
0bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); }
It always assumes that a uint256 is a txid, which is a footgunny interface. Querying by wtxid returns a false negative if the transaction has a witness. :bug:
Another approach would be to try both:
0bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}) || exists(GenTxid{false, txid}); }
But that’s slower and wrongfully placing the burden on the callee; the caller always knows whether the hash is a txid or a wtxid.