action

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EmptyAddress is the empty string
	EmptyAddress = ""
	// ExecutionDataGas represents the execution data gas per uint
	ExecutionDataGas = uint64(100)
	// ExecutionBaseIntrinsicGas represents the base intrinsic gas for execution
	ExecutionBaseIntrinsicGas = uint64(10000)
)
View Source
const (
	// TransferPayloadGas represents the transfer payload gas per uint
	TransferPayloadGas = uint64(100)
	// TransferBaseIntrinsicGas represents the base intrinsic gas for transfer
	TransferBaseIntrinsicGas = uint64(10000)
)
View Source
const (
	// CreateDepositIntrinsicGas represents the intrinsic gas for the deposit action
	CreateDepositIntrinsicGas = uint64(10000)
)
View Source
const PutBlockIntrinsicGas = uint64(1000)

PutBlockIntrinsicGas is the instrinsic gas for put block action.

View Source
const (
	// SettleDepositIntrinsicGas represents the intrinsic gas for the deposit action
	SettleDepositIntrinsicGas = uint64(10000)
)
View Source
const SignatureLength = 65

SignatureLength indicates the length of signature generated by SECP256K1 crypto library

View Source
const (
	// StartSubChainIntrinsicGas is the instrinsic gas for start sub chain action
	StartSubChainIntrinsicGas = uint64(1000)
)
View Source
const (
	// StopSubChainIntrinsicGas is the instrinsic gas for stop sub chain action
	StopSubChainIntrinsicGas = uint64(1000)
)
View Source
const (
	// VoteIntrinsicGas represents the intrinsic gas for vote
	VoteIntrinsicGas = uint64(10000)
)

Variables

View Source
var (
	// ErrAction indicates error for an action
	ErrAction = errors.New("action error")
	// ErrAddress indicates error of address
	ErrAddress = errors.New("address error")
)
View Source
var (
	// ErrActPool indicates the error of actpool
	ErrActPool = errors.New("invalid actpool")
	// ErrHitGasLimit is the error when hit gas limit
	ErrHitGasLimit = errors.New("Hit Gas Limit")
	// ErrInsufficientBalanceForGas is the error that the balance in executor account is lower than gas
	ErrInsufficientBalanceForGas = errors.New("Insufficient balance for gas")
	// ErrOutOfGas is the error when running out of gas
	ErrOutOfGas = errors.New("Out of gas")
	// ErrGasHigherThanLimit indicates the error of gas value
	ErrGasHigherThanLimit = errors.New("invalid gas for action")
	// ErrTransfer indicates the error of transfer
	ErrTransfer = errors.New("invalid transfer")
	// ErrNonce indicates the error of nonce
	ErrNonce = errors.New("invalid nonce")
	// ErrBalance indicates the error of balance
	ErrBalance = errors.New("invalid balance")
	// ErrVotee indicates the error of votee
	ErrVotee = errors.New("votee is not a candidate")
	// ErrHash indicates the error of action's hash
	ErrHash = errors.New("invalid hash")
)

Functions

func ClassifyActions

func ClassifyActions(actions []SealedEnvelope) ([]*Transfer, []*Vote, []*Execution)

ClassifyActions classfies actions

func Verify

func Verify(sealed SealedEnvelope) error

Verify verifies the action using sender's public key

Types

type AbstractAction

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

AbstractAction is an abstract implementation of Action interface

func (*AbstractAction) BasicActionSize

func (act *AbstractAction) BasicActionSize() uint32

BasicActionSize returns the basic size of action

func (*AbstractAction) DstAddr

func (act *AbstractAction) DstAddr() string

DstAddr returns the destination address

func (*AbstractAction) GasLimit

func (act *AbstractAction) GasLimit() uint64

GasLimit returns the gas limit

func (*AbstractAction) GasPrice

func (act *AbstractAction) GasPrice() *big.Int

GasPrice returns the gas price

func (*AbstractAction) Hash

