contract

package
v0.0.0-...-c8e9c26 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContractParameterTypeToByte

func ContractParameterTypeToByte(c []ContractParameterType) []byte

func CreateMultiSigRedeemScript

func CreateMultiSigRedeemScript(m int, pubkeys []keypair.PublicKey) ([]byte, error)

func CreateSignatureRedeemScript

func CreateSignatureRedeemScript(pubkey keypair.PublicKey) ([]byte, error)

Types

type Contract

type Contract struct {
	//the contract program code,which will be run on VM or specific envrionment
	Code []byte

	//the Contract Parameter type list
	// describe the number of contract program parameters and the parameter type
	Parameters []ContractParameterType

	//The program hash as contract address
	ProgramHash common.Address

	//owner's pubkey hash indicate the owner of contract
	OwnerPubkeyHash common.Address
}

Contract include the program codes with parameters which can be executed on specific evnrioment

func CreateMultiSigContract

func CreateMultiSigContract(publicKeyHash common.Address, m int, publicKeys []keypair.PublicKey) (*Contract, error)

create a Multi Signature contract for owner 。

func CreateSignatureContract

func CreateSignatureContract(ownerPubKey keypair.PublicKey) (*Contract, error)

create a Single Signature contract for owner

func (*Contract) Deserialize

func (c *Contract) Deserialize(r io.Reader) error

func (*Contract) GetType

func (c *Contract) GetType() ContractType

func (*Contract) IsMultiSigContract

func (c *Contract) IsMultiSigContract() bool

func (*Contract) IsStandard

func (c *Contract) IsStandard() bool

func (*Contract) Serialize

func (c *Contract) Serialize(w io.Writer) error

func (*Contract) ToArray

func (c *Contract) ToArray() []byte

type ContractContext

type ContractContext struct {
	Data          sig.SignableData
	ProgramHashes []common.Address
	Codes         [][]byte
	Parameters    [][][]byte

	MultiPubkeyPara [][]PubkeyParameter
	// contains filtered or unexported fields
}

func NewContractContext

func NewContractContext(data sig.SignableData) *ContractContext

func (*ContractContext) Add

func (cxt *ContractContext) Add(contract *Contract, index int, parameter []byte) error

func (*ContractContext) AddContract

func (cxt *ContractContext) AddContract(contract *Contract, pubkey keypair.PublicKey, parameter []byte) error

func (*ContractContext) AddMultiSignatures

func (cxt *ContractContext) AddMultiSignatures(index int, contract *Contract, pubkey keypair.PublicKey, parameter []byte) error

func (*ContractContext) AddSignatureToMultiList

func (cxt *ContractContext) AddSignatureToMultiList(contractIndex int, contract *Contract, pubkey keypair.PublicKey, parameter []byte) error

func (*ContractContext) GetIndex

func (cxt *ContractContext) GetIndex(programHash common.Address) int

func (*ContractContext) GetPrograms

func (cxt *ContractContext) GetPrograms() []*pg.Program

func (*ContractContext) IsCompleted

func (cxt *ContractContext) IsCompleted() bool

func (*ContractContext) ParseContractPubKeys

func (cxt *ContractContext) ParseContractPubKeys(contract *Contract) (map[string]int, error)

type ContractParameterType

type ContractParameterType byte

parameter defined type.

const (
	Signature ContractParameterType = iota
	Boolean
	Integer
	Hash160
	Hash256
	ByteArray
	PublicKey
	String
	Array            = 0x10
	InteropInterface = 0xf0
	Void             = 0xff
)

func ByteToContractParameterType

func ByteToContractParameterType(b []byte) []ContractParameterType

type ContractType

type ContractType byte
const (
	SignatureContract ContractType = iota
	MultiSigContract
	CustomContract
)

type ParameterIndex

type ParameterIndex struct {
	Parameter []byte
	Index     int
}

type ParameterIndexSlice

type ParameterIndexSlice []ParameterIndex

func (ParameterIndexSlice) Len

func (p ParameterIndexSlice) Len() int

func (ParameterIndexSlice) Less

func (p ParameterIndexSlice) Less(i, j int) bool

func (ParameterIndexSlice) Swap

func (p ParameterIndexSlice) Swap(i, j int)

type PubkeyParameter

type PubkeyParameter struct {
	PubKey    string
	Parameter string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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