trans

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EAddrTypeDefault the type of default public address
	EAddrTypeDefault = byte(iota + 1)
	// EAddrTypeIBS identity-based signature
	EAddrTypeIBS
)
View Source
const (
	// HashLen the byte length of Hash
	HashLen = 32
	// AddressLen the byte length of Address
	AddressLen = 24
	// AdminNum admin number
	AdminNum = 23
)
View Source
const (
	// AppFlagRun the app can be call
	AppFlagRun = uint8(1 << iota)
	// AppFlagImport the app code can be included
	AppFlagImport
	// AppFlagPublic App funds address uses the plublc address, except for app, others have no right to operate the address.
	AppFlagPublic
	// AppFlagGzipCompress gzip compress
	AppFlagGzipCompress
	// AppFlagEnd end of flag
	AppFlagEnd
)
View Source
const (
	// OpsTransfer pTransfer
	OpsTransfer = uint8(iota)
	// OpsMove Move out of coin, move from this chain to adjacent chains
	OpsMove
	// OpsNewChain create new chain
	OpsNewChain
	// OpsNewApp create new app
	OpsNewApp
	// OpsRunApp run app
	OpsRunApp
	// OpsUpdateAppLife update app life
	OpsUpdateAppLife
	// OpsRegisterMiner Registered as a miner
	OpsRegisterMiner
	// OpsRegisterAdmin Registered as a admin
	OpsRegisterAdmin
	// OpsVote vote admin
	OpsVote
	// OpsUnvote unvote
	OpsUnvote
	// OpsReportError error block
	OpsReportError
)
View Source
const (
	TimeMillisecond = 1
	TimeSecond      = 1000 * TimeMillisecond
	TimeMinute      = 60 * TimeSecond
	TimeHour        = 60 * TimeMinute
	TimeDay         = 24 * TimeHour
	TimeYear        = 31558150 * TimeSecond
	TimeMonth       = TimeYear / 12
)

time

View Source
const (
	// TimeDuration one year/12
	TimeDuration = 31558150000 / 12
)

Variables

This section is empty.

Functions

func Decode

func Decode(in []byte, out interface{}) int

Decode binary decode

func Encode

func Encode(in interface{}) []byte

Encode binary encode

Types

type Address

type Address [AddressLen]byte

Address the wallet address

func (Address) Empty added in v0.5.0

func (a Address) Empty() bool

Empty Check where Address is empty

func (Address) MarshalJSON added in v0.5.0

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

MarshalJSON marshal by base64

func (Address) String added in v0.5.6

func (a Address) String() string

String string

func (*Address) UnmarshalJSON added in v0.5.0

func (a *Address) UnmarshalJSON(b []byte) error

UnmarshalJSON UnmarshalJSON

type Hash

type Hash [HashLen]byte

Hash The KEY of the block of transaction

func (Hash) Empty added in v0.5.0

func (h Hash) Empty() bool

Empty Check whether Hash is empty

func (Hash) MarshalJSON added in v0.5.0

func (h Hash) MarshalJSON() ([]byte, error)

MarshalJSON marshal by base64

func (Hash) String added in v0.5.6

func (h Hash) String() string

String string

func (*Hash) UnmarshalJSON added in v0.5.0

func (h *Hash) UnmarshalJSON(b []byte) error

UnmarshalJSON UnmarshalJSON

type StTrans

type StTrans struct {
	TransactionHead
	Sign []byte
	Data []byte
	Key  []byte
}

StTrans transaction define

func NewTransaction

func NewTransaction(chain uint64, user []byte, cost uint64) *StTrans

NewTransaction create a new transaction struct

  1. NewTransaction
  2. Create*:CreateTransfer,CreateMove...
  3. update energy,time...
  4. GetSignData
  5. SetSign
  6. Output

func (*StTrans) CreateMove

func (t *StTrans) CreateMove(dstChain uint64)

CreateMove move coin to other chain

func (*StTrans) CreateTransfer

func (t *StTrans) CreateTransfer(payee, msg string) error

CreateTransfer transfer

func (*StTrans) CreateVote added in v0.5.0

func (t *StTrans) CreateVote(payee string) error

CreateVote vote

func (*StTrans) GetSignData

func (t *StTrans) GetSignData() []byte

GetSignData get data of sign

func (*StTrans) Output

func (t *StTrans) Output() []byte

Output output the data, the full data of transaction

func (*StTrans) RegisterMiner added in v0.5.0

func (t *StTrans) RegisterMiner(chain uint64, peer string) error

RegisterMiner RegisterMiner

func (*StTrans) RunApp

func (t *StTrans) RunApp(app string, data []byte) error

RunApp run app

func (*StTrans) SetEnergy added in v0.5.0

func (t *StTrans) SetEnergy(energy uint64) bool

SetEnergy set energy

func (*StTrans) SetTheSign added in v0.5.0

func (t *StTrans) SetTheSign(in []byte) error

SetTheSign set the sign

func (*StTrans) Unvote added in v0.5.0

func (t *StTrans) Unvote() error

Unvote cancel vote

func (*StTrans) UpdateAppLife

func (t *StTrans) UpdateAppLife(app string, life uint64) error

UpdateAppLife update app life

type TransactionHead

type TransactionHead struct {
	//signLen uint8
	//sing  []byte
	Time   uint64
	User   Address
	Chain  uint64
	Energy uint64
	Cost   uint64
	Ops    uint8
}

TransactionHead transaction = sign + head + data

type UpdateInfo

type UpdateInfo struct {
	Name Hash
	Life uint64
}

UpdateInfo Information of update app life

type Wallet

type Wallet struct {
	Tag        string `json:"tag,omitempty"`
	AddressStr string `json:"address_str,omitempty"`
	Address    []byte `json:"address,omitempty"`
	Key        []byte `json:"key,omitempty"`
	SignPrefix []byte `json:"sign_prefix,omitempty"`
	// contains filtered or unexported fields
}

Wallet wallet

func (*Wallet) ChangePwd

func (w *Wallet) ChangePwd(old, pwd string) bool

ChangePwd change password

func (*Wallet) Load

func (w *Wallet) Load(pwd, data string) error

Load load wallet by json data

func (*Wallet) New

func (w *Wallet) New(pwd string) error

New new wallet

func (*Wallet) NewByMnemonic added in v0.5.0

func (w *Wallet) NewByMnemonic(pwd string, priv []byte) error

NewByMnemonic new wallet by Mnemonic

func (*Wallet) Sign

func (w *Wallet) Sign(data []byte) []byte

Sign sign

func (*Wallet) String

func (w *Wallet) String() string

String return json string

Jump to

Keyboard shortcuts

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