Documentation ¶
Index ¶
- Constants
- Variables
- func ClassifyActions(actions []Action) ([]*Transfer, []*Vote, []*Execution)
- func Sign(act Action, sk keypair.PrivateKey) error
- func Verify(act Action) error
- type AbstractAction
- func (act *AbstractAction) BasicActionByteStream() []byte
- func (act *AbstractAction) BasicActionSize() uint32
- func (act *AbstractAction) DstAddr() string
- func (act *AbstractAction) GasLimit() uint64
- func (act *AbstractAction) GasPrice() *big.Int
- func (act *AbstractAction) Nonce() uint64
- func (act *AbstractAction) SetSignature(signature []byte)
- func (act *AbstractAction) SetSrcPubkey(srcPubkey keypair.PublicKey)
- func (act *AbstractAction) Signature() []byte
- func (act *AbstractAction) SrcAddr() string
- func (act *AbstractAction) SrcPubkey() keypair.PublicKey
- func (act *AbstractAction) Version() uint32
- type Action
- type Builder
- func (b *Builder) Build() AbstractAction
- func (b *Builder) SetDestinationAddress(addr string) *Builder
- func (b *Builder) SetGasLimit(l uint64) *Builder
- func (b *Builder) SetGasPrice(p *big.Int) *Builder
- func (b *Builder) SetNonce(n uint64) *Builder
- func (b *Builder) SetSourceAddress(addr string) *Builder
- func (b *Builder) SetSourcePublicKey(key keypair.PublicKey) *Builder
- func (b *Builder) SetVersion(v uint32) *Builder
- type CreateDeposit
- func (d *CreateDeposit) Amount() *big.Int
- func (d *CreateDeposit) ByteStream() []byte
- func (d *CreateDeposit) Cost() (*big.Int, error)
- func (d *CreateDeposit) Hash() hash.Hash32B
- func (d *CreateDeposit) IntrinsicGas() (uint64, error)
- func (d *CreateDeposit) LoadProto(pbAct *iproto.ActionPb)
- func (d *CreateDeposit) Proto() *iproto.ActionPb
- func (d *CreateDeposit) Recipient() string
- func (d *CreateDeposit) Sender() string
- func (d *CreateDeposit) SenderPublicKey() keypair.PublicKey
- func (d *CreateDeposit) SetSenderPublicKey(pubkey keypair.PublicKey)
- type Execution
- func (ex *Execution) Amount() *big.Int
- func (ex *Execution) ByteStream() []byte
- func (ex *Execution) Contract() string
- func (ex *Execution) Cost() (*big.Int, error)
- func (ex *Execution) Data() []byte
- func (ex *Execution) Deserialize(buf []byte) error
- func (ex *Execution) Executor() string
- func (ex *Execution) ExecutorPublicKey() keypair.PublicKey
- func (ex *Execution) Hash() hash.Hash32B
- func (ex *Execution) IntrinsicGas() (uint64, error)
- func (ex *Execution) LoadProto(pbAct *iproto.ActionPb)
- func (ex *Execution) Proto() *iproto.ActionPb
- func (ex *Execution) Serialize() ([]byte, error)
- func (ex *Execution) SetExecutorPublicKey(executorPubkey keypair.PublicKey)
- func (ex *Execution) ToJSON() (*explorer.Execution, error)
- func (ex *Execution) TotalSize() uint32
- type Log
- type PutBlock
- func (pb *PutBlock) ByteStream() []byte
- func (pb *PutBlock) Cost() (*big.Int, error)
- func (pb *PutBlock) Hash() hash.Hash32B
- func (pb *PutBlock) Height() uint64
- func (pb *PutBlock) IntrinsicGas() (uint64, error)
- func (pb *PutBlock) LoadProto(actPb *iproto.ActionPb)
- func (pb *PutBlock) ProducerAddress() string
- func (pb *PutBlock) ProducerPublicKey() keypair.PublicKey
- func (pb *PutBlock) Proto() *iproto.ActionPb
- func (pb *PutBlock) Roots() map[string]hash.Hash32B
- func (pb *PutBlock) SubChainAddress() string
- type Receipt
- type SecretProposal
- func (sp *SecretProposal) ByteStream() []byte
- func (sp *SecretProposal) Deserialize(buf []byte) error
- func (sp *SecretProposal) Hash() hash.Hash32B
- func (sp *SecretProposal) IntrinsicGas() (uint64, error)
- func (sp *SecretProposal) LoadProto(pbAct *iproto.ActionPb)
- func (sp *SecretProposal) Proto() *iproto.ActionPb
- func (sp *SecretProposal) Secret() []uint32
- func (sp *SecretProposal) Serialize() ([]byte, error)
- type SecretWitness
- func (sw *SecretWitness) ByteStream() []byte
- func (sw *SecretWitness) Deserialize(buf []byte) error
- func (sw *SecretWitness) Hash() hash.Hash32B
- func (sw *SecretWitness) IntrinsicGas() (uint64, error)
- func (sw *SecretWitness) LoadProto(pbAct *iproto.ActionPb)
- func (sw *SecretWitness) Proto() *iproto.ActionPb
- func (sw *SecretWitness) Serialize() ([]byte, error)
- func (sw *SecretWitness) Witness() [][]byte
- type SettleDeposit
- func (sd *SettleDeposit) Amount() *big.Int
- func (sd *SettleDeposit) ByteStream() []byte
- func (sd *SettleDeposit) Cost() (*big.Int, error)
- func (sd *SettleDeposit) Hash() hash.Hash32B
- func (sd *SettleDeposit) Index() uint64
- func (sd *SettleDeposit) IntrinsicGas() (uint64, error)
- func (sd *SettleDeposit) LoadProto(pbAct *iproto.ActionPb)
- func (sd *SettleDeposit) Proto() *iproto.ActionPb
- func (sd *SettleDeposit) Recipient() string
- func (sd *SettleDeposit) Sender() string
- func (sd *SettleDeposit) SenderPublicKey() keypair.PublicKey
- func (sd *SettleDeposit) SetSenderPublicKey(pubkey keypair.PublicKey)
- type StartSubChain
- func (start *StartSubChain) ByteStream() []byte
- func (start *StartSubChain) ChainID() uint32
- func (start *StartSubChain) Cost() (*big.Int, error)
- func (start *StartSubChain) Hash() hash.Hash32B
- func (start *StartSubChain) IntrinsicGas() (uint64, error)
- func (start *StartSubChain) LoadProto(actPb *iproto.ActionPb)
- func (start *StartSubChain) OperationDeposit() *big.Int
- func (start *StartSubChain) OwnerAddress() string
- func (start *StartSubChain) OwnerPublicKey() keypair.PublicKey
- func (start *StartSubChain) ParentHeightOffset() uint64
- func (start *StartSubChain) Proto() *iproto.ActionPb
- func (start *StartSubChain) SecurityDeposit() *big.Int
- func (start *StartSubChain) StartHeight() uint64
- type StopSubChain
- func (ssc *StopSubChain) ByteStream() []byte
- func (ssc *StopSubChain) ChainAddress() string
- func (ssc *StopSubChain) Cost() (*big.Int, error)
- func (ssc *StopSubChain) Deserialize(buf []byte) error
- func (ssc *StopSubChain) Hash() hash.Hash32B
- func (ssc *StopSubChain) IntrinsicGas() (uint64, error)
- func (ssc *StopSubChain) LoadProto(pbAct *iproto.ActionPb)
- func (ssc *StopSubChain) Proto() *iproto.ActionPb
- func (ssc *StopSubChain) Serialize() ([]byte, error)
- func (ssc *StopSubChain) StopHeight() uint64
- func (ssc *StopSubChain) TotalSize() uint32
- type Transfer
- func (tsf *Transfer) Amount() *big.Int
- func (tsf *Transfer) ByteStream() []byte
- func (tsf *Transfer) Cost() (*big.Int, error)
- func (tsf *Transfer) Deserialize(buf []byte) error
- func (tsf *Transfer) Hash() hash.Hash32B
- func (tsf *Transfer) IntrinsicGas() (uint64, error)
- func (tsf *Transfer) IsCoinbase() bool
- func (tsf *Transfer) IsContract() bool
- func (tsf *Transfer) LoadProto(pbAct *iproto.ActionPb)
- func (tsf *Transfer) Payload() []byte
- func (tsf *Transfer) Proto() *iproto.ActionPb
- func (tsf *Transfer) Recipient() string
- func (tsf *Transfer) Sender() string
- func (tsf *Transfer) SenderPublicKey() keypair.PublicKey
- func (tsf *Transfer) Serialize() ([]byte, error)
- func (tsf *Transfer) SetSenderPublicKey(pubkey keypair.PublicKey)
- func (tsf *Transfer) ToJSON() *explorer.Transfer
- func (tsf *Transfer) TotalSize() uint32
- type Vote
- func (v *Vote) ByteStream() []byte
- func (v *Vote) Cost() (*big.Int, error)
- func (v *Vote) Deserialize(buf []byte) error
- func (v *Vote) Hash() hash.Hash32B
- func (v *Vote) IntrinsicGas() (uint64, error)
- func (v *Vote) LoadProto(pbAct *iproto.ActionPb)
- func (v *Vote) Proto() *iproto.ActionPb
- func (v *Vote) Serialize() ([]byte, error)
- func (v *Vote) SetVoterPublicKey(voterPubkey keypair.PublicKey)
- func (v *Vote) ToJSON() (*explorer.Vote, error)
- func (v *Vote) TotalSize() uint32
- func (v *Vote) Votee() string
- func (v *Vote) Voter() string
- func (v *Vote) VoterPublicKey() keypair.PublicKey
Constants ¶
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) )
const ( // TransferPayloadGas represents the transfer payload gas per uint TransferPayloadGas = uint64(100) // TransferBaseIntrinsicGas represents the base intrinsic gas for transfer TransferBaseIntrinsicGas = uint64(10000) )
const ( // CreateDepositIntrinsicGas represents the intrinsic gas for the deposit action CreateDepositIntrinsicGas = uint64(10000) )
const PutBlockIntrinsicGas = uint64(1000)
PutBlockIntrinsicGas is the instrinsic gas for put block action.
const ( // SettleDepositIntrinsicGas represents the intrinsic gas for the deposit action SettleDepositIntrinsicGas = uint64(10000) )
const ( // StartSubChainIntrinsicGas is the instrinsic gas for start sub chain action StartSubChainIntrinsicGas = uint64(1000) )
const ( // StopSubChainIntrinsicGas is the instrinsic gas for stop sub chain action StopSubChainIntrinsicGas = uint64(1000) )
const ( // VoteIntrinsicGas represents the intrinsic gas for vote VoteIntrinsicGas = uint64(10000) )
Variables ¶
var ( // ErrAction indicates error for an action ErrAction = errors.New("action error") // ErrAddress indicates error of address ErrAddress = errors.New("address error") )
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 ¶
ClassifyActions classfies actions
Types ¶
type AbstractAction ¶
type AbstractAction struct {
// contains filtered or unexported fields
}
AbstractAction is an abstract implementation of Action interface
func (*AbstractAction) BasicActionByteStream ¶
func (act *AbstractAction) BasicActionByteStream() []byte
BasicActionByteStream returns the basic byte stream of action
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) SetSignature ¶
func (act *AbstractAction) SetSignature(signature []byte)
SetSignature sets the signature bytes
func (*AbstractAction) SetSrcPubkey ¶
func (act *AbstractAction) SetSrcPubkey(srcPubkey keypair.PublicKey)
SetSrcPubkey sets the source public key
func (*AbstractAction) Signature ¶
func (act *AbstractAction) Signature() []byte
Signature returns signature bytes
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 { Version() uint32 Nonce() uint64 SrcAddr() string SrcPubkey() keypair.PublicKey SetSrcPubkey(srcPubkey keypair.PublicKey) DstAddr() string GasLimit() uint64 GasPrice() *big.Int Signature() []byte SetSignature(signature []byte) ByteStream() []byte Hash() hash.Hash32B IntrinsicGas() (uint64, error) Cost() (*big.Int, error) Proto() *iproto.ActionPb LoadProto(*iproto.ActionPb) }
Action is the generic interface of all types of actions, and defines the common methods of them
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to build an action.
func (*Builder) SetDestinationAddress ¶
SetDestinationAddress sets
func (*Builder) SetSourceAddress ¶
SetSourceAddress sets
func (*Builder) SetSourcePublicKey ¶
SetSourcePublicKey sets
func (*Builder) SetVersion ¶
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, 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) ByteStream ¶
func (d *CreateDeposit) ByteStream() []byte
ByteStream returns a raw byte stream of the deposit action
func (*CreateDeposit) Cost ¶
func (d *CreateDeposit) Cost() (*big.Int, error)
Cost returns the total cost of a create deposit
func (*CreateDeposit) Hash ¶
func (d *CreateDeposit) Hash() hash.Hash32B
Hash returns the hash 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(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to CreateDeposit
func (*CreateDeposit) Proto ¶
func (d *CreateDeposit) Proto() *iproto.ActionPb
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
func (*CreateDeposit) SetSenderPublicKey ¶
func (d *CreateDeposit) SetSenderPublicKey(pubkey keypair.PublicKey)
SetSenderPublicKey sets the sender public key. It's the wrapper of Action.SetSrcPubkey
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 NewExecutionFromJSON ¶
NewExecutionFromJSON creates a new Execution from ExecutionJSON
func (*Execution) ByteStream ¶
ByteStream returns a raw byte stream of this Transfer
func (*Execution) Deserialize ¶
Deserialize parse the byte stream into Execution
func (*Execution) ExecutorPublicKey ¶
ExecutorPublicKey returns the executor's public key
func (*Execution) IntrinsicGas ¶
IntrinsicGas returns the intrinsic gas of an execution
func (*Execution) LoadProto ¶
func (ex *Execution) LoadProto(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to Execution
func (*Execution) Proto ¶
func (ex *Execution) Proto() *iproto.ActionPb
Proto converts Execution to protobuf's ActionPb
func (*Execution) SetExecutorPublicKey ¶
SetExecutorPublicKey sets the executor's public key
type Log ¶
type Log struct { Address string Topics []hash.Hash32B Data []byte BlockNumber uint64 TxnHash hash.Hash32B 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 ¶
Deserialize parse the byte stream into 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 ¶
ByteStream returns the byte representation of put block action.
func (*PutBlock) IntrinsicGas ¶
IntrinsicGas returns the intrinsic gas of a put block action
func (*PutBlock) LoadProto ¶
func (pb *PutBlock) LoadProto(actPb *iproto.ActionPb)
LoadProto converts a proto message into put block action.
func (*PutBlock) ProducerAddress ¶
ProducerAddress return producer address.
func (*PutBlock) ProducerPublicKey ¶
ProducerPublicKey return producer public key.
func (*PutBlock) Proto ¶
func (pb *PutBlock) Proto() *iproto.ActionPb
Proto converts put sub-chain block action into a proto message.
func (*PutBlock) SubChainAddress ¶
SubChainAddress returns sub chain address.
type Receipt ¶
type Receipt struct { ReturnValue []byte Status uint64 Hash 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 ¶
Deserialize parse the byte stream into Receipt
type SecretProposal ¶
type SecretProposal struct { AbstractAction // contains filtered or unexported fields }
SecretProposal defines the struct of DKG secret proposal
func NewSecretProposal ¶
func NewSecretProposal( nonce uint64, sender string, recipient string, secret []uint32, ) (*SecretProposal, error)
NewSecretProposal returns a SecretProposal instance
func (*SecretProposal) ByteStream ¶
func (sp *SecretProposal) ByteStream() []byte
ByteStream returns a raw byte stream of this SecretProposal
func (*SecretProposal) Deserialize ¶
func (sp *SecretProposal) Deserialize(buf []byte) error
Deserialize parses the byte stream into SecretProposal
func (*SecretProposal) Hash ¶
func (sp *SecretProposal) Hash() hash.Hash32B
Hash returns the hash of the SecretProposal
func (*SecretProposal) IntrinsicGas ¶
func (sp *SecretProposal) IntrinsicGas() (uint64, error)
IntrinsicGas returns the intrinsic gas of a secret proposal
func (*SecretProposal) LoadProto ¶
func (sp *SecretProposal) LoadProto(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to SecretProposal
func (*SecretProposal) Proto ¶
func (sp *SecretProposal) Proto() *iproto.ActionPb
Proto converts SecretProposal to protobuf's ActionPb
func (*SecretProposal) Secret ¶
func (sp *SecretProposal) Secret() []uint32
Secret returns the secret
func (*SecretProposal) Serialize ¶
func (sp *SecretProposal) Serialize() ([]byte, error)
Serialize returns a serialized byte stream for the SecretProposal
type SecretWitness ¶
type SecretWitness struct { AbstractAction // contains filtered or unexported fields }
SecretWitness defines the struct of DKG secret witness
func NewSecretWitness ¶
func NewSecretWitness( nonce uint64, sender string, witness [][]byte, ) (*SecretWitness, error)
NewSecretWitness returns a SecretWitness instance
func (*SecretWitness) ByteStream ¶
func (sw *SecretWitness) ByteStream() []byte
ByteStream returns a raw byte stream of this SecretWitness
func (*SecretWitness) Deserialize ¶
func (sw *SecretWitness) Deserialize(buf []byte) error
Deserialize parses the byte stream into SecretWitness
func (*SecretWitness) Hash ¶
func (sw *SecretWitness) Hash() hash.Hash32B
Hash returns the hash of the SecretWitness
func (*SecretWitness) IntrinsicGas ¶
func (sw *SecretWitness) IntrinsicGas() (uint64, error)
IntrinsicGas returns the intrinsic gas of a secret witness
func (*SecretWitness) LoadProto ¶
func (sw *SecretWitness) LoadProto(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to SecretWitness
func (*SecretWitness) Proto ¶
func (sw *SecretWitness) Proto() *iproto.ActionPb
Proto converts SecretWitness to protobuf's ActionPb
func (*SecretWitness) Serialize ¶
func (sw *SecretWitness) Serialize() ([]byte, error)
Serialize returns a serialized byte stream for the SecretWitness
func (*SecretWitness) Witness ¶
func (sw *SecretWitness) Witness() [][]byte
Witness returns the witness
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) 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) Hash ¶
func (sd *SettleDeposit) Hash() hash.Hash32B
Hash returns the hash of a 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(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to SettleDeposit
func (*SettleDeposit) Proto ¶
func (sd *SettleDeposit) Proto() *iproto.ActionPb
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
func (*SettleDeposit) SetSenderPublicKey ¶
func (sd *SettleDeposit) SetSenderPublicKey(pubkey keypair.PublicKey)
SetSenderPublicKey sets the sender public key. It's the wrapper of Action.SetSrcPubkey
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) Hash ¶
func (start *StartSubChain) Hash() hash.Hash32B
Hash returns the hash of starting sub-chain message
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(actPb *iproto.ActionPb)
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.ActionPb
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) Deserialize ¶
func (ssc *StopSubChain) Deserialize(buf []byte) error
Deserialize parse the byte stream into StopSubChain
func (*StopSubChain) Hash ¶
func (ssc *StopSubChain) Hash() hash.Hash32B
Hash returns the hash of the 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(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to StopSubChain
func (*StopSubChain) Proto ¶
func (ssc *StopSubChain) Proto() *iproto.ActionPb
Proto converts StopSubChain to protobuf's ActionPb
func (*StopSubChain) Serialize ¶
func (ssc *StopSubChain) Serialize() ([]byte, error)
Serialize returns a serialized byte stream for the StopSubChain
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 NewCoinBaseTransfer ¶
NewCoinBaseTransfer returns a coinbase 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 NewTransferFromJSON ¶
NewTransferFromJSON creates a new Transfer from TransferJSON
func (*Transfer) ByteStream ¶
ByteStream returns a raw byte stream of this Transfer
func (*Transfer) Deserialize ¶
Deserialize parse the byte stream into Transfer
func (*Transfer) IntrinsicGas ¶
IntrinsicGas returns the intrinsic gas of a transfer
func (*Transfer) IsCoinbase ¶
IsCoinbase returns a boolean value to indicate if a transfer is a coinbase one
func (*Transfer) IsContract ¶
IsContract returns true for contract action
func (*Transfer) LoadProto ¶
func (tsf *Transfer) LoadProto(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to Transfer
func (*Transfer) Proto ¶
func (tsf *Transfer) Proto() *iproto.ActionPb
Proto converts Transfer to protobuf's ActionPb
func (*Transfer) Recipient ¶
Recipient returns the recipient address. It's the wrapper of Action.DstAddr
func (*Transfer) SenderPublicKey ¶
SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey
func (*Transfer) SetSenderPublicKey ¶
SetSenderPublicKey sets the sender public key. It's the wrapper of Action.SetSrcPubkey
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 NewVoteFromJSON ¶
NewVoteFromJSON creates a new Vote from VoteJSON
func (*Vote) ByteStream ¶
ByteStream returns a raw byte stream of this Transfer
func (*Vote) Deserialize ¶
Deserialize parse the byte stream into Vote
func (*Vote) IntrinsicGas ¶
IntrinsicGas returns the intrinsic gas of a vote
func (*Vote) LoadProto ¶
func (v *Vote) LoadProto(pbAct *iproto.ActionPb)
LoadProto converts a protobuf's ActionPb to Vote
func (*Vote) Proto ¶
func (v *Vote) Proto() *iproto.ActionPb
Proto converts Vote to protobuf's ActionPb
func (*Vote) SetVoterPublicKey ¶
SetVoterPublicKey sets the voter's public key
func (*Vote) VoterPublicKey ¶
VoterPublicKey returns the voter's public key