xbase

package
v0.0.0-...-d2b8996 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: BSD-3-Clause Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBase58Checksum --
	// indicates that the checksum of a check-encoded string does not verify against the checksum
	ErrBase58Checksum = errors.New("checksum error")

	// ErrBase58InvalidFormat -- indicates that the check-encoded string has an invalid format
	ErrBase58InvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")
)

Functions

func Base58CheckDecode

func Base58CheckDecode(input string) (result []byte, version byte, err error)

Base58CheckDecode -- decodes a string that was encoded with CheckEncode and verifies the checksum

func Base58CheckEncode

func Base58CheckEncode(input []byte, version byte) string

Base58CheckEncode -- prepends a version byte and appends a four byte checksum

func Base58Decode

func Base58Decode(b string) []byte

Base58Decode -- decodes a modified base58 string to a byte slice

func Base58Encode

func Base58Encode(b []byte) string

Base58Encode -- encodes a byte slice to a modified base58 string

func Bech32Decode

func Bech32Decode(bech string) (string, []byte, error)

Bech32Decode -- decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum.

func Bech32Encode

func Bech32Encode(hrp string, data []byte) (string, error)

Bech32Encode -- encodes a byte slice into a bech32 string with the human-readable part hrb. Note that the bytes must each encode 5 bits (base32).

func NewIDFromString

func NewIDFromString(hashStr string) ([]byte, error)

NewIDFromString -- returns byte-reverse hash bytes.

func NewIDToString

func NewIDToString(hash []byte) string

NewIDToString -- returns byte-reverse hash hex.

func VarIntSerializeSize

func VarIntSerializeSize(val uint64) int

VarIntSerializeSize -- returns the number of bytes it would take to serialize val as a variable length integer.

func WitnessDecode

func WitnessDecode(addr string) (string, byte, []byte, error)

WitnessDecode -- decodes the segwit address to hrp, version and pubkeyscript.

func WitnessEncode

func WitnessEncode(hrp string, version byte, program []byte) (string, error)

WitnessEncode -- encodes to segwit address.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer -- a buffer writer/reader for bitcoin.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer -- creates a new buffer.

func NewBufferReader

func NewBufferReader(data []byte) *Buffer

NewBufferReader -- creates a new buffer with data initialize.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes -- returns all the datas in the buffer.

func (*Buffer) End

func (b *Buffer) End() bool

End -- returns whether the seek is end or not.

func (*Buffer) Len

func (b *Buffer) Len() int

Len -- returns the buffer length.

func (*Buffer) ReadBytes

func (b *Buffer) ReadBytes(l int) ([]byte, error)

ReadBytes -- read l-bytes from the buffer.

func (*Buffer) ReadU16

func (b *Buffer) ReadU16() (uint32, error)

ReadU16 -- read uint16 from the buffer which with the little-endian byteorder.

func (*Buffer) ReadU32

func (b *Buffer) ReadU32() (uint32, error)

ReadU32 -- read uint32 from the buffer which with the little-endian byteorder.

func (*Buffer) ReadU64

func (b *Buffer) ReadU64() (uint64, error)

ReadU64 -- read uint64 from the buffer which with the little-endian byteorder.

func (*Buffer) ReadU8

func (b *Buffer) ReadU8() (uint8, error)

ReadU8 -- read a byte from the buffer.

func (*Buffer) ReadVarBytes

func (b *Buffer) ReadVarBytes() ([]byte, error)

ReadVarBytes -- read variable length bytes from the buffer.

func (*Buffer) ReadVarInt

func (b *Buffer) ReadVarInt() (uint64, error)

ReadVarInt -- read variable int from the buffer.

func (*Buffer) ReadVarString

func (b *Buffer) ReadVarString() (string, error)

ReadVarString -- read variable length string from the buffer.

func (*Buffer) Remaining

func (b *Buffer) Remaining() []byte

Remaining -- returns the remaining datas in the buffer.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset -- reset the seek, length and the data.

func (*Buffer) Seek

func (b *Buffer) Seek() int

Seek -- returns the seek postion.

func (*Buffer) WriteBytes

func (b *Buffer) WriteBytes(v []byte)

WriteBytes -- write bytes to the buffer.

func (*Buffer) WriteU16

func (b *Buffer) WriteU16(v uint32)

WriteU16 -- write uint16 with little-endian to the buffer.

func (*Buffer) WriteU32

func (b *Buffer) WriteU32(v uint32)

WriteU32 -- write uint32 with little-endian to the buffer.

func (*Buffer) WriteU64

func (b *Buffer) WriteU64(v uint64)

WriteU64 -- write uint64 to the buffer with little-endian byteorder.

func (*Buffer) WriteU8

func (b *Buffer) WriteU8(v uint8)

WriteU8 -- write uint8(byte) to buffer.

func (*Buffer) WriteVarBytes

func (b *Buffer) WriteVarBytes(v []byte)

WriteVarBytes -- write variables length bytes to the buffer.

func (*Buffer) WriteVarInt

func (b *Buffer) WriteVarInt(v uint64)

WriteVarInt -- write variable int to the buffer.

func (*Buffer) WriteVarString

func (b *Buffer) WriteVarString(v string)

WriteVarString -- write variables length string to the buffer.

Jump to

Keyboard shortcuts

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