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
height
as follows. Forheight
in the range {1..16}, the encoding is a single byte of value0x50
+height
. Otherwise, letheightBytes
be the signed little-endian representation ofheight
, using the minimum nonzero number of bytes such that the most significant byte is <0x80
. The length ofheightBytes
MUST be in the range {1..5}. Then the encoding is the length ofheightBytes
encoded as one byte, followed byheightBytes
itself. 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