txs

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Account transactions
	TxTypeSend = byte(0x01)
	TxTypeCall = byte(0x02)
	TxTypeName = byte(0x03)

	// Validation transactions
	TxTypeBond   = byte(0x11)
	TxTypeUnbond = byte(0x12)
	TxTypeRebond = byte(0x13)

	// Admin transactions
	TxTypePermissions = byte(0x1f)
)

Types of Tx implementations

Variables

View Source
var (
	MinNameRegistrationPeriod uint64 = 5

	// cost for storing a name for a block is
	// CostPerBlock*CostPerByte*(len(data) + 32)
	NameByteCostMultiplier  uint64 = 1
	NameBlockCostMultiplier uint64 = 1

	MaxNameLength = 64
	MaxDataLength = 1 << 16
)
View Source
var (
	ErrTxInvalidAddress    = errors.New("error invalid address")
	ErrTxDuplicateAddress  = errors.New("error duplicate address")
	ErrTxInvalidAmount     = errors.New("error invalid amount")
	ErrTxInsufficientFunds = errors.New("error insufficient funds")
	ErrTxUnknownPubKey     = errors.New("error unknown pubkey")
	ErrTxInvalidPubKey     = errors.New("error invalid pubkey")
	ErrTxInvalidSignature  = errors.New("error invalid signature")
)

Functions

func NameBaseCost

func NameBaseCost(name, data string) uint64

base cost is "effective" number of bytes

func NameCostPerBlock

func NameCostPerBlock(baseCost uint64) uint64

func NewGoWireCodec added in v0.18.0

func NewGoWireCodec() *goWireCodec

func TxHash

func TxHash(chainID string, tx Tx) []byte

Types

type BondTx

type BondTx struct {
	PubKey    acm.PublicKey
	Signature acm.Signature
	Inputs    []*TxInput
	UnbondTo  []*TxOutput
	// contains filtered or unexported fields
}

func NewBondTx

func NewBondTx(pubkey acm.PublicKey) (*BondTx, error)

func (*BondTx) AddInput

func (tx *BondTx) AddInput(st state.AccountGetter, pubkey acm.PublicKey, amt uint64) error

func (*BondTx) AddInputWithSequence added in v0.18.0

func (tx *BondTx) AddInputWithSequence(pubkey acm.PublicKey, amt uint64, sequence uint64) error

func (*BondTx) AddOutput

func (tx *BondTx) AddOutput(addr acm.Address, amt uint64) error

func (*BondTx) GetInputs added in v0.18.0

func (tx *BondTx) GetInputs() []TxInput

func (*BondTx) Hash added in v0.18.0

func (tx *BondTx) Hash(chainID string) []byte

func (*BondTx) Sign added in v0.18.0

func (tx *BondTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*BondTx) String

func (tx *BondTx) String() string

func (*BondTx) WriteSignBytes

func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type CallTx

type CallTx struct {
	Input *TxInput
	// Pointer since CallTx defines unset 'to' address as inducing account creation
	Address  *acm.Address
	GasLimit uint64
	Fee      uint64
	Data     []byte
	// contains filtered or unexported fields
}

func NewCallTx

func NewCallTx(st state.AccountGetter, from acm.PublicKey, to *acm.Address, data []byte,
	amt, gasLimit, fee uint64) (*CallTx, error)

func NewCallTxWithSequence added in v0.18.0

func NewCallTxWithSequence(from acm.PublicKey, to *acm.Address, data []byte,
	amt, gasLimit, fee, sequence uint64) *CallTx

func (*CallTx) GetInputs added in v0.18.0

func (tx *CallTx) GetInputs() []TxInput

func (*CallTx) Hash added in v0.18.0

func (tx *CallTx) Hash(chainID string) []byte

func (*CallTx) Sign

func (tx *CallTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*CallTx) String

func (tx *CallTx) String() string

func (*CallTx) WriteSignBytes

