Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeHTLC(payload string) (interface{}, error)
- func QueryAddress(address common.Address, statedb *state.Statedb) (*masternodeInfo, error)
- func Sha256Hash(x []byte) []byte
- func ValidateDomainName(domainName []byte) error
- type BTCBlock
- type Context
- type Contract
- type HashTimeLock
- type RelayRequest
- type SubChainInfo
- type Withdrawing
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 scdo from HTLC CmdWithdraw // CmdRefund refund scdo from HTLC CmdRefund // CmdGetContract get HTLC CmdGetContract )
View Source
const ( // CmdDeposit deposit scdo and register as masternode CmdDeposit byte = iota // CmdQueryMasternode query masternode CmdQueryMasternode // CmdRecall recallCmd scdo 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 ¶
DecodeHTLC decode HTLC information
func QueryAddress ¶
func Sha256Hash ¶
Sha256Hash used consist with solidity HTLC contract sha function
func ValidateDomainName ¶
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
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 Scdo.
func GetContractByAddress ¶
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.
Click to show internal directories.
Click to hide internal directories.