On the implementation, TX_COUNT is written on the result buffer directly:
let mut tx_count = 0;
for transaction in transactions.into_iter() {
...
tx_count += 1;
}
data[0] = tx_count as u8;
But, LEN(tx) bits are inverted before they are written to the buffer:
let len_bytes = transaction.encode_length();
data.push(len_bytes.0);
data.push(len_bytes.1);
pub fn encode_length(&self) -> (u8, u8) {
let len = self.data.len() as u16;
let num = (len as u16).reverse_bits();
(((num >> 8) & 0xFF) as u8, (num & 0xFF) as u8)
}
Block serialization is specfied as the following:
On the implementation,
TX_COUNT
is written on the result buffer directly:But,
LEN(tx)
bits are inverted before they are written to the buffer: