I'm doing some experiments for finding coinbase height from freshly mined block which is received from ZMQ.
tx_coinbase = CTransaction.deserialize(x('010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff2303f90d1800fe6d8a0300fea00a04000963676d696e6572343208010000000000000000ffffffff02bc078402000000001976a914c11998cf0635b9ba940212af99447dfbdcfafe9688ac0000000000000000266a24aa21a9ed7a0ea91535f513cc527e1858a43800c2f6712d45404877f59f564a8eea88276f0120000000000000000000000000000000000000000000000000000000000000000000000000')) scriptSig = tx_coinbase.vin.scriptSig coinbase_script = CScript(scriptSig) for o in coinbase_script: h = int(b2lx(o), 16) logging.debug(h) break
It is really weird in my opinion. The question:
Is there better solution to parse
scriptSig and pull block height?
*It is also an exercise 2 from 'Programming Bitcoin' Chapter 9. But I really want to get block height using only raw block obtained from Core via zmq.