utxo

package
v0.0.0-...-da22cf9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = 2

	CodeInvalidAddress      sdk.CodeType = 101
	CodeInvalidOIndex       sdk.CodeType = 102
	CodeInvalidDenomination sdk.CodeType = 103
	CodeInvalidIOF          sdk.CodeType = 104
	CodeInvalidUTXO         sdk.CodeType = 105
	CodeInvalidTransaction  sdk.CodeType = 106
	CodeInvalidFee          sdk.CodeType = 107
)

Reserve errors 100 ~ 199

Variables

This section is empty.

Functions

func ErrInvalidAddress

func ErrInvalidAddress(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidDenom

func ErrInvalidDenom(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidFee

func ErrInvalidFee(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidIOF

func ErrInvalidIOF(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidOIndex

func ErrInvalidOIndex(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidTransaction

func ErrInvalidTransaction(codespace sdk.CodespaceType, msg string) sdk.Error

---------------------------------------- Error constructors

func ErrInvalidUTXO

func ErrInvalidUTXO(codespace sdk.CodespaceType, msg string) sdk.Error

func MakeCodec

func MakeCodec() *amino.Codec

func NewSpendHandler

func NewSpendHandler(um Mapper, nextPos NextPosition) sdk.Handler

Handler handles spends of arbitrary utxo implementation

func RegisterAmino

func RegisterAmino(cdc *amino.Codec)

func SetupMultiStore

func SetupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey)

Types

type FeeUpdater

type FeeUpdater func([]Output) sdk.Error

User-defined fee update function

type Input

type Input struct {
	Owner []byte
	Position
}

type Mapper

type Mapper interface {
	GetUTXO(ctx sdk.Context, addr []byte, position Position) UTXO
	ConstructKey(addr []byte, position Position) []byte
	ReceiveUTXO(sdk.Context, UTXO)
	ValidateUTXO(sdk.Context, UTXO) sdk.Error
	InvalidateUTXO(sdk.Context, UTXO)
	SpendUTXO(ctx sdk.Context, addr []byte, position Position) sdk.Error
}

Mapper stores and retrieves UTXO's from stores retrieved from the context.

func NewBaseMapper

func NewBaseMapper(contextKey sdk.StoreKey, cdc *amino.Codec) Mapper

type NextPosition

type NextPosition func(ctx sdk.Context, secondary bool) Position

Return the next position for handler to store newly created UTXOs Secondary is true if NextPosition is meant to return secondary output positions for a single multioutput transaction If false, NextPosition will increment position to accomadate outputs for a new transaction

type Output

type Output struct {
	Owner  []byte
	Denom  string
	Amount uint64
}

type Position

type Position interface {
	// Position is a uint slice
	Get() []sdk.Uint // get position int slice. Return nil if unset.

	// returns true if the position is valid, false otherwise
	IsValid() bool
}

Positions must be unqiue or a collision may result when using mapper.go

type ProtoPosition

type ProtoPosition func() Position

Create a prototype Position. Must return pointer to struct implementing Position

type SpendMsg

type SpendMsg interface {
	sdk.Msg

	Inputs() []Input
	Outputs() []Output
}

SpendMsg is an interface that wraps sdk.Msg with additional information for the UTXO spend handler.

type UTXO

type UTXO struct {
	Address  []byte
	Amount   uint64
	Denom    string
	Valid    bool
	Position Position
}

UTXO is a standard unspent transaction output When spent, it becomes invalid and spender keys are filled in

func NewUTXO

func NewUTXO(owner []byte, amount uint64, denom string, position Position) UTXO

func (UTXO) StoreKey

func (utxo UTXO) StoreKey(cdc *amino.Codec) []byte

Jump to

Keyboard shortcuts

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