util

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSlice = errors.New("not slice")

ErrNotSlice is an error that is returned when the provided value is not a slice.

View Source
var ErrSliceValueCannotInterface = errors.New("slice value cannot interface")

ErrSliceValueCannotInterface is an error that is returned when the slice value cannot be converted to an interface.

View Source
var NotSupportedProtocol = errors.New("not supported protocol")

NotSupportedProtocol is an error that represents a not supported protocol.

Functions

func AddressScript

func AddressScript(address string, params *chaincfg.Params) ([]byte, error)

AddressScript is a function that converts a given address to a script. It first decodes the address, then generates a pay-to-address script from the decoded address. It returns the generated script and any error that occurred during the process.

func CheckMp4Codec

func CheckMp4Codec(path string) (bool, error)

CheckMp4Codec is a function that takes a file path as input and returns a boolean indicating whether the file's codec is h264 and an error. It first opens the file and gets the streams. It then checks each stream to see if it's a video stream and if the codec is h264. If the stream is not a video stream or the codec is not h264, it returns false. If all streams are video streams and the codec is h264, it returns true.

func ContentTypeForPath

func ContentTypeForPath(path string) (*constants.Media, error)

ContentTypeForPath is a function that takes a file path as input and returns the media type of the file and an error. It first checks the file extension and if it's mp4, it checks the codec of the file. If the codec is not h264, it returns an error. If the file extension is found in the list of supported media types, it returns the media type. If the file extension is not supported, it returns an error.

func DisableTls

func DisableTls(rpcConnect, port string) (bool, error)

func IsNullOutpoint

func IsNullOutpoint(point wire.OutPoint) bool

func IsNullOutpointString

func IsNullOutpointString(output string) (bool, error)

func IsUnBoundOutpointString

func IsUnBoundOutpointString(output string) (bool, error)

func NullOutpoint

func NullOutpoint() *wire.OutPoint

func NumberFormat

func NumberFormat(str string) string

func RegisterProtocol

func RegisterProtocol(p Protocol)

RegisterProtocol is a function that registers a protocol.

Types

type AcceptEncoding

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

func ParseAcceptEncoding

func ParseAcceptEncoding(acceptEncoding string) *AcceptEncoding

func (*AcceptEncoding) IsAccept

func (a *AcceptEncoding) IsAccept(encoding string) bool

type CBRC20

type CBRC20 struct {
	DefaultProtocol

	Protocol  string `json:"p"`
	Operation string `json:"op"`
	Tick      string `json:"tick"`

	Max      string `json:"max,omitempty"` // deploy
	Limit    string `json:"lim,omitempty"`
	Decimals string `json:"dec,omitempty"`
}

CBRC20 is a struct that represents a BRC20C protocol. It contains the protocol name, operation, tick, max, limit, decimals, tkId, amount, and to.

func (*CBRC20) Check

func (b *CBRC20) Check() error

Check is a method of the BRC20C struct. It checks the BRC20C protocol. It unmarshals the data into a new BRC20C struct and checks the protocol name, tick name, and operation. If the operation is "deploy", it checks the max, limit, and decimals. If the operation is "mint", it checks the tkId. If the operation is not supported, it returns an error.

func (*CBRC20) Clone

func (b *CBRC20) Clone() Protocol

Clone returns a new DefaultProtocol.

func (*CBRC20) Data

func (b *CBRC20) Data() []byte

func (*CBRC20) Len

func (b *CBRC20) Len() int

func (*CBRC20) Name

func (b *CBRC20) Name() string

Name is a method of the BRC20C struct. It returns the name of the BRC20C protocol.

type DefaultProtocol

type DefaultProtocol struct {
	Reader
	// contains filtered or unexported fields
}

DefaultProtocol is a struct that represents a default protocol. It embeds the Reader struct.

func (*DefaultProtocol) Check

func (d *DefaultProtocol) Check() error

Check is a method of the DefaultProtocol struct. It checks the DefaultProtocol. Currently, it does not perform any operations and always returns nil.

func (*DefaultProtocol) Clone

func (d *DefaultProtocol) Clone() Protocol

Clone returns a new DefaultProtocol.

func (*DefaultProtocol) Name

func (d *DefaultProtocol) Name() string

Name is a method of the DefaultProtocol struct. It returns the name of the DefaultProtocol.

type Peek

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

Peek is a struct that implements the Peekable interface. It contains a slice and an index for iteration.

func (*Peek) HasNext

func (p *Peek) HasNext() bool

HasNext checks if there are more elements in the slice.

func (*Peek) Next

func (p *Peek) Next() interface{}

Next returns the current element and moves the iterator to the next element.

func (*Peek) Peek

func (p *Peek) Peek() interface{}

Peek returns the current element in the slice without moving the iterator.

func (*Peek) Range

func (p *Peek) Range(fn func(idx int, v interface{}) error) error

Range iterates over the slice and calls the provided function for each element.

type Peekable

type Peekable interface {
	Peek() interface{}                           // Peek returns the current element in the slice without moving the iterator.
	Next() interface{}                           // Next returns the current element and moves the iterator to the next element.
	HasNext() bool                               // HasNext checks if there are more elements in the slice.
	Range(fn func(int, interface{}) error) error // Range iterates over the slice and calls the provided function for each element.
}

Peekable is an interface that defines methods for peeking and iterating over a slice.

func NewPeekable

func NewPeekable(slice interface{}) (Peekable, error)

NewPeekable creates a new Peekable from a slice or a pointer to a slice. It returns an error if the provided value is not a slice or if the slice values cannot be converted to an interface.

type Protocol

type Protocol interface {
	Name() string
	Check() error
	Reset([]byte)
	Len() int
	Clone() Protocol
	Chunks(size uint64) ([]byte, error)
}

Protocol is an interface that defines the methods that a protocol should implement. It includes methods for getting the name of the protocol, checking the protocol, getting the length of the protocol, and getting the chunks of the protocol.

func NewProtocolFromBytes

func NewProtocolFromBytes(body []byte) (Protocol, error)

NewProtocolFromBytes is a function that returns a new protocol from bytes.

type Reader

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

Reader is a struct that represents a reader. It contains the data to be read and a bytes.Reader to read the data.

func (*Reader) Chunks

func (r *Reader) Chunks(size uint64) ([]byte, error)

Chunks is a method of the Reader struct. It returns the chunks of the data of the Reader.

func (*Reader) Data

func (r *Reader) Data() []byte

Data is a method of the Reader struct. It returns the data of the Reader.

func (*Reader) Len

func (r *Reader) Len() int

Len is a method of the Reader struct. It returns the length of the data of the Reader.

func (*Reader) Reset

func (r *Reader) Reset(d []byte)

Reset is a method of the Reader struct. It resets the data and the reader of the Reader.

Directories

Path Synopsis
Package txscript implements the bitcoin transaction script language.
Package txscript implements the bitcoin transaction script language.

Jump to

Keyboard shortcuts

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