[txpackages] add canonical way to get hash of package
Summary:
Partial backport of core#28970:
https://github.com/bitcoin/bitcoin/pull/28970/commits/092c978a42e8f4a02291b994713505ba8aac8b28
TxId sorting is correct, see D1527 (and comment in the test).
Since we use txid instead of wtxid + correct endianness in the comparison, the test is greatly simplified.
Note that we miss some backports that would allow to remove the type and version from the hasher/datastream, but there is no difference in behavior.
Depends on D16490.
Test Plan:
ninja check-bitcoin-txpackage_tests
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D16491