Bitcoin variable-length integer encoding/decoding.
Summary
Functions
Decode a Bitcoin VarInt from binary, returning value and remaining bytes.
Encode an integer as a Bitcoin VarInt.
Functions
@spec decode(binary(), non_neg_integer() | nil) :: {:ok, {non_neg_integer(), binary()}} | {:error, String.t()}
Decode a Bitcoin VarInt from binary, returning value and remaining bytes.
Optionally pass max to reject values above a threshold (prevents
resource exhaustion when VarInt controls allocation sizes).
@spec encode(non_neg_integer()) :: binary()
Encode an integer as a Bitcoin VarInt.