Documentation
¶
Index ¶
- Constants
- Variables
- func GetAcceptHeaderContentType(c echo.Context, supportedContentTypes ...string) (string, error)
- func GetRequestContentType(c echo.Context, supportedContentTypes ...string) (string, error)
- func GetURL(protocol string, host string, port uint16, path ...string) string
- func JSONResponse(c echo.Context, statusCode int, result interface{}) error
- func LoadOrCreateIdentityPrivateKey(privKeyFilePath string, identityPrivKey string) (libp2pcrypto.PrivKey, bool, error)
- func NewEcho(logger *logger.Logger, onHTTPError func(err error, c echo.Context), ...) *echo.Echo
- func ParseBoolQueryParam(c echo.Context, paramName string) (bool, error)
- func ParseMilestoneIndexParam(c echo.Context, paramName string) (uint64, error)
- func ParseUint32QueryParam(c echo.Context, paramName string, maxValue ...uint32) (uint32, error)
- func ParseUnixTimestampQueryParam(c echo.Context, paramName string) (time.Time, error)
- type AddNeighbors
- type AddNeighborsHornet
- type AddNeighborsResponse
- type AddressWithBalance
- type ApproverStruct
- type AttachToTangle
- type AttachToTangleResponse
- type BroadcastTransactions
- type BroadcastTransactionsResponse
- type BundleWithValue
- type CheckConsistencyResponse
- type Container
- type CreateSnapshotFile
- type CreateSnapshotFileResponse
- type DebugRequest
- type EntryPoint
- type ErrorReturn
- type FindTransactions
- type FindTransactionsResponse
- type GetBalances
- type GetBalancesResponse
- type GetFundsOnSpentAddressesResponse
- type GetInclusionStates
- type GetInclusionStatesResponse
- type GetLedgerDiff
- type GetLedgerDiffExt
- type GetLedgerDiffExtResponse
- type GetLedgerDiffResponse
- type GetLedgerState
- type GetLedgerStateResponse
- type GetMigration
- type GetNeighborsResponse
- type GetNodeAPIConfigurationResponse
- type GetNodeInfoResponse
- type GetRequestsResponse
- type GetTipInfo
- type GetTipInfoResponse
- type GetTransactionsToApprove
- type GetTransactionsToApproveResponse
- type GetTrytes
- type GetTrytesResponse
- type GetWhiteFlagConfirmationResponse
- type HTTPErrorResponse
- type HTTPErrorResponseEnvelope
- type Neighbor
- type PruneDatabase
- type PruneDatabaseResponse
- type RemoveNeighbors
- type RemoveNeighborsResponse
- type Request
- type SearchConfirmedApprover
- type SearchConfirmedApproverResponse
- type SearchEntryPoint
- type SearchEntryPointResponse
- type StoreTransactions
- type TransactionWithApprovers
- type TxHashWithValue
- type TxWithValue
- type WebAPIServer
- type WereAddressesSpentFrom
- type WereAddressesSpentFromResponse
Constants ¶
const ( MIMEApplicationVendorIOTASerializerV1 = "application/vnd.iota.serializer-v1" ProtocolHTTP = "http" ProtocolHTTPS = "https" ProtocolWS = "ws" ProtocolWSS = "wss" )
const ( ParameterAddress = "address" ParameterTransactionHash = "txHash" ParameterMilestoneIndex = "index" QueryParameterBundle = "bundle" QueryParameterAddress = "address" QueryParameterTag = "tag" QueryParameterApprovee = "approvee" QueryParameterMaxResults = "maxResults" )
const ( // RouteRPCEndpoint is the route for sending RPC requests to the API. // POST sends an IOTA legacy API request and returns the results. RouteRPCEndpoint = "/" // RouteInfo is the route for getting the node info. // GET returns the node info. RouteInfo = "/info" // RouteMilestoneByIndex is the route for getting a milestone by its milestoneIndex. // GET will return the milestone. RouteMilestoneByIndex = "/milestones/by-index/:" + ParameterMilestoneIndex // RouteTransactions is the route for getting transactions filtered by the given parameters. // GET with query parameter returns all txHashes that fit these filter criteria. // Query parameters: "bundle", "address", "tag", "approvee", "maxResults" // Returns an empty list if no results are found. RouteTransactions = "/transactions" // former findTransactions // RouteTransaction is the route for getting a transaction. // GET will return the transaction. RouteTransaction = "/transactions/:" + ParameterTransactionHash // RouteTransactionTrytes is the route for getting the trytes of a transaction. // GET will return the transaction trytes. RouteTransactionTrytes = "/transactions/:" + ParameterTransactionHash + "/trytes" // former getTrytes // RouteTransactionMetadata is the route for getting the metadata of a transaction. // GET will return the metadata. RouteTransactionMetadata = "/transactions/:" + ParameterTransactionHash + "/metadata" // former getInclusionStates // RouteAddressBalance is the route for getting the balance of an address. // GET will return the balance. RouteAddressBalance = "/addresses/:" + ParameterAddress + "/balance" // former getBalances // RouteAddressBalance is the route to check whether an address was already spent or not. // GET will return true if the address was already spent. RouteAddressWasSpent = "/addresses/:" + ParameterAddress + "/was-spent" // former wereAddressesSpentFrom // RouteLedgerState is the route to return the current ledger state. // GET will return all addresses with their balances. RouteLedgerState = "/ledger/state" // former getLedgerState // RouteLedgerStateNonMigrated is the route to return the current non-migrated ledger state. // GET will return all non-migrated addresses with their balances. RouteLedgerStateNonMigrated = "/ledger/state/non-migrated" // RouteLedgerStateByIndex is the route to return the ledger state of a given ledger index. // GET will return all addresses with their balances. RouteLedgerStateByIndex = "/ledger/state/by-index/:" + ParameterMilestoneIndex // former getLedgerState // RouteLedgerStateNonMigratedByIndex is the route to return the non-migrated ledger state of a given ledger index. // GET will return all non-migrated addresses with their balances. RouteLedgerStateNonMigratedByIndex = "/ledger/state/by-index/:" + ParameterMilestoneIndex + "/non-migrated" // RouteLedgerDiffByIndex is the route to return the ledger diff of a given ledger index. // GET will return all addresses with their diffs. RouteLedgerDiffByIndex = "/ledger/diff/by-index/:" + ParameterMilestoneIndex // former getLedgerDiff // RouteLedgerDiffExtendedByIndex is the route to return the ledger diff of a given ledger index with extended informations. // GET will return all addresses with their diffs, the confirmed transactions and the confirmed bundles. RouteLedgerDiffExtendedByIndex = "/ledger/diff-extended/by-index/:" + ParameterMilestoneIndex // former getLedgerDiffExt )
const (
APIRouteRest = "/api/core/v0"
)
const (
MIMETextCSV = "text/csv"
)
Variables ¶
var ( // ErrInvalidParameter defines the invalid parameter error. ErrInvalidParameter = echo.NewHTTPError(http.StatusBadRequest, "invalid parameter") // ErrNotAcceptable defines the not acceptable error. ErrNotAcceptable = echo.NewHTTPError(http.StatusNotAcceptable) )
var ( ErrPrivKeyInvalid = errors.New("invalid private key") ErrNoPrivKeyFound = errors.New("no private key found") ErrInvalidKeyLength = errors.New("invalid key length") )
var (
PLUGIN = node.NewPlugin("WebAPI", node.Enabled, configure, run)
)
PLUGIN WebAPI
Functions ¶
func GetRequestContentType ¶
func JSONResponse ¶
JSONResponse sends the JSON response with status code.
func LoadOrCreateIdentityPrivateKey ¶
func LoadOrCreateIdentityPrivateKey(privKeyFilePath string, identityPrivKey string) (libp2pcrypto.PrivKey, bool, error)
LoadOrCreateIdentityPrivateKey loads an existing Ed25519 based identity private key or creates a new one and stores it as a PEM file in the p2p store folder.
func NewEcho ¶
func NewEcho(logger *logger.Logger, onHTTPError func(err error, c echo.Context), debugRequestLoggerEnabled bool) *echo.Echo
NewEcho returns a new Echo instance. It hides the banner, adds a default HTTPErrorHandler and the Recover middleware.
func ParseUint32QueryParam ¶
Types ¶
type AddNeighbors ¶
type AddNeighbors struct {
Uris []string `json:"uris"`
}
AddNeighbors legacy struct.
type AddNeighborsHornet ¶
type AddNeighborsHornet struct {
Neighbors []Neighbor `json:"neighbors"`
}
AddNeighborsHornet struct.
type AddNeighborsResponse ¶
type AddNeighborsResponse struct {
AddedNeighbors int `json:"addedNeighbors"`
Duration int `json:"duration"`
}
AddNeighborsResponse struct.
type AddressWithBalance ¶
type ApproverStruct ¶
type ApproverStruct struct {
TxHash trinary.Hash `json:"txHash"`
ReferencedByTrunk bool `json:"referencedByTrunk"`
}
ApproverStruct struct.
type AttachToTangle ¶
type AttachToTangle struct {
TrunkTransaction trinary.Hash `json:"trunkTransaction"`
BranchTransaction trinary.Hash `json:"branchTransaction"`
MinWeightMagnitude int `json:"minWeightMagnitude,omitempty"`
Trytes []trinary.Trytes `json:"trytes"`
}
AttachToTangle struct.
type AttachToTangleResponse ¶
type AttachToTangleResponse struct {
Trytes []trinary.Trytes `json:"trytes"`
Duration int `json:"duration"`
}
AttachToTangleResponse struct.
type BroadcastTransactions ¶
BroadcastTransactions struct.
type BroadcastTransactionsResponse ¶
type BroadcastTransactionsResponse struct {
Duration int `json:"duration"`
}
BroadcastTransactionsResponse struct.
type BundleWithValue ¶
type BundleWithValue struct {
BundleHash trinary.Hash `json:"bundleHash"`
TailTxHash trinary.Hash `json:"tailTxHash"`
LastIndex uint64 `json:"lastIndex"`
Txs []*TxWithValue `json:"txs"`
}
BundleWithValue struct.
func (*BundleWithValue) Item ¶
func (b *BundleWithValue) Item() Container
type CheckConsistencyResponse ¶
CheckConsistencyResponse struct
type CreateSnapshotFile ¶
CreateSnapshotFile struct.
type CreateSnapshotFileResponse ¶
type CreateSnapshotFileResponse struct {
Duration int `json:"duration"`
}
CreateSnapshotFileResponse struct.
type DebugRequest ¶
type EntryPoint ¶
type EntryPoint struct {
TxHash trinary.Hash `json:"txHash"`
ConfirmedByMilestoneIndex milestone.Index `json:"confirmedByMilestoneIndex"`
}
EntryPoint struct.
type FindTransactions ¶
type FindTransactions struct {
Bundles []trinary.Hash `json:"bundles"`
Addresses []trinary.Hash `json:"addresses"`
Tags []trinary.Hash `json:"tags"`
Approvees []trinary.Hash `json:"approvees"`
MaxResults int `json:"maxresults"`
ValueOnly bool `json:"valueOnly"`
}
FindTransactions struct.
type FindTransactionsResponse ¶
type FindTransactionsResponse struct {
Hashes []trinary.Hash `json:"hashes"`
Duration int `json:"duration"`
}
FindTransactionsResponse struct.
type GetBalances ¶
GetBalances struct.
type GetBalancesResponse ¶
type GetBalancesResponse struct {
Balances []string `json:"balances"`
References []trinary.Hash `json:"references"`
MilestoneIndex milestone.Index `json:"milestoneIndex"`
Duration int `json:"duration"`
}
GetBalancesResponse struct.
type GetFundsOnSpentAddressesResponse ¶
type GetFundsOnSpentAddressesResponse struct {
Addresses []*AddressWithBalance `json:"addresses"`
}
GetFundsOnSpentAddressesResponse struct.
type GetInclusionStates ¶
GetInclusionStates struct.
type GetInclusionStatesResponse ¶
type GetInclusionStatesResponse struct {
States []bool `json:"states"`
Duration int `json:"duration"`
}
GetInclusionStatesResponse struct.
type GetLedgerDiff ¶
GetLedgerDiff struct.
type GetLedgerDiffExt ¶
GetLedgerDiffExt struct.
type GetLedgerDiffExtResponse ¶
type GetLedgerDiffExtResponse struct {
ConfirmedTxWithValue []*TxHashWithValue `json:"confirmedTxWithValue"`
ConfirmedBundlesWithValue []*BundleWithValue `json:"confirmedBundlesWithValue"`
Diff map[trinary.Hash]string `json:"diff"`
MilestoneIndex milestone.Index `json:"milestoneIndex"`
Duration int `json:"duration"`
}
GetLedgerDiffExtResponse struct.
type GetLedgerDiffResponse ¶
type GetLedgerDiffResponse struct {
Diff map[trinary.Hash]string `json:"diff"`
MilestoneIndex milestone.Index `json:"milestoneIndex"`
Duration int `json:"duration"`
}
GetLedgerDiffResponse struct.
type GetLedgerState ¶
GetLedgerState struct.
type GetLedgerStateResponse ¶
type GetLedgerStateResponse struct {
Balances map[trinary.Hash]string `json:"balances"`
MilestoneIndex milestone.Index `json:"milestoneIndex"`
Duration int `json:"duration"`
}
GetLedgerStateResponse struct.
type GetMigration ¶
type GetNeighborsResponse ¶
type GetNeighborsResponse struct {
Neighbors []*peer.Info `json:"neighbors"`
Duration int `json:"duration"`
}
GetNeighborsResponse struct.
type GetNodeAPIConfigurationResponse ¶
type GetNodeAPIConfigurationResponse struct {
MaxFindTransactions int `json:"maxFindTransactions"`
MaxRequestsList int `json:"maxRequestsList"`
MaxGetTrytes int `json:"maxGetTrytes"`
MaxBodyLength int `json:"maxBodyLength"`
MilestoneStartIndex milestone.Index `json:"milestoneStartIndex"`
Duration int `json:"duration"`
}
GetNodeAPIConfigurationResponse struct.
type GetNodeInfoResponse ¶
type GetNodeInfoResponse struct {
AppName string `json:"appName"`
AppVersion string `json:"appVersion"`
NodeAlias string `json:"nodeAlias,omitempty"`
LatestMilestone trinary.Hash `json:"latestMilestone"`
LatestMilestoneIndex milestone.Index `json:"latestMilestoneIndex"`
LatestSolidSubtangleMilestone trinary.Hash `json:"latestSolidSubtangleMilestone"`
LatestSolidSubtangleMilestoneIndex milestone.Index `json:"latestSolidSubtangleMilestoneIndex"`
IsSynced bool `json:"isSynced"`
Health bool `json:"isHealthy"`
MilestoneStartIndex milestone.Index `json:"milestoneStartIndex"`
LastSnapshottedMilestoneIndex milestone.Index `json:"lastSnapshottedMilestoneIndex"`
Neighbors uint `json:"neighbors"`
Time int64 `json:"time"`
Tips uint32 `json:"tips"`
TransactionsToRequest int `json:"transactionsToRequest"`
Features []string `json:"features"`
CoordinatorAddress trinary.Hash `json:"coordinatorAddress"`
Duration int `json:"duration"`
}
GetNodeInfoResponse struct.
type GetRequestsResponse ¶
type GetRequestsResponse struct {
Requests []*DebugRequest `json:"requests"`
}
GetRequestsResponse struct.
type GetTipInfo ¶
GetTipInfo struct.
type GetTipInfoResponse ¶
type GetTipInfoResponse struct {
Confirmed bool `json:"confirmed"`
Conflicting bool `json:"conflicting"`
ShouldPromote bool `json:"shouldPromote"`
ShouldReattach bool `json:"shouldReattach"`
Duration int `json:"duration"`
}
GetTipInfoResponse struct.
type GetTransactionsToApprove ¶
type GetTransactionsToApprove struct {
Depth uint `json:"depth"`
Reference trinary.Hash `json:"reference"`
}
GetTransactionsToApprove struct.
type GetTransactionsToApproveResponse ¶
type GetTransactionsToApproveResponse struct {
TrunkTransaction trinary.Hash `json:"trunkTransaction"`
BranchTransaction trinary.Hash `json:"branchTransaction"`
Duration int `json:"duration"`
}
GetTransactionsToApproveResponse struct.
type GetTrytesResponse ¶
type GetTrytesResponse struct {
Trytes []trinary.Trytes `json:"trytes"`
Duration int `json:"duration"`
}
GetTrytesResponse struct.
type GetWhiteFlagConfirmationResponse ¶
type GetWhiteFlagConfirmationResponse struct {
// The trytes of the milestone bundle.
MilestoneBundle []trinary.Trytes `json:"milestoneBundle"`
// The included bundles of the white-flag confirmation in their DFS order.
IncludedBundles [][]trinary.Trytes `json:"includedBundles"`
}
GetWhiteFlagConfirmationResponse defines the response of a getWhiteFlagConfirmation HTTP API call.
type HTTPErrorResponse ¶
HTTPErrorResponse defines the error struct for the HTTPErrorResponseEnvelope.
type HTTPErrorResponseEnvelope ¶
type HTTPErrorResponseEnvelope struct {
Error HTTPErrorResponse `json:"error"`
}
HTTPErrorResponseEnvelope defines the error response schema for node API responses.
type Neighbor ¶
type Neighbor struct {
Identity string `json:"identity"`
Alias string `json:"alias"`
PreferIPv6 bool `json:"prefer_ipv6"`
}
Neighbor struct.
type PruneDatabase ¶
type PruneDatabase struct {
TargetIndex milestone.Index `json:"targetIndex"`
Depth milestone.Index `json:"depth"`
}
PruneDatabase struct.
type PruneDatabaseResponse ¶
type PruneDatabaseResponse struct {
Duration int `json:"duration"`
}
PruneDatabaseResponse struct.
type RemoveNeighbors ¶
type RemoveNeighbors struct {
Uris []string `json:"uris"`
}
RemoveNeighbors struct.
type RemoveNeighborsResponse ¶
type RemoveNeighborsResponse struct {
RemovedNeighbors uint `json:"removedNeighbors"`
Duration int `json:"duration"`
}
RemoveNeighborsResponse struct.
type SearchConfirmedApprover ¶
type SearchConfirmedApprover struct {
TxHash trinary.Hash `json:"txHash"`
SearchMilestone bool `json:"searchMilestone"`
}
SearchConfirmedApprover struct.
type SearchConfirmedApproverResponse ¶
type SearchConfirmedApproverResponse struct {
ConfirmedTxHash trinary.Hash `json:"confirmedTxHash"`
ConfirmedByMilestoneIndex milestone.Index `json:"confirmedByMilestoneIndex"`
TanglePath []*ApproverStruct `json:"tanglePath"`
TanglePathLength int `json:"tanglePathLength"`
}
SearchConfirmedApproverResponse struct.
type SearchEntryPoint ¶
SearchEntryPoint struct.
type SearchEntryPointResponse ¶
type SearchEntryPointResponse struct {
TanglePath []*TransactionWithApprovers `json:"tanglePath"`
EntryPoints []*EntryPoint `json:"entryPoints"`
TanglePathLength int `json:"tanglePathLength"`
}
SearchEntryPointResponse struct.
type StoreTransactions ¶
StoreTransactions struct.
type TxHashWithValue ¶
type TxHashWithValue struct {
TxHash trinary.Hash `json:"txHash"`
TailTxHash trinary.Hash `json:"tailTxHash"`
BundleHash trinary.Hash `json:"bundleHash"`
Address trinary.Hash `json:"address"`
Value string `json:"value"`
}
TxHashWithValue struct.
func (*TxHashWithValue) Item ¶
func (tx *TxHashWithValue) Item() Container
type TxWithValue ¶
type TxWithValue struct {
TxHash trinary.Hash `json:"txHash"`
Address trinary.Hash `json:"address"`
Index uint64 `json:"index"`
Value string `json:"value"`
}
TxWithValue struct.
func (*TxWithValue) Item ¶
func (tx *TxWithValue) Item() Container
type WebAPIServer ¶
type WebAPIServer struct {
// contains filtered or unexported fields
}
func NewWebAPIServer ¶
func (*WebAPIServer) HasRPCEndpoint ¶
func (s *WebAPIServer) HasRPCEndpoint(endpoint string) bool
func (*WebAPIServer) SetFeatures ¶
func (s *WebAPIServer) SetFeatures(features []string)
type WereAddressesSpentFrom ¶
WereAddressesSpentFrom struct.
type WereAddressesSpentFromResponse ¶
type WereAddressesSpentFromResponse struct {
States []bool `json:"states"`
Duration int `json:"duration"`
}
WereAddressesSpentFromResponse struct.