contract

package
v0.0.0-...-2cf7c70 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: Apache-2.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 []*crypto.PubKey) ([]byte, error)

func CreateSignatureRedeemScript

func CreateSignatureRedeemScript(pubkey *crypto.PubKey) ([]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 Uint160

	//owner's pubkey hash indicate the owner of contract
	OwnerPubkeyHash Uint160
}

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

func CreateMultiSigContract

func CreateMultiSigContract(publicKeyHash Uint160, m int, publicKeys []*crypto.PubKey) (*Contract, error)

create a Multi Singature contract for owner 。

func CreateSignatureContract

func CreateSignatureContract(ownerPubKey *crypto.PubKey) (*Contract, error)

create a Single Singature 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 []Uint160
	Codes         [][]byte
	Parameters    [][][]byte

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

func NewContractContext

func NewContractContext(data sig.SignableData) *ContractContext

func (*ContractContext) Add

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

func (*ContractContext) AddContract

func (ctx *ContractContext) AddContract(contract *Contract, pubkey *crypto.PubKey, parameter []byte) error

func (*ContractContext) AddMultiSignatures

func (ctx *ContractContext) AddMultiSignatures(index int, contract *Contract, pubkey *crypto.PubKey, parameter []byte) error

func (*ContractContext) AddSignatureToMultiList

func (ctx *ContractContext) AddSignatureToMultiList(contractIndex int, contract *Contract, pubkey *crypto.PubKey, parameter []byte) error

func (*ContractContext) GetIndex

func (ctx *ContractContext) GetIndex(programHash Uint160) int

func (*ContractContext) GetPrograms

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

func (*ContractContext) IsCompleted

func (ctx *ContractContext) IsCompleted() bool

func (*ContractContext) ParseContractPubKeys

func (ctx *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
	Object
	Array = 0x10
	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