system

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: LGPL-3.0 Imports: 15 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// CmdVerifyTx is the command byte to verify btc tx
	CmdVerifyTx = iota
	// CmdRelayTx is the command byte to relay btc tx
	CmdRelayTx
	// CmdStoreBlockHeader is the command byte to store btc block header
	CmdStoreBlockHeader
	// CmdGetBlockHeader is the command byte to get btc block header
	CmdGetBlockHeader
)
View Source
const (
	// CmdCreateDomainName create a domain
	CmdCreateDomainName byte = iota
	// CmdGetDomainNameOwner query the registrar of specified domain name
	CmdGetDomainNameOwner
)
View Source
const (
	// CmdNewContract create HTLC
	CmdNewContract byte = iota
	// CmdWithdraw withdraw seele from HTLC
	CmdWithdraw
	// CmdRefund refund seele from HTLC
	CmdRefund
	// CmdGetContract get HTLC
	CmdGetContract
)
View Source
const (
	// CmdDeposit deposit seele and register as masternode
	CmdDeposit byte = iota
	// CmdQueryMasternode query masternode
	CmdQueryMasternode
	// CmdRecall recallCmd seele and unregister as masternode
	CmdRecall
	// CmdQuit quitCmd masternode
	CmdQuit
)
View Source
const (
	// CmdSubChainRegister register a sub-chain
	CmdSubChainRegister byte = iota
	// CmdSubChainQuery query a sub-chain.
	CmdSubChainQuery
)

Variables

View Source
var (

	// DomainNameContractAddress domain contract address
	DomainNameContractAddress = common.BytesToAddress([]byte{1, 1})
	// SubChainContractAddress subchain contract address
	SubChainContractAddress = common.BytesToAddress([]byte{1, 2})
	// HashTimeLockContractAddress HTLC contract address
	HashTimeLockContractAddress = common.BytesToAddress([]byte{1, 3})
	// MasternodeContractAddress masternode contract address
	MasternodeContractAddress = common.BytesToAddress([]byte{1, 4})
	// BTCRelayContractAddress btc-relay contract address
	BTCRelayContractAddress = common.BytesToAddress([]byte{1, 5})
)
View Source
var (
	ByteTrue  = []byte{1}
	ByteFalse = []byte{0}
)
View Source
var (
	ErrDepositNotRight   = errors.New("deposit amount is not right")
	ErrAlreadyExist      = errors.New("this address is already masternode")
	ErrNotExist          = errors.New("this address is not masternode")
	ErrNotQuit           = errors.New("address doesn't quit")
	ErrNotEnoughDistance = errors.New("not enough distance")
)

Functions

func DecodeHTLC

func DecodeHTLC(payload string) (interface{}, error)

DecodeHTLC decode HTLC information

func QueryAddress

func QueryAddress(address common.Address, statedb *state.Statedb) (*masternodeInfo, error)

func Sha256Hash

func Sha256Hash(x []byte) []byte

Sha256Hash used consist with solidity HTLC contract sha function

func ValidateDomainName

func ValidateDomainName(domainName []byte) error

ValidateDomainName validate domain name

Types

type BTCBlock

type BTCBlock struct {
	BlockHeaderHex   string
	Height           uint64
	PreviousBlockHex string
	TxHexs           []string
	Relayer          common.Address
}

BTCBlock btc block structure

func (*BTCBlock) String

func (b *BTCBlock) String() string

type Context

type Context struct {
	BlockHeader *types.BlockHeader
	// contains filtered or unexported fields
}

Context provides information that required in system contract.

func NewContext

func NewContext(tx *types.Transaction, statedb *state.Statedb, BlockHeader *types.BlockHeader) *Context

NewContext creates a system contract context.

type Contract

type Contract interface {
	RequiredGas(input []byte) uint64
	Run(input []byte, context *Context) ([]byte, error)
}

Contract is the basic interface for native Go contracts in Seele.

func GetContractByAddress

func GetContractByAddress(address common.Address) Contract

GetContractByAddress get system contract by the address

type HashTimeLock

type HashTimeLock struct {
	// HashLock is used to lock amount until provide preimage of hashlock
	HashLock common.Bytes
	// TimeLock is used to lock amount a period
	TimeLock int64
	// receive address
	To common.Address
}

HashTimeLock payload information

type RelayRequest

type RelayRequest struct {
	BTCBlock
	TxHex string
	// This is used to relay the verification of successful tx to the contract address
	RelayAddress common.Address
}

RelayRequest is a request structure using btc-relay

func (*RelayRequest) String

func (r *RelayRequest) String() string

type SubChainInfo

type SubChainInfo struct {
	Name        string            `json:"name"`
	Version     string            `json:"version"`
	StaticNodes []*discovery.Node `json:"staticNodes"`

	TokenFullName  string `json:"tokenFullName"`
	TokenShortName string `json:"tokenShortName"`
	TokenAmount    uint64 `json:"tokenAmount"`

	GenesisDifficulty uint64                      `json:"genesisDifficulty"`
	GenesisAccounts   map[common.Address]*big.Int `json:"genesisAccounts"`
	CreateTimestamp   *big.Int                    `json:"timestamp,omitempty"`

	// SubChain owner publick key
	Owner common.Address `json:"owner,omitempty"`
}

SubChainInfo represents the sub-chain registration information.

type Withdrawing

type Withdrawing struct {
	// Hash is the key of data
	Hash common.Hash
	// Preimage the hashlock preimage
	Preimage common.Bytes
}

Withdrawing used to withdraw from contract

Jump to

Keyboard shortcuts

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