Documentation ¶
Overview ¶
Package bitcoin encodes and decodes numbers and strings using the Bitcoin varint format.
Index ¶
- Variables
- func ReadBytes(r io.Reader, maxSize int) ([]byte, error)
- func ReadString(r io.Reader, maxSize int) (string, error)
- func ReadVarint(r io.Reader) (uint64, error)
- func WriteBytes(w io.Writer, p []byte) (int, error)
- func WriteString(w io.Writer, s string) (int, error)
- func WriteVarint(w io.Writer, v uint64) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrSize = errors.New("bitcoin string too big")
ErrSize indicates the size of a string or []byte being read is greater than the limit given to ReadString or ReadBytes.
Functions ¶
func ReadBytes ¶
ReadBytes reads a variable length byte array. A byte array is encoded as a varint containing the length of the array followed by the bytes themselves. If the size of the data is greater than maxSize, ReadBytes will not read the payload and will return ErrSize.
func ReadString ¶
ReadString reads a variable length string from r and returns it as a Go string. A Bitcoin string is encoded as a varint containing the length of the string followed by the bytes that represent the string itself. If the size of the string is greater than maxSize, ReadString will not read the payload and will return ErrSize.
func ReadVarint ¶
ReadVarint reads a variable length integer in the Bitcoin varint format.
func WriteBytes ¶
WriteBytes writes p as a varint containing the number of bytes, followed by the bytes themselves. It returns the total number of bytes written.
func WriteString ¶
WriteString serializes s to w as a varint containing the length of the string followed by the bytes that represent the string itself. It returns the total number of bytes written.
Types ¶
This section is empty.