types

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 21 Imported by: 0

README

CLONE from mondo/types

Documentation

Index

Constants

View Source
const (
	CodeType_OK uint32 = 0
	// General response codes, 0 ~ 99
	CodeType_InternalError uint32 = 1 // 内部错误
	CodeType_EncodingError uint32 = 2 // 编解码错误
	CodeType_UnsupportedTx uint32 = 3 // 不支持的tx类型
	CodeType_BadSignature  uint32 = 4 // 签名错误
	CodeType_BadArgument   uint32 = 5 // 参数错误
	CodeType_ExecuteTx     uint32 = 6 // tx执行错误
	CodeType_Deadline      uint32 = 7 // 交易过期

	CodeType_SenderNotExist    uint32 = 11 // 帐户不存在
	CodeType_BadNonce          uint32 = 12 // nonce错误
	CodeType_InsufficientFunds uint32 = 13 // 资金不足
	CodeType_ReceiverNotExist  uint32 = 14 // 帐户不存在

	// manage tx
	CodeType_ValidatorNotExist       uint32 = 20 // 节点不存在
	CodeType_ValidatorIsNotGenesis   uint32 = 21 // 不是创世节点
	CodeType_ValidatorPowerNotEnough uint32 = 22 // 投票权不足
	CodeType_ValidatorDoubleUpdate   uint32 = 23 // 节点并发更新
	CodeType_ValidatorChangeSelf     uint32 = 24 // 不能操作自己
	CodeType_ValidatorNotFound       uint32 = 25 // 没有该节点

	// evm tx
	CodeType_ContractExecuteErr    uint32 = 30 // 合约执行错误
	CodeType_ContractExecuteFailed uint32 = 31 // 合约执行失败

	// delegate tx
	CodeType_NodeNotExist       uint32 = 41 // 节点不存在
	CodeType_NodeNotRunFor      uint32 = 42 // 节点未参与竞选
	CodeType_Delegate_Limit     uint32 = 43 // 代理限制
	CodeType_InsufficientProfit uint32 = 44 // 收益不足
	CodeType_VoterNotExist      uint32 = 45 // 投票人不存在
)
View Source
const (
	API_V2_QUERY_ACCOUNT          = "/v2/account"
	API_V2_CONTRACT_QUERY_ACCOUNT = "/v2/contract/account"
	API_V2_CONTRACT_QUERY_LOGS    = "/v2/contract/logs"
	API_V2_CONTRACT_CALL          = "/v2/contract/call"
	API_V3_QUERY_NODE             = "/v3/node/account"
	API_V3_QUERY_NODES            = "/v3/node/accounts"
	API_V3_QUERY_NODEVOTERS       = "/v3/node/account/voters"
	API_V3_QUERY_VOTER            = "/v3/voter/account"
	API_V3_QUERY_DPOS_POOL        = "/v3/dpos/pool"
	API_V3_QUERY_DPOS_POOLLOG     = "/v3/dpos/poollog"
	API_V3_QUERY_DPOS_TCNLOG      = "/v3/dpos/tcnlog"
	API_V3_QUERY_DPOS_TINLOG      = "/v3/dpos/tinlog"
	API_V3_QUERY_DPOS_RANKLOG     = "/v3/dpos/ranklog"
)
View Source
const (
	NODE_OPTYPE_NULL = uint8(iota)
	NODE_OPTYPE_MORTGAGE
	NODE_OPTYPE_REEDEM
	NODE_OPTYPE_COLLECT
	NODE_OPTYPE_WITHDRAW
)
View Source
const (
	KEY_DPOSBeginHeight  = "DPOSBeginHeight"   // 从此高度开启DPOS机制 必须>1
	KEY_DPOSEachHeight   = "DPOSEachHeight"    // 每多少高度清算一次 10240
	KEY_DPOSMaxNodeNum   = "DPOSMaxNodeNum"    // 超级节点数量
	KEY_NodeWorkMortgage = "NodeWorkMortgage"  // 节点至少抵押该数字才会参与DPOS
	KEY_NodeMinMortgage  = "NodeMinMortgage"   // 节点最小单笔抵押金额
	KEY_NodeMinCollect   = "NodeMinCollect"    // 节点最小单笔收集收益金额
	KEY_UserMinMortgage  = "UserMinMortgage"   // 用户最小抵押金额
	KEY_UserMinCollect   = "UserMinCollect"    // 用户最小单笔收集收益金额
	KEY_UpgradeHeight    = "KEY_UpgradeHeight" // 升级高度
)
View Source
const (
	USER_OPTYPE_NULL = uint8(iota)
	USER_OPTYPE_MORTGAGE
	USER_OPTYPE_REEDEM
	USER_OPTYPE_COLLECT
)
View Source
const PubKeyLength = 33
View Source
const (
	TxGas = int64(21000) // tx gas
)

