Documentation ¶
Overview ¶
Package error privides error code for rest
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
Package restful privides restful server router ¶
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2020 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func PackResponse(errCode uint32) map[string]interface{}
- type Action
- type ApiServer
- type BroadcastTxReq
- type ChangeAddressReq
- type GetAllUtxosResp
- type GetFeePerByteReq
- type QueryHeaderByHeightParam
- type QueryUtxosReq
- type Response
- type ResponseAllUtxos
- type RestClient
- func (self *RestClient) BroadcastTxBySpv(mtx *wire.MsgTx) error
- func (self *RestClient) ChangeSpvWatchedAddr(addr string, action string) error
- func (self *RestClient) GetAllUtxosFromSpv() ([]UtxoInfo, error)
- func (self *RestClient) GetCurrentHeightFromSpv() (uint32, error)
- func (self *RestClient) GetFeeRateFromSpv(level int) (int64, error)
- func (self *RestClient) GetHeaderFromSpv(height uint32) (*wire.BlockHeader, error)
- func (self *RestClient) GetUtxosFromSpv(addr string, amount int64, fee int64, isPreExec bool) ([]btcjson.TransactionInput, int64, error)
- func (self *RestClient) GetWatchedAddrsFromSpv() ([]string, error)
- func (self *RestClient) RollbackSpv(time string) error
- func (self *RestClient) SendGetRequst(addr string) ([]byte, error)
- func (self *RestClient) SendRestRequest(addr string, data []byte) ([]byte, error)
- func (self *RestClient) SetAddr(addr string) *RestClient
- func (self *RestClient) SetRestClient(restClient *http.Client) *RestClient
- func (self *RestClient) UnlockUtxoInSpv(hash string, index uint32) error
- type RollbackReq
- type Route
- type Router
- func (r *Router) Connect(path string, handler http.HandlerFunc)
- func (r *Router) Delete(path string, handler http.HandlerFunc)
- func (r *Router) Get(path string, handler http.HandlerFunc)
- func (r *Router) Head(path string, handler http.HandlerFunc)
- func (r *Router) Options(path string, handler http.HandlerFunc)
- func (r *Router) Post(path string, handler http.HandlerFunc)
- func (r *Router) Put(path string, handler http.HandlerFunc)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (this *Router) Try(path string, method string) (http.HandlerFunc, paramsMap, error)
- type UnlockUtxoReq
- type UtxoInfo
- type Web
Constants ¶
Variables ¶
var ErrMap = map[uint32]string{ SUCCESS: "SUCCESS", FAILED: "FAILED", INVALID_METHOD: "INVALID METHOD", INVALID_PARAMS: "INVALID PARAMS", ILLEGAL_DATAFORMAT: "ILLEGAL DATAFORMAT", INTERNAL_ERROR: "INTERNAL_ERROR", }
Functions ¶
func PackResponse ¶
Types ¶
type BroadcastTxReq ¶
type BroadcastTxReq struct {
RawTx string `json:"raw_tx"`
}
type ChangeAddressReq ¶
type GetAllUtxosResp ¶
type GetAllUtxosResp struct {
Infos []UtxoInfo `json:"infos"`
}
type GetFeePerByteReq ¶
type GetFeePerByteReq struct {
Level int `json:"level"`
}
type QueryHeaderByHeightParam ¶
type QueryHeaderByHeightParam struct {
Height uint32 `json:"height"`
}
type QueryUtxosReq ¶
type Response ¶
type Response struct { Action string `json:"action"` Desc string `json:"desc"` Error uint32 `json:"error"` Result interface{} `json:"result"` }
response
type ResponseAllUtxos ¶
type ResponseAllUtxos struct { Action string `json:"action"` Desc string `json:"desc"` Error uint32 `json:"error"` Result GetAllUtxosResp `json:"result"` }
type RestClient ¶
type RestClient struct { Addr string // contains filtered or unexported fields }
func NewRestClient ¶
func NewRestClient(addr string) *RestClient
func (*RestClient) BroadcastTxBySpv ¶
func (self *RestClient) BroadcastTxBySpv(mtx *wire.MsgTx) error
func (*RestClient) ChangeSpvWatchedAddr ¶
func (self *RestClient) ChangeSpvWatchedAddr(addr string, action string) error
func (*RestClient) GetAllUtxosFromSpv ¶
func (self *RestClient) GetAllUtxosFromSpv() ([]UtxoInfo, error)
func (*RestClient) GetCurrentHeightFromSpv ¶
func (self *RestClient) GetCurrentHeightFromSpv() (uint32, error)
func (*RestClient) GetFeeRateFromSpv ¶
func (self *RestClient) GetFeeRateFromSpv(level int) (int64, error)
func (*RestClient) GetHeaderFromSpv ¶
func (self *RestClient) GetHeaderFromSpv(height uint32) (*wire.BlockHeader, error)
func (*RestClient) GetUtxosFromSpv ¶
func (self *RestClient) GetUtxosFromSpv(addr string, amount int64, fee int64, isPreExec bool) ([]btcjson.TransactionInput, int64, error)
func (*RestClient) GetWatchedAddrsFromSpv ¶
func (self *RestClient) GetWatchedAddrsFromSpv() ([]string, error)
func (*RestClient) RollbackSpv ¶
func (self *RestClient) RollbackSpv(time string) error
func (*RestClient) SendGetRequst ¶
func (self *RestClient) SendGetRequst(addr string) ([]byte, error)
func (*RestClient) SendRestRequest ¶
func (self *RestClient) SendRestRequest(addr string, data []byte) ([]byte, error)
func (*RestClient) SetAddr ¶
func (self *RestClient) SetAddr(addr string) *RestClient
func (*RestClient) SetRestClient ¶
func (self *RestClient) SetRestClient(restClient *http.Client) *RestClient
func (*RestClient) UnlockUtxoInSpv ¶
func (self *RestClient) UnlockUtxoInSpv(hash string, index uint32) error
type RollbackReq ¶
type RollbackReq struct {
Time string `json:"time"`
}