neorpc

package
v0.0.0-...-9522f64 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Hash              string `json:"hash"`
	Size              int    `json:"size"`
	Version           int    `json:"version"`
	Previousblockhash string `json:"previousblockhash"`
	Merkleroot        string `json:"merkleroot"`
	Time              int    `json:"time"`
	Index             int    `json:"index"`
	Nonce             string `json:"nonce"`
	Nextconsensus     string `json:"nextconsensus"`
	CrossStatesRoot   string `json:"crossstatesroot"`
	ChainID           string `json:"chainid"` //ulong = uint64
	Script            struct {
		Invocation   string `json:"invocation"`
		Verification string `json:"verification"`
	} `json:"script"`
	Tx []struct {
		Txid       string        `json:"txid"`
		Size       int           `json:"size"`
		Type       string        `json:"type"`
		Version    int           `json:"version"`
		Attributes []interface{} `json:"attributes"`
		Vin        []interface{} `json:"vin"`
		Vout       []interface{} `json:"vout"`
		Claims     []interface{} `json:"claims"`
		SysFee     string        `json:"sys_fee"`
		NetFee     string        `json:"net_fee"`
		Scripts    []interface{} `json:"scripts"`
		Nonce      int64         `json:"nonce,omitempty"`
		Script     string        `json:"script,omitempty"`
		Gas        string        `json:"gas,omitempty"`
	} `json:"tx"`
	Confirmations int    `json:"confirmations"`
	Nextblockhash string `json:"nextblockhash"`
}

type BlockHeader

type BlockHeader struct {
	Hash              util.Uint256 `json:"hash"`
	Size              int          `json:"size"`
	Version           uint32       `json:"version"`
	Previousblockhash util.Uint256 `json:"previousblockhash"`
	Merkleroot        util.Uint256 `json:"merkleroot"`
	Time              uint32       `json:"time"`
	Index             uint32       `json:"index"`
	Nonce             string       `json:"nonce"`         //ulong = uint64
	Nextconsensus     string       `json:"nextconsensus"` //address
	CrossStatesRoot   util.Uint256 `json:"crossstatesroot"`
	ChainID           string       `json:"chainid"` //ulong = uint64
	Script            struct {
		InvocationScript   string `json:"invocation"`
		VerificationScript string `json:"verification"`
	} `json:"script"`
	Confirmations int `json:"confirmations"`
}

BlockHeader for neo

func (*BlockHeader) DeserializeUnsigned

func (bh *BlockHeader) DeserializeUnsigned(br *io.BinReader)

DeserializeUnsigned deserialize blockheader without witness

func (*BlockHeader) DeserializeWitness

func (bh *BlockHeader) DeserializeWitness(br *io.BinReader)

DeserializeWitness deserialize witness

func (*BlockHeader) SerializeUnsigned

func (bh *BlockHeader) SerializeUnsigned(bw *io.BufBinWriter)

SerializeUnsigned serialize blockheader without witness

func (*BlockHeader) SerializeWitness

func (bh *BlockHeader) SerializeWitness(bw *io.BufBinWriter)

SerializeWitness serialize witness

func (*BlockHeader) ToBlockHeader

func (bh *BlockHeader) ToBlockHeader(rawBlock []byte)

ToBlockHeader deserialize bytes to blockHeader

func (*BlockHeader) ToBytes

func (bh *BlockHeader) ToBytes() []byte

ToBytes conver blockheader to bytes

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

type GetAccountStateBalance

type GetAccountStateBalance struct {
	Asset string `json:"asset"`
	Value string `json:"value"`
}

type GetAccountStateResponse

type GetAccountStateResponse struct {
	JSONRPCResponse
	*ErrorResponse                       //optional
	Result         GetAccountStateResult `json:"result"`
}

type GetAccountStateResult

type GetAccountStateResult struct {
	Version    int                      `json:"version"`
	ScriptHash string                   `json:"script_hash"`
	Frozen     bool                     `json:"frozen"`
	Votes      []interface{}            `json:"votes"`
	Balances   []GetAccountStateBalance `json:"balances"`
}

type GetApplicationLogResponse

type GetApplicationLogResponse struct {
	JSONRPCResponse
	*ErrorResponse
	Result struct {
		TxId       string `json:"txid"`
		Executions []struct {
			Trigger     string `json:"trigger"`
			Contract    string `json:"contract"`
			VMState     string `json:"vmstate"`
			GasConsumed string `json:"gas_consumed"`
			Stack       []struct {
				Type  string `json:"type"`
				Value string `json:"value"`
			} `json:"stack"`
			Notifications []struct {
				Contract string `json:"contract"`
				State    struct {
					Type string `json:"type"`
					//Value []interface{} `json:"value"`
					Value []struct {
						Type  string `json:"type"`
						Value string `json:"value"`
					}
				} `json:"state"`
			} `json:"notifications"`
		} `json:"executions"`
	} `json:"result"`
}

type GetBlockCountResponse

type GetBlockCountResponse struct {
	JSONRPCResponse
	*ErrorResponse     //optional
	Result         int `json:"result"`
}

type GetBlockHeaderResponse

type GetBlockHeaderResponse struct {
	JSONRPCResponse
	*ErrorResponse             //optional
	Result         BlockHeader `json:"result"`
}

type GetBlockResponse

type GetBlockResponse struct {
	JSONRPCResponse
	*ErrorResponse       //optional
	Result         Block `json:"result"`
}

type GetContractStateResponse

type GetContractStateResponse struct {
	JSONRPCResponse
	*ErrorResponse                        //optional
	Result         GetContractStateResult `json:"result"`
}

type GetContractStateResult

type GetContractStateResult struct {
	Version     int      `json:"version"`
	Hash        string   `json:"hash"`
	Script      string   `json:"script"`
	Parameters  []string `json:"parameters"`
	Returntype  string   `json:"returntype"`
	Name        string   `json:"name"`
	CodeVersion string   `json:"code_version"`
	Author      string   `json:"author"`
	Email       string   `json:"email"`
	Description string   `json:"description"`
	Properties  struct {
		Storage       bool `json:"storage"`
		DynamicInvoke bool `json:"dynamic_invoke"`
	} `json:"properties"`
}

type GetCrosschainProofResponse

type GetCrosschainProofResponse struct {
	JSONRPCResponse
	*ErrorResponse         //optional
	CrosschainProof string `json:"result"`
}

type GetRawTransactionResponse

type GetRawTransactionResponse struct {
	JSONRPCResponse
	*ErrorResponse                         //optional
	Result         GetRawTransactionResult `json:"result"`
}

type GetRawTransactionResult

type GetRawTransactionResult struct {
	Txid       string `json:"txid"`
	Size       int    `json:"size"`
	Type       string `json:"type"`
	Version    int    `json:"version"`
	Attributes []struct {
		Usage string `json:"usage"`
		Data  string `json:"data"`
	} `json:"attributes"`
	Vin []struct {
		Txid string `json:"txid"`
		Vout int    `json:"vout"`
	} `json:"vin"`
	Vout []struct {
		N       int    `json:"n"`
		Asset   string `json:"asset"`
		Value   string `json:"value"`
		Address string `json:"address"`
	} `json:"vout"`
	Claims []struct {
		Txid string `json:"txid"`
		Vout int    `json:"vout"`
	} `json:"claims"`
	SysFee  string `json:"sys_fee"`
	NetFee  string `json:"net_fee"`
	Scripts []struct {
		Invocation   string `json:"invocation"`
		Verification string `json:"verification"`
	} `json:"scripts"`
	Script        string `json:"script"`
	Gas           string `json:"gas"`
	Blockhash     string `json:"blockhash"`
	Confirmations int    `json:"confirmations"`
	Blocktime     int    `json:"blocktime"`
}

type GetStorageResponse

type GetStorageResponse struct {
	JSONRPCResponse
	*ErrorResponse
	Result string `json:"result"`
}

type GetUnspentsResponse

type GetUnspentsResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      int    `json:"id"`
	Result  struct {
		Balance []struct {
			Unspent []struct {
				Txid  string `json:"txid"`
				N     int    `json:"n"`
				Value int    `json:"value"`
			} `json:"unspent"`
			AssetHash   string `json:"asset_hash"`
			Asset       string `json:"asset"`
			AssetSymbol string `json:"asset_symbol"`
			Amount      int    `json:"amount"`
		} `json:"balance"`
		Address string `json:"address"`
	} `json:"result"`
}

type InvokeFunctionResponse

type InvokeFunctionResponse struct {
	JSONRPCResponse
	*ErrorResponse
	Result struct {
		Script      string                      `json:"script"`
		State       string                      `json:"state"`
		GasConsumed string                      `json:"gas_consumed"`
		Stack       []InvokeFunctionStackResult `json:"stack"`
	} `json:"result"`
}

type InvokeFunctionStackArg

type InvokeFunctionStackArg struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

func NewInvokeFunctionStackArg

func NewInvokeFunctionStackArg(t string, v string) InvokeFunctionStackArg

func NewInvokeFunctionStackByteArray

func NewInvokeFunctionStackByteArray(value string) InvokeFunctionStackArg

type InvokeFunctionStackResult

type InvokeFunctionStackResult struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type InvokeScriptResponse

