api

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: AGPL-3.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SUCCESS indicates the rpc calling is successful.
	SUCCESS = "success"
	// FAIL indicated the rpc calling is failed.
	FAIL = "fail"
)

Variables

View Source
var (
	ErrNullContract      = errors.New("contract is empty")
	ErrNullContractID    = errors.New("contract id is empty")
	ErrNullContractAlias = errors.New("contract alias is empty")
)

pre-define errors for supporting bytom errorFormatter

View Source
var (
	ErrBadActionType         = errors.New("bad action type")
	ErrBadAction             = errors.New("bad action object")
	ErrBadActionConstruction = errors.New("bad action construction")
)

action error

View Source
var (
	// ErrDefault is default Bytom API Error
	ErrDefault = errors.New("Bytom API Error")
)

Functions

func AuthHandler

func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore, authDisable bool) http.Handler

AuthHandler access token auth Handler

func RedirectHandler

func RedirectHandler(next http.Handler) http.Handler

RedirectHandler redirect to dashboard 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, wallet *wallet.Wallet, blockProposer *blockproposer.BlockProposer, chain *protocol.Chain, traceService *contract.TraceService, config *cfg.Config, token *accesstoken.CredentialStore, dispatcher *event.Dispatcher, notificationMgr *websocket.WSNotificationManager) *API

NewAPI create and initialize the API

func (*API) GetChainStatus added in v1.2.1

func (a *API) GetChainStatus() (*ChainStatus, error)

GetChainStatus return chain status

func (*API) IsMining added in v0.4.3

func (a *API) IsMining() bool

IsMining return mining status

func (*API) ServeHTTP

func (a *API) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*API) StartServer

func (a *API) StartServer(address string)

StartServer start the server

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 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"`
	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 ChainStatus added in v1.2.1

type ChainStatus struct {
	CurrentHeight   uint64 `json:"current_height"`
	CurrentHash     string `json:"current_hash"`
	FinalizedHeight uint64 `json:"finalized_height"`
	FinalizedHash   string `json:"finalized_hash"`
	JustifiedHeight uint64 `json:"justified_height"`
	JustifiedHash   string `json:"justified_hash"`
}

ChainStatus indicate chain status

type CheckPasswordResp added in v1.0.5

type CheckPasswordResp struct {
	CheckResult bool `json:"check_result"`
}

CheckPasswordResp is response for check key password

type ContractInstance added in v1.2.1

type ContractInstance struct {
	UTXOs       []*contract.UTXO     `json:"utxos"`
	TxHash      *bc.Hash             `json:"tx_hash"`
	Status      contract.Status      `json:"status"`
	Unconfirmed []*contract.TreeNode `json:"unconfirmed"`
}

type DecodeProgResp added in v1.0.3

type DecodeProgResp struct {
	Instructions string `json:"instructions"`
}

DecodeProgResp is response for decode program

type GetBlockHeaderResp added in v0.5.1

type GetBlockHeaderResp struct {
	BlockHeader *types.BlockHeader `json:"block_header"`
}

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"`
	Validator              string     `json:"validator"`
	PreviousBlockHash      *bc.Hash   `json:"previous_block_hash"`
	Timestamp              uint64     `json:"timestamp"`
	TransactionsMerkleRoot *bc.Hash   `json:"transaction_merkle_root"`
	Transactions           []*BlockTx `json:"transactions"`
}

GetBlockResp is the resp for getBlock api

type GetMerkleBlockResp added in v1.0.7

type GetMerkleBlockResp struct {
	BlockHeader  types.BlockHeader `json:"block_header"`
	TxHashes     []*bc.Hash        `json:"tx_hashes"`
	Flags        []uint32          `json:"flags"`
	MatchedTxIDs []*bc.Hash        `json:"matched_tx_ids"`
}

GetMerkleBlockResp is resp struct for GetTxOutProof API

type GetRawBlockResp added in v1.0.7

type GetRawBlockResp struct {
	RawBlock  *types.Block `json:"raw_block"`
	Validator string       `json:"validator"`
}

GetRawBlockResp is resp struct for getRawBlock API

type MerkleBlockReq added in v1.0.7

type MerkleBlockReq struct {
	TxIDs     []chainjson.HexBytes `json:"tx_ids"`
	BlockHash chainjson.HexBytes   `json:"block_hash"`
}

MerkleBlockReq is used to handle getTxOutProof req

type NetInfo added in v0.4.3

type NetInfo struct {
	Listening     bool         `json:"listening"`
	Syncing       bool         `json:"syncing"`
	Mining        bool         `json:"mining"`
	NodeXPub      string       `json:"node_xpub"`
	PeerCount     int          `json:"peer_count"`
	HighestHeight uint64       `json:"highest_height"`
	NetWorkID     string       `json:"network_id"`
	Version       *VersionInfo `json:"version_info"`
}

NetInfo indicate net information

type NetSync added in v1.0.8

type NetSync interface {
	IsListening() bool
	IsCaughtUp() bool
	PeerCount() int
	GetNetwork() string
	BestPeer() *peers.PeerInfo
	DialPeerWithAddress(addr *p2p.NetAddress) error
	GetPeerInfos() []*peers.PeerInfo
	StopPeer(peerID string) error
}

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 {
	ID        bc.Hash                  `json:"tx_id"`
	Version   uint64                   `json:"version"`
	Size      uint64                   `json:"size"`
	TimeRange uint64                   `json:"time_range"`
	Inputs    []*query.AnnotatedInput  `json:"inputs"`
	Outputs   []*query.AnnotatedOutput `json:"outputs"`
	Fee       uint64                   `json:"fee"`
}

RawTx is the tx struct for getRawTransaction

type ResetPasswordResp

type ResetPasswordResp struct {
	Changed bool `json:"changed"`
}

ResetPasswordResp is response for reset key 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

func FormatErrResp(err error) (response Response)

FormatErrResp format error response

func NewErrorResponse

func NewErrorResponse(err error) Response

NewErrorResponse 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 VerifyMsgResp added in v1.0.2

type VerifyMsgResp struct {
	VerifyResult bool `json:"result"`
}

VerifyMsgResp is response for verify message

type VersionInfo added in v1.0.5

type VersionInfo struct {
	Version string `json:"version"`
	Update  uint16 `json:"update"` // 0: no update; 1: small update; 2: significant update
	NewVer  string `json:"new_version"`
}

type VoteInfo added in v1.2.1

type VoteInfo struct {
	Vote    string `json:"vote"`
	VoteNum uint64 `json:"vote_number"`
}

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

Jump to

Keyboard shortcuts

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