According to all internet sources i have found, the hash/ID of a transaction is the result of the double_sha256 algorithm that takes all raw data of the transaction. I tried to calculate it in Python but get incorrect results in recent blocks. Here ist my test script for block #745778: https://www.blockchain.com/btc/block/745778
import hashlib
def d_SHA256(hex_string): return hashlib.sha256(hashlib.sha256(bytes.fromhex(hex_string)).digest()).digest()
# https://www.blockchain.com/btc/tx/aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856
coinbase_hash = 'aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856'
# https://blockchain.info/rawtx/aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856?format=hex
coinbase_data = '010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff640332610b2cfabe6d6ddcb8d8f2a2ddf5191d8191cfa7aa4fd9d85c529f2ce8ed4363c1a8942f14810b10000000f09f909f092f4632506f6f6c2f6500000000000000000000000000000000000000000000000000000000000000000000000500540000000000000004b1bbbb26000000001976a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac0000000000000000266a24aa21a9edd02fc86dcb2b66db1a5add17b3660e4046f50cde03199425f0944c7becb6546a0000000000000000266a2448617468e62698d5bdd57572ff76305ed48933e8b787a67df4319ade7d798df03c706edf00000000000000002c6a4c2952534b424c4f434b3a3c622bf845a23d0ee4927d14fe0455d8e30af6e68e7e3620aa1af6270044738b01200000000000000000000000000000000000000000000000000000000000000000730b053f'
tmp_coinbase_hash = d_SHA256(coinbase_data) # big-endian in bytes
my_coinbase_hash = tmp_coinbase_hash[::-1].hex() # litte-endian in hex
print('coinb_hash:', coinbase_hash)
print('my_cb_hash:', my_coinbase_hash)
coinb_hash: aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856
my_cb_hash: b33db7a32051e9cf9f73bcbcfb2f6f454c8baa9317738f2c8a703593dd01bf44
I don't get what I do wrong. Did the protocol change? Because it works for older blocks but not for recent mined blocks and I can't find any information on this issue.
You can get bonuses upto $100 FREE BONUS when you:
π° Install these recommended apps:
π² SocialGood - 100% Crypto Back on Everyday Shopping
π² xPortal - The DeFi For The Next Billion
π² CryptoTab Browser - Lightweight, fast, and ready to mine!
π° Register on these recommended exchanges:
π‘ Binanceπ‘ Bitfinexπ‘ Bitmartπ‘ Bittrexπ‘ Bitget
π‘ CoinExπ‘ Crypto.comπ‘ Gate.ioπ‘ Huobiπ‘ Kucoin.
Comments