func (act *AbstractAction) Hash() hash.Hash32B

Hash returns the hash value of referred SealedActionEnvelope hash.

func (*AbstractAction) Nonce

func (act *AbstractAction) Nonce() uint64

Nonce returns the nonce

func (*AbstractAction) SetEnvelopeContext

func (act *AbstractAction) SetEnvelopeContext(selp SealedEnvelope)

SetEnvelopeContext sets the SealedEnvelope context to action context.

func (*AbstractAction) SrcAddr

func (act *AbstractAction) SrcAddr() string

SrcAddr returns the source address

func (*AbstractAction) SrcPubkey

func (act *AbstractAction) SrcPubkey() keypair.PublicKey

SrcPubkey returns the source public key

func (*AbstractAction) Version

func (act *AbstractAction) Version() uint32

Version returns the version

type Action

type Action interface {
	SetEnvelopeContext(SealedEnvelope)
}

Action is the action can be Executed in protocols. The method is added to avoid mistakenly used empty interface as action.

type Builder

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

Builder is used to build an action.

func (*Builder) Build

func (b *Builder) Build() AbstractAction

Build builds a new action.

func (*Builder) SetDestinationAddress

func (b *Builder) SetDestinationAddress(addr string) *Builder

SetDestinationAddress sets action's destination address.

func (*Builder) SetGasLimit

func (b *Builder) SetGasLimit(l uint64) *Builder

SetGasLimit sets action's gas limit.

func (*Builder) SetGasPrice

func (b *Builder) SetGasPrice(p *big.Int) *Builder

SetGasPrice sets action's gas price.

func (*Builder) SetGasPriceByBytes

func (b *Builder) SetGasPriceByBytes(buf []byte) *Builder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*Builder) SetNonce

func (b *Builder) SetNonce(n uint64) *Builder

SetNonce sets action's nonce.

func (*Builder) SetSourceAddress

func (b *Builder) SetSourceAddress(addr string) *Builder

SetSourceAddress sets action's source address.

func (*Builder) SetSourcePublicKey

func (b *Builder) SetSourcePublicKey(key keypair.PublicKey) *Builder

SetSourcePublicKey sets action's source's public key.

func (*Builder) SetVersion

func (b *Builder) SetVersion(v uint32) *Builder

SetVersion sets action's version.

type CreateDeposit

type CreateDeposit struct {
	AbstractAction
	// contains filtered or unexported fields
}

CreateDeposit represents the action to deposit the token from main-chain to sub-chain. The recipient address must be a sub-chain address, but it doesn't need to be owned by the sender.

func NewCreateDeposit

func NewCreateDeposit(
	nonce uint64,
	chainID uint32,
	amount *big.Int,
	sender string,
	recipient string,
	gasLimit uint64,
	gasPrice *big.Int,
) *CreateDeposit

NewCreateDeposit instantiates a deposit creation to sub-chain action struct

func (*CreateDeposit) Amount

func (d *CreateDeposit) Amount() *big.Int

Amount returns the amount

func (*CreateDeposit) ByteStream

func (d *CreateDeposit) ByteStream() []byte

ByteStream returns a raw byte stream of the deposit action

func (*CreateDeposit) ChainID

func (d *CreateDeposit) ChainID() uint32

ChainID returns chain ID

func (*CreateDeposit) Cost

func (d *CreateDeposit) Cost() (*big.Int, error)

Cost returns the total cost of a create deposit

func (*CreateDeposit) IntrinsicGas

func (d *CreateDeposit) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a create deposit

func (*CreateDeposit) LoadProto

func (d *CreateDeposit) LoadProto(pbDpst *iproto.CreateDepositPb) error

LoadProto converts a protobuf's ActionPb to CreateDeposit

func (*CreateDeposit) Proto

func (d *CreateDeposit) Proto() *iproto.CreateDepositPb

Proto converts CreateDeposit to protobuf's ActionPb

