balance

package
v0.2.4-0...-2c2ceb1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ColorLength = 32

ColorLength represents the length of a Color (amount of bytes).

View Source
const Length = 8 + ColorLength

Length encodes the length of a marshaled Balance (the length of the color + 8 bytes for the balance).

Variables

View Source
var ColorNew = [32]byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}

ColorNew represents a placeholder Color that will be replaced with the transaction ID that created the funds. It is used to indicate that tokens should be "colored" in their Output (minting new colored coins).

Functions

This section is empty.

Types

type Balance

type Balance struct {
	// The numeric value of the balance.
	Value int64 `json:"value"`
	// The color of the balance.
	Color Color `json:"color"`
}

Balance represents a balance in the IOTA ledger. It consists out of a numeric value and a color.

func FromBytes

func FromBytes(bytes []byte) (result *Balance, consumedBytes int, err error)

FromBytes unmarshals a Balance from a sequence of bytes.

func New

func New(color Color, balance int64) (result *Balance)

New creates a new Balance with the given details.

func Parse

func Parse(marshalUtil *marshalutil.MarshalUtil) (*Balance, error)

Parse is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func (*Balance) Bytes

func (balance *Balance) Bytes() []byte

Bytes marshals the Balance into a sequence of bytes.

func (*Balance) String

func (balance *Balance) String() string

String creates a human readable string of the Balance.

type Color

type Color [ColorLength]byte

Color represents a marker that is associated to a token balance and that gives it a certain "meaning". The zero value represents "vanilla" IOTA tokens but it is also possible to define tokens that represent i.e. real world assets.

var ColorIOTA Color = [32]byte{}

ColorIOTA is the zero value of the Color and represents vanilla IOTA tokens.

func ColorFromBytes

func ColorFromBytes(bytes []byte) (result Color, consumedBytes int, err error)

ColorFromBytes unmarshals a Color from a sequence of bytes.

func (Color) Bytes

func (color Color) Bytes() []byte

Bytes marshals the Color into a sequence of bytes.

func (Color) String

func (color Color) String() string

String creates a human readable string of the Color.

Jump to

Keyboard shortcuts

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