Variables

View Source
var (
	ZERO_ADDRESS   = ethcmn.Address{}
	ZERO_HASH      = ethcmn.Hash{}
	ZERO_PUBLICKEY = PublicKey{}
)
View Source
var (
	ErrUnsupportedTx           = errors.New("unsupported tx")
	ErrInvalidSignature        = errors.New("signature verify failed")
	ErrInvalidOperations       = errors.New("too little/much operations")
	ErrInvalidGasLimit         = errors.New("invalid gasLimit")
	ErrInvalidGasPrice         = errors.New("invalid gasPrice")
	ErrNotFoundSender          = errors.New("sender not exist")
	ErrNotFoundReceiver        = errors.New("receiver not exist")
	ErrInsufficientBalance     = errors.New("insufficient balance")
	ErrInsufficientPermissions = errors.New("insufficient permissions")
	ErrDeadline                = errors.New("tx deadline")
)
View Source
var (
	TxTagAppInit        = []byte{0, 0}     // 账户迁移,采用与batch相同的交易结构,但是不收取手续费 v4废弃
	TxTagTinInit        = []byte{0, 1}     // v3初始化TIN用户 v4废弃
	TxTagAppOLO         = []byte{1, 1}     // 原生交易 v1 - v3废弃
	TxTagAppEvm         = []byte{1, 2}     // 合约交易
	TxTagAppFee         = []byte{1, 3}     // 收取手续费 - v3废弃
	TxTagAppBatch       = []byte{1, 4}     // 批量交易
	TxTagNodeDelegate   = []byte{2, 1}     // 节点抵押赎回提现
	TxTagUserDelegate   = []byte{2, 2}     // 用户抵押赎回提现
	TxTagAppEvmMultisig = []byte{3, 2}     // EVM多签交易
	TxTagAppParams      = []byte{255, 0}   // 修改APP参数
	TxTagAppMgr         = []byte{255, 255} // 节点管理交易
)
View Source
var (
	// 竞选超级节点
	OpType_SetRunFor = uint8(1)
	// 更改投票权
	OpType_SetPower = uint8(2)
	// 转移genesis权限
	OpType_SetGenesis = uint8(3)
)
View Source
var DefaultConfig = Config{
	DPOSBeginHeight:  150000,
	DPOSEachHeight:   20480,
	DPOSMaxNodeNum:   13,
	NodeWorkMortgage: 50000,
	NodeMinMortgage:  10000 * 1e8,
	NodeMinCollect:   10 * 1e8,
	UserMinMortgage:  100 * 1e8,
	UserMinCollect:   10 * 1e8,
	UpgradeHeight:    0,
}

Functions

func PubkeyToAddress

func PubkeyToAddress(pub PublicKey) ethcmn.Address

func ValidAddress

func ValidAddress(s string) bool

func ValidPublicKey

func ValidPublicKey(s string) bool

Types

type ABCIValidator

type ABCIValidator struct {
	PubKey [32]byte
	Power  int64
}

type Address

type Address struct {
	ethcmn.Address
}

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

type AppHeader

type AppHeader struct {
	Height     *big.Int       // refresh by new block
	ClosedAt   time.Time      // ON abci beginBlock
	BlockHash  ethcmn.Hash    // fill on new block
	Validator  ethcmn.Address // refresh by new block
	StateRoot  ethcmn.Hash    // fill after statedb commit
	XStateRoot ethcmn.Hash    // fill after xstatedb commit
	TxCount    uint64         // fill when ready to save
	PrevHash   ethcmn.Hash    // global, just used to calculate header-hash
	MinePool   *MinePool
	Params     *Config
}

AppHeader ledger header for app

func (*AppHeader) Hash

func (h *AppHeader) Hash() []byte

Hash hash

func (*AppHeader) String

func (h *AppHeader) String() string

type BeanAccount