func (*CreateDeposit) Recipient

func (d *CreateDeposit) Recipient() string

Recipient returns the recipient address. It's the wrapper of Action.DstAddr. The recipient should be an address on the sub-chain

func (*CreateDeposit) Sender

func (d *CreateDeposit) Sender() string

Sender returns the sender address. It's the wrapper of Action.SrcAddr

func (*CreateDeposit) SenderPublicKey

func (d *CreateDeposit) SenderPublicKey() keypair.PublicKey

SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey

type Envelope

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

Envelope defines an envelope wrapped on action with some envelope metadata.

func (*Envelope) Action

func (act *Envelope) Action() Action

Action returns the action payload.

func (*Envelope) ByteStream

func (act *Envelope) ByteStream() []byte

ByteStream returns encoded binary.

func (*Envelope) Cost

func (act *Envelope) Cost() (*big.Int, error)

Cost returns cost of actions

func (*Envelope) DstAddr

func (act *Envelope) DstAddr() string

DstAddr returns the destination address

func (*Envelope) GasLimit

func (act *Envelope) GasLimit() uint64

GasLimit returns the gas limit

func (*Envelope) GasPrice

func (act *Envelope) GasPrice() *big.Int

GasPrice returns the gas price

func (*Envelope) IntrinsicGas

func (act *Envelope) IntrinsicGas() (uint64, error)

IntrinsicGas returns intrinsic gas of action.

func (*Envelope) Nonce

func (act *Envelope) Nonce() uint64

Nonce returns the nonce

func (*Envelope) Version

func (act *Envelope) Version() uint32

Version returns the version

type EnvelopeBuilder

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

EnvelopeBuilder is the builder to build Envelope.

func (*EnvelopeBuilder) Build

func (b *EnvelopeBuilder) Build() Envelope

Build builds a new action.

func (*EnvelopeBuilder) SetAction

func (b *EnvelopeBuilder) SetAction(action actionPayload) *EnvelopeBuilder

SetAction sets the action payload for the Envelope Builder is building.

func (*EnvelopeBuilder) SetDestinationAddress

func (b *EnvelopeBuilder) SetDestinationAddress(addr string) *EnvelopeBuilder

SetDestinationAddress sets action's destination address.

func (*EnvelopeBuilder) SetGasLimit

func (b *EnvelopeBuilder) SetGasLimit(l uint64) *EnvelopeBuilder

SetGasLimit sets action's gas limit.

func (*EnvelopeBuilder) SetGasPrice

func (b *EnvelopeBuilder) SetGasPrice(p *big.Int) *EnvelopeBuilder

SetGasPrice sets action's gas price.

func (*EnvelopeBuilder) SetGasPriceByBytes

func (b *EnvelopeBuilder) SetGasPriceByBytes(buf []byte) *EnvelopeBuilder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*EnvelopeBuilder) SetNonce

func (b *EnvelopeBuilder) SetNonce(n uint64) *EnvelopeBuilder

SetNonce sets action's nonce.

func (*EnvelopeBuilder) SetVersion

func (b *EnvelopeBuilder) SetVersion(v uint32) *EnvelopeBuilder

SetVersion sets action's version.

type Execution

type Execution struct {
	AbstractAction
	// contains filtered or unexported fields
}

Execution defines the struct of account-based contract execution

func NewExecution

func NewExecution(executorAddress string, contractAddress string, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) (*Execution, error)

NewExecution returns a Execution instance

func (*Execution) Amount

func (ex *Execution) Amount() *big.Int

Amount returns the amount

func (*Execution) ByteStream

func (ex *Execution) ByteStream() []byte

ByteStream returns a raw byte stream of this Transfer

func (*Execution) Contract

func (ex *Execution) Contract() string

Contract returns a contract address

func (*Execution) Cost

func (ex *Execution) Cost() (*big.Int, error)

Cost returns the cost of an execution

func (*Execution) Data

func (ex *Execution) Data() []byte