type InvokeScriptResponse struct {
	JSONRPCResponse
	*ErrorResponse
	Result struct {
		Script      string `json:"script"`
		State       string `json:"state"`
		GasConsumed string `json:"gas_consumed"`
		Stack       []struct {
			Type  string `json:"type"`
			Value string `json:"value"`
		} `json:"stack"`
	} `json:"result"`
}

type JSONRPCRequest

type JSONRPCRequest struct {
	Jsonrpc string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	ID      int           `json:"id"`
}

func NewRequest

func NewRequest(method string, params []interface{}) JSONRPCRequest

type JSONRPCResponse

type JSONRPCResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      int    `json:"id"`
}

type NEORPCClient

type NEORPCClient struct {
	Endpoint url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) *NEORPCClient

func (*NEORPCClient) GetAccountState

func (n *NEORPCClient) GetAccountState(address string) GetAccountStateResponse

func (*NEORPCClient) GetApplicationLog

func (n *NEORPCClient) GetApplicationLog(txID string) GetApplicationLogResponse

func (*NEORPCClient) GetBlock

func (n *NEORPCClient) GetBlock(blockHash string) GetBlockResponse

func (*NEORPCClient) GetBlockByIndex

func (n *NEORPCClient) GetBlockByIndex(index uint32) GetBlockResponse

func (*NEORPCClient) GetBlockCount

func (n *NEORPCClient) GetBlockCount() GetBlockCountResponse

func (*NEORPCClient) GetBlockHeaderByIndex

func (n *NEORPCClient) GetBlockHeaderByIndex(index uint32) GetBlockHeaderResponse

func (*NEORPCClient) GetContractState

func (n *NEORPCClient) GetContractState(scripthash string) GetContractStateResponse

func (*NEORPCClient) GetCrosschainProof

func (n *NEORPCClient) GetCrosschainProof(blockIndex int, txID string) GetCrosschainProofResponse

func (*NEORPCClient) GetRawTransaction

func (n *NEORPCClient) GetRawTransaction(txID string) GetRawTransactionResponse

func (*NEORPCClient) GetStorage

func (n *NEORPCClient) GetStorage(scripthash string, key string) GetStorageResponse

func (*NEORPCClient) GetTokenBalance

func (n *NEORPCClient) GetTokenBalance(tokenHash string, neoAddress string) TokenBalanceResponse

func (*NEORPCClient) GetUnspents

func (n *NEORPCClient) GetUnspents(adddress string) GetUnspentsResponse

func (*NEORPCClient) InvokeFunction

func (n *NEORPCClient) InvokeFunction(scriptHash string, method string, args []interface{}) InvokeFunctionResponse

func (*NEORPCClient) InvokeScript

func (n *NEORPCClient) InvokeScript(scriptInHex string) InvokeScriptResponse

func (*NEORPCClient) SendRawTransaction

func (n *NEORPCClient) SendRawTransaction(rawTransactionInHex string) SendRawTransactionResponse

type NEORPCInterface

type NEORPCInterface interface {
	GetContractState(scripthash string) GetContractStateResponse
	SendRawTransaction(rawTransactionInHex string) SendRawTransactionResponse
	GetRawTransaction(txID string) GetRawTransactionResponse

	GetBlockCount() GetBlockCountResponse
	GetBlock(blockHash string) GetBlockResponse
	GetBlockByIndex(index uint32) GetBlockResponse
	GetAccountState(address string) GetAccountStateResponse
	InvokeScript(scriptInHex string) InvokeScriptResponse
	InvokeFunction(scriptHash string, method string, params []interface{}) InvokeFunctionResponse
	GetTokenBalance(tokenHash string, adddress string) TokenBalanceResponse
	GetUnspents(adddress string) GetUnspentsResponse

	GetStorage(scripthash string, key string) GetStorageResponse
	GetApplicationLog(txID string) GetApplicationLogResponse
	GetCrosschainProof(blockIndex int, txID string) GetCrosschainProofResponse
	// contains filtered or unexported methods
}

type SendRawTransactionResponse

type SendRawTransactionResponse struct {
	JSONRPCResponse
	*ErrorResponse //optional
	Result         bool
}

type TokenBalanceResponse

type TokenBalanceResponse struct {
	JSONRPCResponse
	*ErrorResponse                    //optional
	Result         TokenBalanceResult `json:"result"`
}

type TokenBalanceResult

type TokenBalanceResult struct {
	Script      string                      `json:"script"`
	State       string                      `json:"state"`
	GasConsumed string                      `json:"gas_consumed"`
	Stack       []InvokeFunctionStackResult `json:"stack"`
	Tx          string                      `json:"tx"`
}

Jump to

Keyboard shortcuts

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