type BeanAccount struct {
	Address string `json:"address"` // 地址
	Balance string `json:"balance"` // 余额
	Nonce   uint64 `json:"nonce"`   // nonce
}

type BeanContract

type BeanContract struct {
	Address  string `json:"address"`  // 地址
	Balance  string `json:"balance"`  // 余额
	Nonce    uint64 `json:"nonce"`    // nonce
	Code     string `json:"code"`     // 合约代码
	Suicided bool   `json:"suicided"` // 合约是否已自杀
}

type BeanDPOSPool

type BeanDPOSPool struct {
	CurrentHeight int64 `json:"currentHeight"` // 当前高度
	LastHeight    int64 `json:"lastHeight"`    // 上一轮DPOS高度
	NextHeight    int64 `json:"nextHeight"`    // 下一轮DPOS高度
}

type BeanEvmCallResult

type BeanEvmCallResult = struct {
	Code    uint32 `json:"code"`    // 错误码
	Msg     string `json:"msg"`     // msg
	Ret     string `json:"ret"`     // 返回数据的hex编码
	GasUsed uint64 `json:"gasUsed"` // 消耗的gas
}

type BeanValidator

type BeanValidator struct {
	Address    string `json:"address"`    // 节点公钥
	Nonce      uint64 `json:"nonce"`      // nonce
	Power      uint64 `json:"power"`      // 投票权
	Genesis    bool   `json:"genesis"`    // 是否是创世节点
	RunFor     bool   `json:"runFor"`     // 参与竞选
	Balance    string `json:"balance"`    // 余额(累积收益)
	Profit     string `json:"-"`          // 本轮收益
	Mortgaged  string `json:"mortgaged"`  // 已抵押
	ToMortgage string `json:"toMortgage"` // 待抵押
	Redeem     bool   `json:"redeem"`     // 待赎回
	Voters     int    `json:"voters"`     // 投票人数
	Voted      string `json:"voted"`      // 选民贡献
}

func (*BeanValidator) ToPrettyJSON

func (v *BeanValidator) ToPrettyJSON() ([]byte, error)

type BeanVot

type BeanVot struct {
	Address string `json:"address"` // 选民地址
	Amount  string `json:"amount"`  // 投票金额
}

type BeanVoter

type BeanVoter struct {
	Address    string `json:"address"`    // 选民地址
	Balance    string `json:"balance"`    // 累积收益余额
	Validator  string `json:"validator"`  // 节点地址
	Mortgaged  string `json:"mortgaged"`  // 已抵押
	ToMortgage string `json:"toMortgage"` // 待抵押
	Burned     string `json:"burned"`     // 已燃烧
	Redeem     bool   `json:"redeem"`     // 赎回标志
}

type BeanVots

type BeanVots struct {
	Address string    `json:"address"` // 节点公钥
	Voted   string    `json:"voted"`   // 选民贡献
	Voters  []BeanVot `json:"voters"`  // 选民列表
}

func (*BeanVots) ToPrettyJSON

func (v *BeanVots) ToPrettyJSON() ([]byte, error)

type Config

type Config struct {
	DPOSBeginHeight  int64 // 从此高度开启DPOS机制 必须>1
	DPOSEachHeight   int64 // 每多少高度清算一次 10240
	DPOSMaxNodeNum   int   // 超级节点数量
	NodeWorkMortgage int64 // 节点至少抵押该数字才会参与DPOS
	NodeMinMortgage  int64 // 节点最小单笔抵押金额
	NodeMinCollect   int64 // 节点最小单笔收集收益金额
	UserMinMortgage  int64 // 用户最小抵押金额
	UserMinCollect   int64 // 用户最小单笔收集收益金额
	UpgradeHeight    int64 // 升级高度,如果不为0,在此高度的EndBlock会Panic等待升级
}

func (*Config) FromBytes

func (p *Config) FromBytes(bz []byte)

func (*Config) ToBytes

func (p *Config) ToBytes() []byte

type DPOSPoolLog

type DPOSPoolLog struct {
	Id       uint64    `db:"id" json:"id"`             // 数据库自增id
	Height   uint64    `db:"height" json:"height"`     // 去看高度
	Balance  string    `db:"balance" json:"balance"`   // 矿池余额
	Mined    string    `db:"mined" json:"mined"`       // 挖矿量
	Released string    `db:"released" json:"released"` // 实际释放量,实际释放量约等于挖矿量
	Total    string    `db:"total" json:"total"`       // 总股权
	BlockAt  time.Time `db:"blockat" json:"blockAt"`   // 区块时间
}

type DPOSQuery

type DPOSQuery struct {
	QueryBase
	Height  uint64
	Address ethcmn.Address
}

func (*DPOSQuery) FromBytes

func (q *DPOSQuery) FromBytes(bz []byte) error

func (*DPOSQuery) ToBytes

func (q *DPOSQuery) ToBytes() []byte

type DPOSRankLog

type DPOSRankLog struct {
	Id        uint64    `db:"id" json:"id"`               // 数据库自增id
	Height    uint64    `db:"height" json:"height"`       // 区块高度
	Address   string    `db:"address" json:"address"`     // 节点地址
	Mortgaged string    `db:"mortgaged" json:"mortgaged"` // 节点抵押量
	Voted     string    `db:"voted" json:"voted"`         // 用户投票量
	Voters    uint64    `db:"voters" json:"voters"`       // 投票用户数
	Total     string    `db:"total" json:"total"`         // 总股权
	Rank      uint32    `db:"rank" json:"rank"`           // 排名
	BlockAt   time.Time `db:"blockat" json:"blockAt"`     // 区块时间
}

type DPOSTcnLog

type DPOSTcnLog struct {
	Id        uint64    `db:"id" json:"id"`               // 数据库自增id
	Height    uint64    `db:"height" json:"height"`       // 区块高度
	Address   string    `db:"address" json:"address"`     // 节点地址
	Mortgaged string    `db:"mortgaged" json:"mortgaged"` // 节点抵押量
	Voted     string    `db:"voted" json:"voted"`         // 用户投票量
	Voters    uint64    `db:"voters" json:"voters"`       // 投票用户数
	Profit    string    `db:"profit" json:"profit"`       // 收益
	BlockAt   time.Time `db:"blockat" json:"blockAt"`     // 区块时间
}

type DPOSTinLog

type DPOSTinLog struct {
	Id        uint64    `db:"id" json:"id"`               // 数据库自增id
	Height    uint64    `db:"height" json:"height"`       // 区块高度
	Address   string    `db:"address" json:"address"`     // 用户地址
	Validator string    `db:"validator" json:"validator"` // 用户选举的节点地址
	Mortgaged string    `db:"mortgaged" json:"mortgaged"` // 用户抵押量
	Profit    string    `db:"profit" json:"profit"`       // 收益
	BlockAt   time.Time `db:"blockat" json:"blockAt"`     // 区块时间
}

type LastBlockInfo

type LastBlockInfo struct {
	Height           int64
	StateRoot        ethcmn.Hash
	XStateRoot       ethcmn.Hash
	AppHash          ethcmn.Hash
	PrevHash         ethcmn.Hash
	ValidatorUpdates []ABCIValidator
}

func (*LastBlockInfo) FromBytes

func (block *LastBlockInfo) FromBytes(bz []byte)

func (*LastBlockInfo) ToBytes

func (block *LastBlockInfo) ToBytes() []byte

type MinePool

type MinePool struct {
	GenesisTime     time.Time // 创世时间
	LastBlockHeight int64     // 上次出矿区块高度
	LastBlockTime   time.Time // 上次出矿区块时间
}

func (*MinePool) FromBytes

func (pool *MinePool) FromBytes(bz []byte)

func (*MinePool) ToBytes

func (pool *MinePool) ToBytes() []byte

type MultisigEvmTx

type MultisigEvmTx struct {
	Deadline  uint64         // 有效期 截止时间 秒
	GasLimit  uint64         // gas限额
	GasPrice  *big.Int       // gas价格
	From      ethcmn.Address // 多签账户地址
	Nonce     uint64         // 多签账户nonce
	To        ethcmn.Address // 交易接收方地址
	Value     *big.Int       // 交易金额
	Load      []byte         // 合约交易负荷
	Memo      []byte         // 备注信息
	Signature Signature      // 签名信息
	// contains filtered or unexported fields
}

func NewMultisigEvmTx

func NewMultisigEvmTx(k int, pks []PublicKey) *MultisigEvmTx

func (*MultisigEvmTx) AddSign

func (tx *MultisigEvmTx) AddSign(signature string) error

func (*MultisigEvmTx) Cost

func (tx *MultisigEvmTx) Cost() *big.Int

func (*MultisigEvmTx) FromBytes

func (tx *MultisigEvmTx) FromBytes(bs []byte) error

func (*MultisigEvmTx) Hash

func (tx *MultisigEvmTx) Hash() ethcmn.Hash

func (*MultisigEvmTx) SigHash

func (tx *MultisigEvmTx) SigHash() ethcmn.Hash

func (*MultisigEvmTx) Sign

func (tx *MultisigEvmTx) Sign(privkey string) error

func (MultisigEvmTx) Signer

func (tx MultisigEvmTx) Signer() []ethcmn.Address

func (*MultisigEvmTx) ToBytes

func (tx *MultisigEvmTx) ToBytes() []byte

func (*MultisigEvmTx) Verify

func (tx *MultisigEvmTx) Verify() bool

type Multisignature

type Multisignature struct {
	BitArray *bitarray.CompactBitArray
	Sigs     [][]byte
}

Multisignature is used to represent the signature object used in the multisigs. Sigs is a list of signatures, sorted by corresponding index.

func NewMultisig

func NewMultisig(n int) *Multisignature

NewMultisig returns a new Multisignature of size n.

func (*Multisignature) AddSignature

func (mSig *Multisignature) AddSignature(sig []byte, index int)

AddSignature adds a signature to the multisig, at the corresponding index. If the signature already exists, replace it.

func (*Multisignature) AddSignatureFromPubKey

func (mSig *Multisignature) AddSignatureFromPubKey(sig []byte, pubkey PublicKey, keys []PublicKey) error

AddSignatureFromPubKey adds a signature to the multisig, at the index in keys corresponding to the provided pubkey.

func (*Multisignature) Marshal

func (mSig *Multisignature) Marshal() []byte

Marshal the multisignature with RLP

func (*Multisignature) UnMarshal

func (mSig *Multisignature) UnMarshal(bz []byte) error

type PubKeyMultisigThreshold

type PubKeyMultisigThreshold struct {
	K       uint        `json:"threshold"`
	PubKeys []PublicKey `json:"pubkeys"`
}

func NewPubKeyMultisigThreshold

func NewPubKeyMultisigThreshold(k int, pubkeys []PublicKey) PubKeyMultisigThreshold

func (PubKeyMultisigThreshold) Address

func (pk PubKeyMultisigThreshold) Address() ethcmn.Address

func (PubKeyMultisigThreshold) Bytes

func (pk PubKeyMultisigThreshold) Bytes() []byte

func (PubKeyMultisigThreshold) Hash

func (pk PubKeyMultisigThreshold) Hash() (sum ethcmn.Hash)

func (PubKeyMultisigThreshold) VerifyBytes

func (pk PubKeyMultisigThreshold) VerifyBytes(msg []byte, marshalledSig []byte) bool

type PublicKey

type PublicKey [PubKeyLength]byte

func BytesToPubkey

func BytesToPubkey(b []byte) (PublicKey, error)

func HexToPubkey

func HexToPubkey(s string) (PublicKey, error)

func (PublicKey) Big

func (a PublicKey) Big() *big.Int

func (PublicKey) Bytes

func (a PublicKey) Bytes() []byte

func (PublicKey) Equals

func (pk PublicKey) Equals(pk1 PublicKey) bool

func (PublicKey) Format

func (a PublicKey) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (PublicKey) Hex

func (a PublicKey) Hex() string

func (PublicKey) IsAddress

func (a PublicKey) IsAddress() bool

unsafe 前13个字节都是0

func (PublicKey) MarshalText

func (a PublicKey) MarshalText() ([]byte, error)

MarshalText returns the hex representation of a.

func (*PublicKey) SetBytes

func (a *PublicKey) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (PublicKey) String

func (a PublicKey) String() string

String implements fmt.Stringer.

func (PublicKey) ToAddress

func (pk PublicKey) ToAddress() Address

unsafe 兼容老版本

func (*PublicKey) UnmarshalJSON

func (a *PublicKey) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*PublicKey) UnmarshalText

func (a *PublicKey) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

func (PublicKey) VerifyBytes

func (pk PublicKey) VerifyBytes(msg, signature []byte) bool

type QueryBase

type QueryBase struct {
	Order  string
	Limit  uint64
	Cursor uint64

	Begin uint64
	End   uint64
}

type Result

type Result struct {
	Code uint32 `json:"Code"`
	Data []byte `json:"Data"`
	Log  string `json:"Log"` // Can be non-deterministic
}

CONTRACT: a zero Result is OK.

func NewError

func NewError(code uint32, log string) Result

func NewResultOK

func NewResultOK(data []byte, log string) Result

NOTE: if data == nil and log == "", same as zero Result.

func (Result) AppendLog

func (res Result) AppendLog(log string) Result

func (Result) Error

func (res Result) Error() string

func (*Result) FromJSON

func (res *Result) FromJSON(j string) *Result

func (Result) IsErr

func (res Result) IsErr() bool

func (Result) IsOK

func (res Result) IsOK() bool

func (Result) PrependLog

func (res Result) PrependLog(log string) Result

func (Result) SetData

func (res Result) SetData(data []byte) Result

func (Result) SetLog

func (res Result) SetLog(log string) Result

func (Result) String

func (res Result) String() string

func (Result) ToJSON

func (res Result) ToJSON() string

type Signature

type Signature struct {
	PubKey   PubKeyMultisigThreshold
	MultiSig *Multisignature
}

type TxBatch

type TxBatch struct {
	CreatedAt uint64    // 交易发起时间
	GasLimit  uint64    // gas限额
	GasPrice  *big.Int  // gas价格
	Nonce     uint64    // 交易发起者nonce
	Sender    PublicKey // 交易发起者公钥
	Ops       []TxOp    // 交易列表
	Memo      []byte    // 备注
	Signature []byte    // 交易签名
	// contains filtered or unexported fields
}

1对多批量交易

func NewTxBatch

func NewTxBatch() *TxBatch

func (*TxBatch) Cost

func (tx *TxBatch) Cost() *big.Int

func (*TxBatch) FromBytes

func (tx *TxBatch) FromBytes(bs []byte) error

func (*TxBatch) GasWanted

func (tx *TxBatch) GasWanted() int64

func (*TxBatch) Hash

func (tx *TxBatch) Hash() ethcmn.Hash

func (*TxBatch) SigHash

func (tx *TxBatch) SigHash() ethcmn.Hash

func (*TxBatch) Sign

func (tx *TxBatch) Sign(privkey string) ([]byte, error)

func (*TxBatch) ToBytes

func (tx *TxBatch) ToBytes() []byte

func (*TxBatch) Verify

func (tx *TxBatch) Verify() bool

type TxEvm

type TxEvm struct {
	CreatedAt uint64      // 交易发起时间
	GasLimit  uint64      // gas限额
	GasPrice  *big.Int    // gas价格
	Nonce     uint64      // 交易发起者nonce
	Sender    PublicKey   // 交易发起者公钥
	Body      TxEvmCommon // 交易结构
	Signature []byte      // 交易签名
	// contains filtered or unexported fields
}

evm交易时sender和receiver都传public key,如果是合约帐户,receiver填写最后20个字节,前12字节填0

func NewTxEvm

func NewTxEvm() *TxEvm

func (*TxEvm) Cost

func (tx *TxEvm) Cost() *big.Int

func (*TxEvm) FromBytes

func (tx *TxEvm) FromBytes(bs []byte) error

func (*TxEvm) Hash

func (tx *TxEvm) Hash() ethcmn.Hash

func (*TxEvm) SigHash

func (tx *TxEvm) SigHash() ethcmn.Hash

func (*TxEvm) Sign

func (tx *TxEvm) Sign(privkey string) ([]byte, error)

func (*TxEvm) ToBytes

func (tx *TxEvm) ToBytes() []byte

func (*TxEvm) Verify

func (tx *TxEvm) Verify() bool

type TxEvmCommon

type TxEvmCommon struct {
	To    PublicKey // 交易接收方公钥或地址,地址时填后20字节,创建合约是为全0
	Value *big.Int  // 交易金额
	Load  []byte    // 合约交易负荷
	Memo  []byte    // 备注信息
}

type TxManage

type TxManage struct {
	CreatedAt uint64         // 时间戳
	Sender    ed25519.PubKey // 交易发起者公钥
	Nonce     uint64         // 交易发起者nonce
	Receiver  ed25519.PubKey // 交易接受者公钥
	OpType    uint8          // 操作类型 1-设置RunFor 2-设置POWER 3-设置Genesis权限
	OpValue   uint64         // Op对应的值 OpType=1时(OpValue=0,取消runFor;OpValue=1,设置runFor);OpType=2时是TMCore票权
	Signature []byte         // signature
	// contains filtered or unexported fields
}

func NewMgrTx

func NewMgrTx() *TxManage

func (*TxManage) FromBytes

func (tx *TxManage) FromBytes(bs []byte) error

func (*TxManage) Hash

func (tx *TxManage) Hash() ethcmn.Hash

func (*TxManage) Sign

func (tx *TxManage) Sign(privkey []byte) []byte

func (*TxManage) ToBytes

func (tx *TxManage) ToBytes() []byte

func (*TxManage) Verify

func (tx *TxManage) Verify() bool

type TxNodeDelegate

type TxNodeDelegate struct {
	CreatedAt uint64         // 交易发起时间
	Sender    ed25519.PubKey // 交易发起者公钥
	Nonce     uint64         // 交易发起者nonce
	OpType    uint8          // 操作类型 1-抵押 2-赎回 3-领取收益 4-提现
	OpValue   *big.Int       // Op对应的值 OpType=1时为抵押金额;OpType=4时为体现金额
	Receiver  []byte         // 提现地址,OpType=4时有效
	Signature []byte         // 交易签名
	// contains filtered or unexported fields
}

func NewNodeDelegateTx

func NewNodeDelegateTx() *TxNodeDelegate

func (*TxNodeDelegate) Cost

func (tx *TxNodeDelegate) Cost() *big.Int

func (*TxNodeDelegate) FromBytes

func (tx *TxNodeDelegate) FromBytes(bs []byte) error

func (*TxNodeDelegate) GasWanted

func (tx *TxNodeDelegate) GasWanted() int64

func (*TxNodeDelegate) Hash

func (tx *TxNodeDelegate) Hash() ethcmn.Hash

func (*TxNodeDelegate) Sign

func (tx *TxNodeDelegate) Sign(privkey []byte) []byte

func (*TxNodeDelegate) ToBytes

func (tx *TxNodeDelegate) ToBytes() []byte

func (*TxNodeDelegate) Verify

func (tx *TxNodeDelegate) Verify() bool

type TxOp

type TxOp struct {
	To    PublicKey // 转账接收方公钥或地址,地址时填后20字节
	Value *big.Int  // 交易金额
}

type TxParams

type TxParams struct {
	CreatedAt uint64         // 时间戳
	Sender    ed25519.PubKey // 交易发起者公钥
	Nonce     uint64         // 交易发起者nonce
	Key       []byte         // 参数名称
	Value     []byte         // 参数值
	Signature []byte         // signature
	// contains filtered or unexported fields
}

unsafe

func NewTxParams

func NewTxParams() *TxParams

func (*TxParams) FromBytes

func (tx *TxParams) FromBytes(bs []byte) error

func (*TxParams) Hash

func (tx *TxParams) Hash() ethcmn.Hash

func (*TxParams) Sign

func (tx *TxParams) Sign(privkey []byte) []byte

func (*TxParams) ToBytes

func (tx *TxParams) ToBytes() []byte

func (*TxParams) Verify

func (tx *TxParams) Verify() bool

type TxResult

type TxResult struct {
	Ret      []byte      `json:"ret"`      // 返回数据
	Hash     common.Hash `json:"hash"`     // tx hash
	Reversed []byte      `json:"reversed"` // 保留
}

注意amino的兼容类型

func NewTxResult

func NewTxResult(ret []byte, hash common.Hash) *TxResult

func (TxResult) Copy

func (tx TxResult) Copy() *TxResult

func (*TxResult) FromBytes

func (tx *TxResult) FromBytes(bs []byte) error

func (TxResult) ToBytes

func (tx TxResult) ToBytes() []byte

type TxUserDelegate

type TxUserDelegate struct {
	CreatedAt uint64    // 交易发起时间
	Sender    PublicKey // 交易发起者公钥
	Nonce     uint64    // 交易发起者nonce
	OpType    uint8     // 操作类型 1-抵押选举 2-赎回 3-领取收益
	OpValue   *big.Int  // Op对应的值,OpType=1时为抵押金额
	Receiver  []byte    // 接受者地址 OpType=1时为节点地址
	Signature []byte    // 交易签名
	// contains filtered or unexported fields
}