Data returns the data bytes

func (*Execution) Executor

func (ex *Execution) Executor() string

Executor returns an executor address

func (*Execution) ExecutorPublicKey

func (ex *Execution) ExecutorPublicKey() keypair.PublicKey

ExecutorPublicKey returns the executor's public key

func (*Execution) IntrinsicGas

func (ex *Execution) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of an execution

func (*Execution) LoadProto

func (ex *Execution) LoadProto(pbAct *iproto.ExecutionPb) error

LoadProto converts a protobuf's ExecutionPb to Execution

func (*Execution) Proto

func (ex *Execution) Proto() *iproto.ExecutionPb

Proto converts Execution to protobuf's ExecutionPb

func (*Execution) TotalSize

func (ex *Execution) TotalSize() uint32

TotalSize returns the total size of this Execution

type Log

type Log struct {
	Address     string
	Topics      []hash.Hash32B
	Data        []byte
	BlockNumber uint64
	TxnHash     hash.Hash32B
	// TODO: in our case, BlockHash is actually txRoot, we need to revisit this field later
	BlockHash hash.Hash32B
	Index     uint
}

Log stores an evm contract event

func (*Log) ConvertFromLogPb

func (log *Log) ConvertFromLogPb(pbLog *iproto.LogPb)

ConvertFromLogPb converts a protobuf's LogPb to Log

func (*Log) ConvertToLogPb

func (log *Log) ConvertToLogPb() *iproto.LogPb

ConvertToLogPb converts a Log to protobuf's LogPb

func (*Log) Deserialize

func (log *Log) Deserialize(buf []byte) error

Deserialize parse the byte stream into Log

func (*Log) Serialize

func (log *Log) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Log

type PutBlock

type PutBlock struct {
	AbstractAction
	// contains filtered or unexported fields
}

PutBlock represents put a sub-chain block message.

func NewPutBlock

func NewPutBlock(
	nonce uint64,
	subChainAddress string,
	producerAddress string,
	height uint64,
	roots map[string]hash.Hash32B,
	gasLimit uint64,
	gasPrice *big.Int,
) *PutBlock

NewPutBlock instantiates a putting sub-chain block action struct.

func (*PutBlock) ByteStream

func (pb *PutBlock) ByteStream() []byte

ByteStream returns the byte representation of put block action.

func (*PutBlock) Cost

func (pb *PutBlock) Cost() (*big.Int, error)

Cost returns the total cost of a put block action

func (*PutBlock) Height

func (pb *PutBlock) Height() uint64

Height returns put block height.

func (*PutBlock) IntrinsicGas

func (pb *PutBlock) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a put block action

func (*PutBlock) LoadProto

func (pb *PutBlock) LoadProto(putBlockPb *iproto.PutBlockPb) error

LoadProto converts a proto message into put block action.

func (*PutBlock) ProducerAddress

func (pb *PutBlock) ProducerAddress() string

ProducerAddress return producer address.

func (*PutBlock) ProducerPublicKey

func (pb *PutBlock) ProducerPublicKey() keypair.PublicKey

ProducerPublicKey return producer public key.

func (*PutBlock) Proto

func (pb *PutBlock) Proto() *iproto.PutBlockPb

Proto converts put sub-chain block action into a proto message.

func (*PutBlock) Roots

func (pb *PutBlock) Roots() map[string]hash.Hash32B

Roots return merkel roots put in.

func (*PutBlock) SubChainAddress

func (pb *PutBlock) SubChainAddress() string

SubChainAddress returns sub chain address.

type Receipt

type Receipt struct {
	ReturnValue     []byte
	Status          uint64
	ActHash         hash.Hash32B
	GasConsumed     uint64
	ContractAddress string
	Logs            []*Log
}

Receipt represents the result of a contract

func (*Receipt) ConvertFromReceiptPb

func (receipt *Receipt) ConvertFromReceiptPb(pbReceipt *iproto.ReceiptPb)

ConvertFromReceiptPb converts a protobuf's ReceiptPb to Receipt

func (*Receipt) ConvertToReceiptPb

func (receipt *Receipt) ConvertToReceiptPb() *iproto.ReceiptPb

ConvertToReceiptPb converts a Receipt to protobuf's ReceiptPb

func (*Receipt) Deserialize

func (receipt *Receipt) Deserialize(buf []byte) error

Deserialize parse the byte stream into Receipt

func (*Receipt) Hash

func (receipt *Receipt) Hash() hash.Hash32B

Hash returns the hash of receipt

func (*Receipt) Serialize

func (receipt *Receipt) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Receipt

type SealedEnvelope

type SealedEnvelope struct {
	Envelope
	// contains filtered or unexported fields
}

SealedEnvelope is a signed action envelope.

func AssembleSealedEnvelope

func AssembleSealedEnvelope(act Envelope, addr string, pk keypair.PublicKey, sig []byte) SealedEnvelope

AssembleSealedEnvelope assembles a SealedEnvelope use Envelope, Sender Address and Signature. This method should be only used in tests.

func FakeSeal

func FakeSeal(act Envelope, addr string, pubk keypair.PublicKey) SealedEnvelope

FakeSeal creates a SealedActionEnvelope without signature. This method should be only used in tests.

func Sign

func Sign(act Envelope, addr string, sk keypair.PrivateKey) (SealedEnvelope, error)

Sign signs the action using sender's private key

func (*SealedEnvelope) Hash

func (sealed *SealedEnvelope) Hash() hash.Hash32B

Hash returns the hash value of SealedEnvelope.

func (*SealedEnvelope) LoadProto

func (sealed *SealedEnvelope) LoadProto(pbAct *iproto.ActionPb) error

LoadProto loads from proto scheme.

func (SealedEnvelope) Proto

func (sealed SealedEnvelope) Proto() *iproto.ActionPb

Proto converts it to it's proto scheme.

func (*SealedEnvelope) Signature

func (sealed *SealedEnvelope) Signature() []byte

Signature returns signature bytes

func (*SealedEnvelope) SrcAddr

func (sealed *SealedEnvelope) SrcAddr() string

SrcAddr returns the source address

func (*SealedEnvelope) SrcPubkey

func (sealed *SealedEnvelope) SrcPubkey() keypair.PublicKey

SrcPubkey returns the source public key

type SettleDeposit

type SettleDeposit struct {
	AbstractAction
	// contains filtered or unexported fields
}

SettleDeposit represents the action to settle a deposit on the sub-chain

func NewSettleDeposit

func NewSettleDeposit(
	nonce uint64,
	amount *big.Int,
	index uint64,
	sender string,
	recipient string,
	gasLimit uint64,
	gasPrice *big.Int,
) *SettleDeposit

NewSettleDeposit instantiates a deposit settlement to sub-chain action struct

func (*SettleDeposit) Amount

func (sd *SettleDeposit) Amount() *big.Int

Amount returns the amount

func (*SettleDeposit) ByteStream

func (sd *SettleDeposit) ByteStream() []byte

ByteStream returns a raw byte stream of the settle deposit action

func (*SettleDeposit) Cost

func (sd *SettleDeposit) Cost() (*big.Int, error)

Cost returns the total cost of a settle deposit

func (*SettleDeposit) Index

func (sd *SettleDeposit) Index() uint64

Index returns the index of the deposit on main-chain's sub-chain account

func (*SettleDeposit) IntrinsicGas

func (sd *SettleDeposit) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a settle deposit

func (*SettleDeposit) LoadProto

func (sd *SettleDeposit) LoadProto(pbDpst *iproto.SettleDepositPb) error

LoadProto converts a protobuf's ActionPb to SettleDeposit

func (*SettleDeposit) Proto

func (sd *SettleDeposit) Proto() *iproto.SettleDepositPb

