bitcoin

package
v0.0.0-...-59fa258 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2016 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package bitcoin encodes and decodes numbers and strings using the Bitcoin varint format.

Index

Constants

This section is empty.

Variables

View Source
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

func ReadBytes(r io.Reader, maxSize int) ([]byte, error)

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

func ReadString(r io.Reader, maxSize int) (string, error)

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

func ReadVarint(r io.Reader) (uint64, error)

ReadVarint reads a variable length integer in the Bitcoin varint format.

func WriteBytes

func WriteBytes(w io.Writer, p []byte) (int, error)

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

func WriteString(w io.Writer, s string) (int, error)

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.

func WriteVarint

func WriteVarint(w io.Writer, v uint64) (int, error)

WriteVarint serializes v to w in the Bitcoin varint format. It returns the number of bytes written.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL