Expand description
Variable-length integer encoding (Bitcoin protocol)
Bitcoin uses a variable-length integer encoding where:
- Values < 0xfd: encoded as single byte
- Values < 0xffff: encoded as 0xfd + 2 bytes (little-endian)
- Values < 0xffffffff: encoded as 0xfe + 4 bytes (little-endian)
- Values >= 0xffffffff: encoded as 0xff + 8 bytes (little-endian)
Constants§
- MAX_
VARINT - Maximum value for a varint (2^64 - 1)
Functions§
- read_
varint - Read a variable-length integer from bytes
- varint_
size - Get the encoded size of a varint without writing it
- write_
varint - Write a variable-length integer to bytes