Proto converts SettleDeposit to protobuf's ActionPb

func (*SettleDeposit) Recipient

func (sd *SettleDeposit) Recipient() string

Recipient returns the recipient address. It's the wrapper of Action.DstAddr. The recipient should be an address on the sub-chain

func (*SettleDeposit) Sender

func (sd *SettleDeposit) Sender() string

Sender returns the sender address. It's the wrapper of Action.SrcAddr

func (*SettleDeposit) SenderPublicKey

func (sd *SettleDeposit) SenderPublicKey() keypair.PublicKey

SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey

type StartSubChain

type StartSubChain struct {
	AbstractAction
	// contains filtered or unexported fields
}

StartSubChain represents start sub-chain message

func NewStartSubChain

func NewStartSubChain(
	nonce uint64,
	chainID uint32,
	ownerAddr string,
	securityDeposit *big.Int,
	operationDeposit *big.Int,
	startHeight uint64,
	parentHeightOffset uint64,
	gasLimit uint64,
	gasPrice *big.Int,
) *StartSubChain

NewStartSubChain instantiates a start sub-chain action struct

func (*StartSubChain) ByteStream

func (start *StartSubChain) ByteStream() []byte

ByteStream returns the byte representation of sub-chain action

func (*StartSubChain) ChainID

func (start *StartSubChain) ChainID() uint32

ChainID returns chain ID

func (*StartSubChain) Cost

func (start *StartSubChain) Cost() (*big.Int, error)

Cost returns the total cost of a start sub-chain action

func (*StartSubChain) IntrinsicGas

func (start *StartSubChain) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a start sub-chain action

func (*StartSubChain) LoadProto

func (start *StartSubChain) LoadProto(startPb *iproto.StartSubChainPb) error

LoadProto converts a proto message into start sub-chain action

func (*StartSubChain) OperationDeposit

func (start *StartSubChain) OperationDeposit() *big.Int

OperationDeposit returns operation deposit

func (*StartSubChain) OwnerAddress

func (start *StartSubChain) OwnerAddress() string

OwnerAddress returns the owner address, which is the wrapper of SrcAddr

func (*StartSubChain) OwnerPublicKey

func (start *StartSubChain) OwnerPublicKey() keypair.PublicKey

OwnerPublicKey returns the owner public key, which is the wrapper of SrcPubkey

func (*StartSubChain) ParentHeightOffset

func (start *StartSubChain) ParentHeightOffset() uint64

ParentHeightOffset returns parent height offset

func (*StartSubChain) Proto

func (start *StartSubChain) Proto() *iproto.StartSubChainPb

Proto converts start sub-chain action into a proto message

func (*StartSubChain) SecurityDeposit

func (start *StartSubChain) SecurityDeposit() *big.Int

SecurityDeposit returns security deposit

func (*StartSubChain) StartHeight

func (start *StartSubChain) StartHeight() uint64

StartHeight returns start height

type StopSubChain

type StopSubChain struct {
	AbstractAction
	// contains filtered or unexported fields
}

StopSubChain defines the action to stop sub chain

func NewStopSubChain

func NewStopSubChain(
	senderAddress string,
	nonce uint64,
	chainAddress string,
	stopHeight uint64,
	gasLimit uint64,
	gasPrice *big.Int,
) *StopSubChain

NewStopSubChain returns a StopSubChain instance

func (*StopSubChain) ByteStream

func (ssc *StopSubChain) ByteStream() []byte

ByteStream returns a raw byte stream of this instance

func (*StopSubChain) ChainAddress

func (ssc *StopSubChain) ChainAddress() string

ChainAddress returns the address of the sub chain

func (*StopSubChain) Cost

func (ssc *StopSubChain) Cost() (*big.Int, error)

Cost returns the total cost of a StopSubChain

func (*StopSubChain) IntrinsicGas

func (ssc *StopSubChain) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a StopSubChain

func (*StopSubChain) LoadProto