func (tx *CallTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type Decoder added in v0.18.0

type Decoder interface {
	DecodeTx(txBytes []byte) (Tx, error)
}

type Encoder added in v0.18.0

type Encoder interface {
	EncodeTx(tx Tx) ([]byte, error)
}

type ErrTxInvalidSequence

type ErrTxInvalidSequence struct {
	Got      uint64
	Expected uint64
}

func (ErrTxInvalidSequence) Error

func (e ErrTxInvalidSequence) Error() string

type ErrTxInvalidString

type ErrTxInvalidString struct {
	Msg string
}

func (ErrTxInvalidString) Error

func (e ErrTxInvalidString) Error() string

type NameTx

type NameTx struct {
	Input *TxInput
	Name  string
	Data  string
	Fee   uint64
	// contains filtered or unexported fields
}

func NewNameTx

func NewNameTx(st state.AccountGetter, from acm.PublicKey, name, data string, amt, fee uint64) (*NameTx, error)

func NewNameTxWithSequence added in v0.18.0

func NewNameTxWithSequence(from acm.PublicKey, name, data string, amt, fee, sequence uint64) *NameTx

func (*NameTx) GetInputs added in v0.18.0

func (tx *NameTx) GetInputs() []TxInput

func (*NameTx) Hash added in v0.18.0

func (tx *NameTx) Hash(chainID string) []byte

func (*NameTx) Sign

func (tx *NameTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*NameTx) String

func (tx *NameTx) String() string

func (*NameTx) ValidateStrings

func (tx *NameTx) ValidateStrings() error

func (*NameTx) WriteSignBytes

func (tx *NameTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type PermissionsTx

type PermissionsTx struct {
	Input    *TxInput
	PermArgs snatives.PermArgs
	// contains filtered or unexported fields
}

func NewPermissionsTx

func NewPermissionsTx(st state.AccountGetter, from acm.PublicKey, args snatives.PermArgs) (*PermissionsTx, error)

func NewPermissionsTxWithSequence added in v0.18.0

func NewPermissionsTxWithSequence(from acm.PublicKey, args snatives.PermArgs, sequence uint64) *PermissionsTx

func (*PermissionsTx) GetInputs added in v0.18.0

func (tx *PermissionsTx) GetInputs() []TxInput

func (*PermissionsTx) Hash added in v0.18.0

func (tx *PermissionsTx) Hash(chainID string) []byte

func (*PermissionsTx) Sign

func (tx *PermissionsTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*PermissionsTx) String

func (tx *PermissionsTx) String() string

func (*PermissionsTx) WriteSignBytes

func (tx *PermissionsTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type RebondTx

type RebondTx struct {
	Address   acm.Address
	Height    int
	Signature acm.Signature
	// contains filtered or unexported fields
}

func NewRebondTx

func NewRebondTx(addr acm.Address, height int) *RebondTx

func (*RebondTx) GetInputs added in v0.18.0

func (tx *RebondTx) GetInputs() []TxInput

func (*RebondTx) Hash added in v0.18.0

func (tx *RebondTx) Hash(chainID string) []byte

func (*RebondTx) Sign

func (tx *RebondTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*RebondTx) String

func (tx *RebondTx) String() string

func (*RebondTx) WriteSignBytes

func (tx *RebondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type Receipt

type Receipt struct {
	TxHash          []byte
	CreatesContract bool
	ContractAddress acm.Address
}

BroadcastTx or Transact

func GenerateReceipt

func GenerateReceipt(chainId string, tx Tx) Receipt

type SendTx

type SendTx struct {
	Inputs  []*TxInput
	Outputs []*TxOutput
	// contains filtered or unexported fields
}

func NewSendTx

func NewSendTx() *SendTx

func (*SendTx) AddInput

func (tx *SendTx) AddInput(st state.AccountGetter, pubkey acm.PublicKey, amt uint64) error

func (*SendTx) AddInputWithSequence added in v0.18.0

func (tx *SendTx) AddInputWithSequence(pubkey acm.PublicKey, amt uint64, sequence uint64) error

func (*SendTx) AddOutput

func (tx *SendTx) AddOutput(addr acm.Address, amt uint64) error

func (*SendTx) GetInputs added in v0.18.0

func (tx *SendTx) GetInputs() []TxInput

func (*SendTx) Hash added in v0.18.0

func (tx *SendTx) Hash(chainID string) []byte

func (*SendTx) Sign added in v0.18.0

func (tx *SendTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*SendTx) String

func (tx *SendTx) String() string

func (*SendTx) WriteSignBytes

func (tx *SendTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type Tx

type Tx interface {
	WriteSignBytes(chainID string, w io.Writer, n *int, err *error)
	String() string
	GetInputs() []TxInput
	Hash(chainID string) []byte
	Sign(chainID string, signingAccounts ...acm.AddressableSigner) error
}

TODO: replace with sum-type struct like ResultEvent

type TxInput

type TxInput struct {
	Address   acm.Address
	Amount    uint64
	Sequence  uint64
	Signature acm.Signature
	PublicKey acm.PublicKey
}

func (*TxInput) String

func (txIn *TxInput) String() string

func (*TxInput) ValidateBasic

func (txIn *TxInput) ValidateBasic() error

func (*TxInput) WriteSignBytes

func (txIn *TxInput) WriteSignBytes(w io.Writer, n *int, err *error)

type TxOutput

type TxOutput struct {
	Address acm.Address
	Amount  uint64
}

func (*TxOutput) String

func (txOut *TxOutput) String() string

func (*TxOutput) ValidateBasic

func (txOut *TxOutput) ValidateBasic() error

func (*TxOutput) WriteSignBytes

func (txOut *TxOutput) WriteSignBytes(w io.Writer, n *int, err *error)

type UnbondTx

type UnbondTx struct {
	Address   acm.Address
	Height    int
	Signature acm.Signature
	// contains filtered or unexported fields
}

func NewUnbondTx

func NewUnbondTx(addr acm.Address, height int) *UnbondTx

func (*UnbondTx) GetInputs added in v0.18.0

func (tx *UnbondTx) GetInputs() []TxInput

func (*UnbondTx) Hash added in v0.18.0

func (tx *UnbondTx) Hash(chainID string) []byte

func (*UnbondTx) Sign

func (tx *UnbondTx) Sign(chainID string, signingAccounts ...acm.AddressableSigner) error

func (*UnbondTx) String

func (tx *UnbondTx) String() string

func (*UnbondTx) WriteSignBytes

func (tx *UnbondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type Wrapper added in v0.18.0

type Wrapper struct {
	Tx `json:"unwrap"`
}

func Wrap added in v0.18.0

func Wrap(tx Tx) Wrapper

Wrap the Tx in a struct that allows for go-wire JSON serialisation

func (Wrapper) MarshalJSON added in v0.18.0

func (txw Wrapper) MarshalJSON() ([]byte, error)

func (*Wrapper) UnmarshalJSON added in v0.18.0

func (txw *Wrapper) UnmarshalJSON(data []byte) (err error)

func (*Wrapper) Unwrap added in v0.18.0

func (txw *Wrapper) Unwrap() Tx

Get the inner Tx that this Wrapper wraps

func (Wrapper) WriteSignBytes added in v0.18.0

func (txw Wrapper) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

A serialisation wrapper that is itself a Tx

Jump to

Keyboard shortcuts

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