Documentation
¶
Index ¶
- Constants
- func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore) http.Handler
- func RedirectHandler(next http.Handler) http.Handler
- type API
- func (a *API) GetNodeInfo() *NetInfo
- func (a *API) GetTxFeedByAlias(ctx context.Context, filter string) ([]byte, error)
- func (a *API) GetWork() (*GetWorkResp, error)
- func (a *API) GetWorkJSON() (*GetWorkJSONResp, error)
- func (a *API) IsMining() bool
- func (a *API) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (a *API) StartServer(address string)
- func (a *API) SubmitWork(bh *types.BlockHeader) error
- type AccountInfo
- type AccountPubkey
- type BlockHeaderJSON
- type BlockReq
- type BlockTx
- type BuildRequest
- type DecodeProgResp
- type EstimateTxGasResp
- type GetBlockHeaderResp
- type GetBlockResp
- type GetDifficultyResp
- type GetWorkJSONResp
- type GetWorkResp
- type NetInfo
- type PubKeyInfo
- type RawTx
- type ResetPasswordResp
- type Response
- type SignMsgResp
- type SortByIndex
- type SubmitWorkJSONReq
- type SubmitWorkReq
- type VerifyMsgResp
- type WalletImage
- type WalletInfo
Constants ¶
const ( // SUCCESS indicates the rpc calling is successful. SUCCESS = "success" // FAIL indicated the rpc calling is failed. FAIL = "fail" )
Variables ¶
This section is empty.
Functions ¶
func AuthHandler ¶
func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore) http.Handler
AuthHandler access token auth Handler
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the scheduling center for server
func NewAPI ¶
func NewAPI(sync *netsync.SyncManager, wallet *wallet.Wallet, txfeeds *txfeed.Tracker, cpuMiner *cpuminer.CPUMiner, miningPool *miningpool.MiningPool, chain *protocol.Chain, config *cfg.Config, token *accesstoken.CredentialStore) *API
NewAPI create and initialize the API
func (*API) GetNodeInfo ¶ added in v0.4.3
GetNodeInfo return net information
func (*API) GetTxFeedByAlias ¶ added in v0.4.3
func (*API) GetWork ¶ added in v0.4.3
func (a *API) GetWork() (*GetWorkResp, error)
GetWork gets work in compressed protobuf format
func (*API) GetWorkJSON ¶ added in v1.0.3
func (a *API) GetWorkJSON() (*GetWorkJSONResp, error)
GetWorkJSON gets work in json format
func (*API) SubmitWork ¶ added in v0.4.3
func (a *API) SubmitWork(bh *types.BlockHeader) error
SubmitWork tries to submit work to the chain
type AccountInfo ¶ added in v0.5.0
type AccountInfo struct {
Info string `json:"account_info"`
}
AccountInfo is request struct for deleteAccount
type AccountPubkey ¶ added in v1.0.4
type AccountPubkey struct { RootXPub chainkd.XPub `json:"root_xpub"` PubKeyInfos []PubKeyInfo `json:"pubkey_infos"` }
AccountPubkey is detail of account pubkey info
type BlockHeaderJSON ¶ added in v1.0.3
type BlockHeaderJSON struct { Version uint64 `json:"version"` // The version of the block. Height uint64 `json:"height"` // The height of the block. PreviousBlockHash bc.Hash `json:"previous_block_hash"` // The hash of the previous block. Timestamp uint64 `json:"timestamp"` // The time of the block in seconds. Nonce uint64 `json:"nonce"` // Nonce used to generate the block. Bits uint64 `json:"bits"` // Difficulty target for the block. BlockCommitment *types.BlockCommitment `json:"block_commitment"` //Block commitment }
BlockHeaderJSON struct provides support for get work in json format, when it also follows BlockHeader structure
type BlockReq ¶ added in v0.5.1
type BlockReq struct { BlockHeight uint64 `json:"block_height"` BlockHash chainjson.HexBytes `json:"block_hash"` }
BlockReq is used to handle getBlock req
type BlockTx ¶
type BlockTx struct { ID bc.Hash `json:"id"` Version uint64 `json:"version"` Size uint64 `json:"size"` TimeRange uint64 `json:"time_range"` Inputs []*query.AnnotatedInput `json:"inputs"` Outputs []*query.AnnotatedOutput `json:"outputs"` StatusFail bool `json:"status_fail"` MuxID bc.Hash `json:"mux_id"` }
BlockTx is the tx struct for getBlock func
type BuildRequest ¶
type BuildRequest struct { Tx *types.TxData `json:"base_transaction"` Actions []map[string]interface{} `json:"actions"` TTL json.Duration `json:"ttl"` TimeRange uint64 `json:"time_range"` }
BuildRequest is main struct when building transactions
type DecodeProgResp ¶ added in v1.0.3
type DecodeProgResp struct {
Instructions string `json:"instructions"`
}
DecodeProgResp is response for decode program
type EstimateTxGasResp ¶ added in v0.4.7
type EstimateTxGasResp struct { TotalNeu int64 `json:"total_neu"` StorageNeu int64 `json:"storage_neu"` VMNeu int64 `json:"vm_neu"` }
EstimateTxGasResp estimate transaction consumed gas
func EstimateTxGas ¶ added in v1.0.2
func EstimateTxGas(template txbuilder.Template) (*EstimateTxGasResp, error)
EstimateTxGas estimate consumed neu for transaction
type GetBlockHeaderResp ¶ added in v0.5.1
type GetBlockHeaderResp struct { BlockHeader *types.BlockHeader `json:"block_header"` Reward uint64 `json:"reward"` }
GetBlockHeaderResp is resp struct for getBlockHeader API
type GetBlockResp ¶
type GetBlockResp struct { Hash *bc.Hash `json:"hash"` Size uint64 `json:"size"` Version uint64 `json:"version"` Height uint64 `json:"height"` PreviousBlockHash *bc.Hash `json:"previous_block_hash"` Timestamp uint64 `json:"timestamp"` Nonce uint64 `json:"nonce"` Bits uint64 `json:"bits"` Difficulty string `json:"difficulty"` TransactionsMerkleRoot *bc.Hash `json:"transaction_merkle_root"` TransactionStatusHash *bc.Hash `json:"transaction_status_hash"` Transactions []*BlockTx `json:"transactions"` }
GetBlockResp is the resp for getBlock api
type GetDifficultyResp ¶ added in v1.0.1
type GetDifficultyResp struct { BlockHash *bc.Hash `json:"hash"` BlockHeight uint64 `json:"height"` Bits uint64 `json:"bits"` Difficulty string `json:"difficulty"` }
GetDifficultyResp is resp struct for getDifficulty API
type GetWorkJSONResp ¶ added in v1.0.3
type GetWorkJSONResp struct { BlockHeader *BlockHeaderJSON `json:"block_header"` Seed *bc.Hash `json:"seed"` }
GetWorkJSONResp is resp struct for get-work-json API
type GetWorkResp ¶ added in v0.4.3
type GetWorkResp struct { BlockHeader *types.BlockHeader `json:"block_header"` Seed *bc.Hash `json:"seed"` }
GetWorkResp is resp struct for get-work API
type NetInfo ¶ added in v0.4.3
type NetInfo struct { Listening bool `json:"listening"` Syncing bool `json:"syncing"` Mining bool `json:"mining"` PeerCount int `json:"peer_count"` CurrentBlock uint64 `json:"current_block"` HighestBlock uint64 `json:"highest_block"` NetWorkID string `json:"network_id"` Version string `json:"version"` }
NetInfo indicate net information
type PubKeyInfo ¶ added in v1.0.4
type PubKeyInfo struct { Pubkey string `json:"pubkey"` Path []chainjson.HexBytes `json:"derivation_path"` }
PubKeyInfo is structure of pubkey info
type RawTx ¶ added in v1.0.2
type RawTx struct { Version uint64 `json:"version"` Size uint64 `json:"size"` TimeRange uint64 `json:"time_range"` Inputs []*query.AnnotatedInput `json:"inputs"` Outputs []*query.AnnotatedOutput `json:"outputs"` Fee int64 `json:"fee"` }
RawTx is the tx struct for getRawTransaction
type ResetPasswordResp ¶
type ResetPasswordResp struct {
Changed bool `json:"changed"`
}
ResetPasswordResp is response for reset password password
type Response ¶
type Response struct { Status string `json:"status,omitempty"` Code string `json:"code,omitempty"` Msg string `json:"msg,omitempty"` ErrorDetail string `json:"error_detail,omitempty"` Data interface{} `json:"data,omitempty"` }
Response describes the response standard.
func FormatErrResp ¶ added in v1.0.3
FormatErrResp format error response
func NewSuccessResponse ¶
func NewSuccessResponse(data interface{}) Response
NewSuccessResponse success response
type SignMsgResp ¶ added in v1.0.2
type SignMsgResp struct { Signature string `json:"signature"` DerivedXPub chainkd.XPub `json:"derived_xpub"` }
SignMsgResp is response for sign message
type SortByIndex ¶ added in v1.0.3
type SortByIndex []addressResp
SortByIndex implements sort.Interface for addressResp slices
func (SortByIndex) Len ¶ added in v1.0.3
func (a SortByIndex) Len() int
func (SortByIndex) Less ¶ added in v1.0.3
func (a SortByIndex) Less(i, j int) bool
func (SortByIndex) Swap ¶ added in v1.0.3
func (a SortByIndex) Swap(i, j int)
type SubmitWorkJSONReq ¶ added in v1.0.3
type SubmitWorkJSONReq struct {
BlockHeader *BlockHeaderJSON `json:"block_header"`
}
SubmitWorkJSONReq is req struct for submit-work-json API
type SubmitWorkReq ¶ added in v0.4.2
type SubmitWorkReq struct {
BlockHeader *types.BlockHeader `json:"block_header"`
}
SubmitWorkJSONReq is req struct for submit-work API
type VerifyMsgResp ¶ added in v1.0.2
type VerifyMsgResp struct {
VerifyResult bool `json:"result"`
}
VerifyMsgResp is response for verify message
type WalletImage ¶ added in v0.5.0
type WalletImage struct { AccountImage *account.Image `json:"account_image"` AssetImage *asset.Image `json:"asset_image"` KeyImages *pseudohsm.KeyImage `json:"key_images"` }
WalletImage hold the ziped wallet data
type WalletInfo ¶ added in v1.0.4
type WalletInfo struct { BestBlockHeight uint64 `json:"best_block_height"` WalletHeight uint64 `json:"wallet_height"` }
WalletInfo return wallet information