pub(crate) fn parse_coinbase_height(
data: Vec<u8>,
) -> Result<(Height, CoinbaseData), SerializationError>Expand description
Split data into a block height and remaining miner-controlled coinbase data.
The height may consume 0..=5 bytes at the stat of the coinbase data.
The genesis block does not include an encoded coinbase height.
ยงConsensus
A coinbase transaction for a block at block height greater than 0 MUST have a script that, as its first item, encodes the block height
heightas follows. Forheightin the range {1..16}, the encoding is a single byte of value0x50+height. Otherwise, letheightBytesbe the signed little-endian representation ofheight, using the minimum nonzero number of bytes such that the most significant byte is <0x80. The length ofheightBytesMUST be in the range {1..5}. Then the encoding is the length ofheightBytesencoded as one byte, followed byheightBytesitself. This matches the encoding used by Bitcoin in the implementation of [BIP-34] (but the description here is to be considered normative).
https://zips.z.cash/protocol/protocol.pdf#txnconsensus https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki