Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(input string) ([]byte, error)
- func DecodeZV(input string) ([]byte, error)
- func Encode(b []byte) string
- func NewMnemonic(bitSize int) (string, error)
- func ToAddrHex(b []byte) string
- func ValidateAddress(addr string) bool
- type ABI
- type ABIVerify
- type Account
- type AccountMsg
- type Address
- type Api
- func (api Api) Balance(address Address) (float64, error)
- func (api Api) BlockHeight() (uint64, error)
- func (api Api) GetBlockByHash(hash Hash) (*Block, error)
- func (api Api) GetBlockByHeight(height uint64) (*Block, error)
- func (api Api) GetBlockHashByHeight(height uint64) (*Hash, error)
- func (api Api) GetNonce(address Address) (uint64, error)
- func (api Api) GetTransactionByHash(hash Hash) (*RawTransaction, error)
- func (api Api) MinerInfo(address Address, detail interface{}) (*MinerStakeDetails, error)
- func (api Api) SendTransaction(tx Transaction) (*Hash, error)
- func (api *Api) SetSigner(signer Signer)
- func (api Api) SignAndSendTransaction(tx Transaction) (*Hash, error)
- type Asset
- type Block
- type BlockDetail
- type Contract
- type ContractCallTransaction
- type ContractCreateTransaction
- type ErrorResult
- type Event
- type Hash
- type ID
- type KeyBag
- type MinerStakeDetails
- type MortGage
- type PrivateKey
- type PublicKey
- type RPCReqObj
- type RPCResObj
- type RawMessage
- type RawTransaction
- func (t RawTransaction) GenHash() Hash
- func (t *RawTransaction) SetData(data []byte) *RawTransaction
- func (t *RawTransaction) SetExtraData(extraData []byte) *RawTransaction
- func (t *RawTransaction) SetGasLimit(gasLimit uint64) *RawTransaction
- func (t *RawTransaction) SetGasPrice(gasPrice uint64) *RawTransaction
- func (t *RawTransaction) SetNonce(nonce uint64) *RawTransaction
- func (t RawTransaction) ToRawTransaction() RawTransaction
- type Result
- type RewardTransaction
- type Sign
- type Signer
- type SimpleTx
- type StakeDetail
- type Transaction
- type TransferTransaction
- type Wallet
Constants ¶
View Source
const ( DefaultGasPrice = 500 DefaultGasLimit = 3000 CodeBytePrice = 19073 //1.9073486328125 CodeBytePricePrecision = 10000 )
View Source
const ( TransactionTypeTransfer = 0 TransactionTypeContractCreate = 1 TransactionTypeContractCall = 2 )
View Source
const ( Ra = 1 ZVC = 1000000000 )
View Source
const AddrPrefix = "zv"
View Source
const AddressLength = 32
View Source
const HashPrefix = "0x"
View Source
const Idlength = 32
View Source
const Mnemonic12WordBitSize = 128
View Source
const Mnemonic24WordBitSize = 256
View Source
const SignLength = 65 //length of signature,32 bytes r & 32 bytes s & 1 byte recid.
View Source
const ZVCPath = "m/44'/372'/0'/0/%d" // 372
Variables ¶
View Source
var ( ErrPassword = fmt.Errorf("password error") ErrUnlocked = fmt.Errorf("please unlock the Account first") ErrUnConnected = fmt.Errorf("please connect to one node first") ErrInternal = fmt.Errorf("internal error") )
View Source
var ( ErrorInvalidAssetString = errors.New("invalid asset string") ErrorInvalidAddressString = errors.New("invalid address string") ErrorInvalidPrivateKey = errors.New("invalid private key") ErrorInvalid0xString = errors.New("invalid hex String") ErrorInvalidZVString = errors.New("invalid address String") ErrorSignerNotFound = errors.New("signer not found") ErrorSourceEmpty = errors.New("source should not be empty") )
View Source
var (
NoSignerError = errors.New("signer should be set before send a no-sign transaction")
)
Functions ¶
func NewMnemonic ¶
NewMnemonic Generate Mnemonic, returns of number of words depends on input: bitSize(eg: Mnemonic12WordBitSize, Mnemonic24WordBitSize)
func ValidateAddress ¶
Types ¶
type ABIVerify ¶
ABIVerify stores the contract function name and args types, in order to facilitate the abi verify
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func NewAccount ¶
func NewAccountFromString ¶
func (Account) PrivateKey ¶
func (a Account) PrivateKey() *PrivateKey
type AccountMsg ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func NewAddressFromBytes ¶
func NewAddressFromString ¶
func (*Address) MarshalJSON ¶
func (*Address) UnmarshalJSON ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
func (Api) BlockHeight ¶
func (Api) GetTransactionByHash ¶
func (api Api) GetTransactionByHash(hash Hash) (*RawTransaction, error)
func (Api) MinerInfo ¶
func (api Api) MinerInfo(address Address, detail interface{}) (*MinerStakeDetails, error)
func (Api) SendTransaction ¶
func (api Api) SendTransaction(tx Transaction) (*Hash, error)
func (Api) SignAndSendTransaction ¶
func (api Api) SignAndSendTransaction(tx Transaction) (*Hash, error)
type Block ¶
type Block struct { Height uint64 `json:"height" mapstructure:"height"` Hash Hash `json:"hash" mapstructure:"hash"` PreHash Hash `json:"pre_hash" mapstructure:"pre_hash"` CurTime time.Time `json:"cur_time" mapstructure:"cur_time,squash"` PreTime time.Time `json:"pre_time" mapstructure:"pre_time,squash"` Castor ID `json:"castor" mapstructure:"castor"` Group Hash `json:"group_id" mapstructure:"group_id"` Prove string `json:"prove" mapstructure:"prove"` TotalQN uint64 `json:"total_qn" mapstructure:"total_qn"` Qn uint64 `json:"qn" mapstructure:"qn"` TxNum uint64 `json:"txs" mapstructure:"txs"` StateRoot Hash `json:"state_root" mapstructure:"state_root"` TxRoot Hash `json:"tx_root" mapstructure:"tx_root"` ReceiptRoot Hash `json:"receipt_root" mapstructure:"receipt_root"` ProveRoot Hash `json:"prove_root" mapstructure:"prove_root"` Random string `json:"random" mapstructure:"random"` }
type BlockDetail ¶
type BlockDetail struct { Block GenRewardTx RewardTransaction `json:"gen_reward_tx"` Trans []SimpleTx `json:"trans"` BodyRewardTxs []RewardTransaction `json:"body_reward_txs"` PreTotalQN uint64 `json:"pre_total_qn"` }
type ContractCallTransaction ¶
type ContractCallTransaction struct {
RawTransaction
}
func (*ContractCallTransaction) ToRawTransaction ¶
func (tt *ContractCallTransaction) ToRawTransaction() RawTransaction
type ContractCreateTransaction ¶
type ContractCreateTransaction struct {
RawTransaction
}
func NewContractCallTransaction ¶
func NewContractCallTransaction(from, to Address, value Asset, funcName string, params ...interface{}) *ContractCreateTransaction
func NewContractCreateTransaction ¶
func NewContractCreateTransaction(from Address, code string, contractName string, value Asset) *ContractCreateTransaction
func (*ContractCreateTransaction) ToRawTransaction ¶
func (tt *ContractCreateTransaction) ToRawTransaction() RawTransaction
type ErrorResult ¶
ErrorResult is rpc requestGzv error returned variable parameter
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
func (*Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
func (*ID) MarshalJSON ¶
func (*ID) UnmarshalJSON ¶
type KeyBag ¶
type KeyBag struct {
// contains filtered or unexported fields
}
func (KeyBag) AvailableAddresses ¶
func (KeyBag) AvailablePublicKeys ¶
func (*KeyBag) ImportPrivateKey ¶
func (*KeyBag) ImportPrivateKeyFromString ¶
type MinerStakeDetails ¶
type MinerStakeDetails struct { Overview []*MortGage `json:"overview,omitempty"` Details map[string][]*StakeDetail `json:"details,omitempty"` }
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func NewPrivateKey ¶
func NewPrivateKey(privateKey []byte) (*PrivateKey, error)
func (*PrivateKey) ImportPrivateKey ¶
func (key *PrivateKey) ImportPrivateKey(privateKey []byte) (err error)
ImportPrivateKey import private key by bytes of private key
func (PrivateKey) PublicKey ¶
func (key PrivateKey) PublicKey() *PublicKey
func (PrivateKey) String ¶
func (key PrivateKey) String() string
String serialize private key to hex string
type RPCReqObj ¶
type RPCReqObj struct { Method string `json:"method"` Params []interface{} `json:"params"` Jsonrpc string `json:"jsonrpc"` ID uint `json:"id"` }
RPCReqObj is complete rpc requestGzv body
type RPCResObj ¶
type RPCResObj struct { Result RawMessage `json:"result,omitempty"` Error *ErrorResult `json:"error,omitempty"` }
type RawMessage ¶
type RawMessage []byte
func (RawMessage) MarshalJSON ¶
func (m RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*RawMessage) UnmarshalJSON ¶
func (m *RawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type RawTransaction ¶
type RawTransaction struct { Data []byte `json:"data"` Value uint64 `json:"value"` Nonce uint64 `json:"nonce"` Target *Address `json:"target"` Type int8 `json:"type"` GasLimit uint64 `json:"gas_limit"` GasPrice uint64 `json:"gas_price"` Hash Hash `json:"hash"` ExtraData []byte `json:"extra_data"` Sign *Sign `json:"sign"` Source *Address `json:"source"` }
func (RawTransaction) GenHash ¶
func (t RawTransaction) GenHash() Hash
func (*RawTransaction) SetData ¶
func (t *RawTransaction) SetData(data []byte) *RawTransaction
func (*RawTransaction) SetExtraData ¶
func (t *RawTransaction) SetExtraData(extraData []byte) *RawTransaction
func (*RawTransaction) SetGasLimit ¶
func (t *RawTransaction) SetGasLimit(gasLimit uint64) *RawTransaction
func (*RawTransaction) SetGasPrice ¶
func (t *RawTransaction) SetGasPrice(gasPrice uint64) *RawTransaction
func (*RawTransaction) SetNonce ¶
func (t *RawTransaction) SetNonce(nonce uint64) *RawTransaction
func (RawTransaction) ToRawTransaction ¶
func (t RawTransaction) ToRawTransaction() RawTransaction
type Result ¶
type Result struct { Message string `json:"message"` Status int `json:"status"` Data interface{} `json:"data"` }
Result is rpc requestGzv successfully returns the variable parameter
type RewardTransaction ¶
type Sign ¶
type Sign struct {
// contains filtered or unexported fields
}
Sign Data struct
func (Sign) MarshalJSON ¶
type Signer ¶
type Signer interface {
Sign(tx Transaction) (*Sign, error)
}
type SimpleTx ¶
type SimpleTx struct { Data []byte `json:"data"` Value float64 `json:"value"` Nonce uint64 `json:"nonce"` Source *Address `json:"source"` Target *Address `json:"target"` Type int8 `json:"type"` GasLimit uint64 `json:"gas_limit"` GasPrice uint64 `json:"gas_price"` Hash Hash `json:"hash"` ExtraData string `json:"extra_data"` }
type StakeDetail ¶
type Transaction ¶
type Transaction interface {
ToRawTransaction() RawTransaction
}
type TransferTransaction ¶
type TransferTransaction struct {
RawTransaction
}
func NewTransferTransaction ¶
func NewTransferTransaction(from, to Address, value Asset, data []byte) *TransferTransaction
func (*TransferTransaction) ToRawTransaction ¶
func (tt *TransferTransaction) ToRawTransaction() RawTransaction
Click to show internal directories.
Click to hide internal directories.