func (ssc *StopSubChain) LoadProto(pbSSC *iproto.StopSubChainPb) error

LoadProto converts a protobuf's ActionPb to StopSubChain

func (*StopSubChain) Proto

func (ssc *StopSubChain) Proto() *iproto.StopSubChainPb

Proto converts StopSubChain to protobuf's ActionPb

func (*StopSubChain) StopHeight

func (ssc *StopSubChain) StopHeight() uint64

StopHeight returns the height to stop the sub chain

func (*StopSubChain) TotalSize

func (ssc *StopSubChain) TotalSize() uint32

TotalSize returns the total size of this instance

type Transfer

type Transfer struct {
	AbstractAction
	// contains filtered or unexported fields
}

Transfer defines the struct of account-based transfer

func NewTransfer

func NewTransfer(
	nonce uint64,
	amount *big.Int,
	sender string,
	recipient string,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*Transfer, error)

NewTransfer returns a Transfer instance

func (*Transfer) Amount

func (tsf *Transfer) Amount() *big.Int

Amount returns the amount

func (*Transfer) ByteStream

func (tsf *Transfer) ByteStream() []byte

ByteStream returns a raw byte stream of this Transfer

func (*Transfer) Cost

func (tsf *Transfer) Cost() (*big.Int, error)

Cost returns the total cost of a transfer

func (*Transfer) IntrinsicGas

func (tsf *Transfer) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a transfer

func (*Transfer) IsContract

func (tsf *Transfer) IsContract() bool

IsContract returns true for contract action

func (*Transfer) LoadProto

func (tsf *Transfer) LoadProto(pbAct *iproto.TransferPb) error

LoadProto converts a protobuf's ActionPb to Transfer

func (*Transfer) Payload

func (tsf *Transfer) Payload() []byte

Payload returns the payload bytes

func (*Transfer) Proto

func (tsf *Transfer) Proto() *iproto.TransferPb

Proto converts Transfer to protobuf's ActionPb

func (*Transfer) Recipient

func (tsf *Transfer) Recipient() string

Recipient returns the recipient address. It's the wrapper of Action.DstAddr

func (*Transfer) Sender

func (tsf *Transfer) Sender() string

Sender returns the sender address. It's the wrapper of Action.SrcAddr

func (*Transfer) SenderPublicKey

func (tsf *Transfer) SenderPublicKey() keypair.PublicKey

SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey

func (*Transfer) TotalSize

func (tsf *Transfer) TotalSize() uint32

TotalSize returns the total size of this Transfer

type Vote

type Vote struct {
	AbstractAction
}

Vote defines the struct of account-based vote

func NewVote

func NewVote(nonce uint64, voterAddress string, voteeAddress string, gasLimit uint64, gasPrice *big.Int) (*Vote, error)

NewVote returns a Vote instance

func (*Vote) ByteStream

func (v *Vote) ByteStream() []byte

ByteStream returns a raw byte stream of this Transfer

func (*Vote) Cost

func (v *Vote) Cost() (*big.Int, error)

Cost returns the total cost of a vote

func (*Vote) IntrinsicGas

func (v *Vote) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a vote

func (*Vote) LoadProto

func (v *Vote) LoadProto(pbAct *iproto.VotePb) error

LoadProto converts a protobuf's ActionPb to Vote

func (*Vote) Proto

func (v *Vote) Proto() *iproto.VotePb

Proto converts Vote to protobuf's ActionPb

func (*Vote) TotalSize

func (v *Vote) TotalSize() uint32

TotalSize returns the total size of this Vote

func (*Vote) Votee

func (v *Vote) Votee() string

Votee returns the votee's address

func (*Vote) Voter

func (v *Vote) Voter() string

Voter returns the voter's address

func (*Vote) VoterPublicKey

func (v *Vote) VoterPublicKey() keypair.PublicKey

VoterPublicKey returns the voter's public key

Jump to

Keyboard shortcuts

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