func NewUserDelegateTx

func NewUserDelegateTx() *TxUserDelegate

func (*TxUserDelegate) Cost

func (tx *TxUserDelegate) Cost() *big.Int

func (*TxUserDelegate) FromBytes

func (tx *TxUserDelegate) FromBytes(bs []byte) error

func (*TxUserDelegate) GasWanted

func (tx *TxUserDelegate) GasWanted() int64

func (*TxUserDelegate) Hash

func (tx *TxUserDelegate) Hash() ethcmn.Hash

func (*TxUserDelegate) SigHash

func (tx *TxUserDelegate) SigHash() ethcmn.Hash

func (*TxUserDelegate) Sign

func (tx *TxUserDelegate) Sign(privkey string) ([]byte, error)

func (*TxUserDelegate) ToBytes

func (tx *TxUserDelegate) ToBytes() []byte

func (*TxUserDelegate) Verify

func (tx *TxUserDelegate) Verify() bool

type Validator

type Validator struct {
	PubKey     ed25519.PubKey // 节点公钥
	Nonce      uint64         // nonce
	Power      uint64         // 投票权
	Genesis    bool           // 是否是创世节点
	RunFor     bool           // 参与竞选
	Balance    *big.Int       // 余额(累积收益)
	Profit     *big.Int       // 本轮收益
	Mortgaged  *big.Int       // 已抵押
	ToMortgage *big.Int       // 待抵押
	Redeem     bool           // 待赎回
	Voters     []Vot          // 选民列表
	Voted      *big.Int       // 选民贡献
}

func NewValidator

func NewValidator() *Validator

func (*Validator) AddVoter

func (v *Validator) AddVoter(address common.Address, amount *big.Int)

func (*Validator) Address

func (v *Validator) Address() crypto.Address

func (*Validator) Equal

func (v *Validator) Equal(to *Validator) bool

func (*Validator) FromBytes

func (v *Validator) FromBytes(b []byte)

func (*Validator) FromJSON

func (v *Validator) FromJSON(data []byte) error

func (*Validator) PublicKeyStr

func (v *Validator) PublicKeyStr() string

func (*Validator) RemoveVoter

func (v *Validator) RemoveVoter(address common.Address)

func (*Validator) String

func (v *Validator) String() string

func (*Validator) TCNShare

func (v *Validator) TCNShare() *big.Int

func (*Validator) TINShare

func (v *Validator) TINShare() *big.Int

func (*Validator) ToBytes

func (v *Validator) ToBytes() []byte

func (*Validator) ToJSON

func (v *Validator) ToJSON() ([]byte, error)

func (*Validator) ToPrettyJSON

func (v *Validator) ToPrettyJSON() ([]byte, error)

func (*Validator) TotalShare

func (v *Validator) TotalShare() *big.Int

func (*Validator) UpdateVoter

func (v *Validator) UpdateVoter(address common.Address, amount *big.Int)

type Vot

type Vot struct {
	Address common.Address // 选民地址
	Amount  *big.Int       // 投票金额
}

type Voter

type Voter struct {
	Address    common.Address // 选民地址
	Balance    *big.Int       // 累积收益余额
	Validator  common.Address // 节点地址 使用common.Address替换crypto.Address
	Mortgaged  *big.Int       // 已抵押
	ToMortgage *big.Int       // 待抵押
	Burned     *big.Int       // 已燃烧
	Redeem     bool           // 赎回标志
}

func NewVoter

func NewVoter() *Voter

func (*Voter) CanRemove

func (v *Voter) CanRemove() bool

func (*Voter) Equal

func (v *Voter) Equal(to *Voter) bool

func (*Voter) FromBytes

func (v *Voter) FromBytes(b []byte)

func (*Voter) FromJSON

func (v *Voter) FromJSON(data []byte) error

func (*Voter) RealMortgaged

func (v *Voter) RealMortgaged() *big.Int

实际抵押金额

func (*Voter) String

func (v *Voter) String() string

func (*Voter) ToBytes

func (v *Voter) ToBytes() []byte

func (*Voter) ToJSON

func (v *Voter) ToJSON() ([]byte, error)

func (*Voter) TotalShare

func (v *Voter) TotalShare() *big.Int

实际股权贡献

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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