Documentation ¶
Index ¶
- Constants
- Variables
- type APIClient
- type APIKey
- type APIResponse
- type AccountAPIService
- type BasicAuth
- type BlockAPIService
- func (a *BlockAPIService) Block(ctx _context.Context, blockRequest *models.BlockRequest) (*models.BlockResponse, *models.Error, error)
- func (a *BlockAPIService) BlockTransaction(ctx _context.Context, blockTransactionRequest *models.BlockTransactionRequest) (*models.BlockTransactionResponse, *models.Error, error)
- type Configuration
- type ConstructionAPIService
- type MempoolAPIService
- type NetworkAPIService
- type ServerConfiguration
- type ServerVariable
Constants ¶
const ( // APIVersion is the version of the Rosetta API Spec // used to generate this code. APIVersion = "1.3.0" )
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct { AccountAPI *AccountAPIService BlockAPI *BlockAPIService ConstructionAPI *ConstructionAPIService MempoolAPI *MempoolAPIService NetworkAPI *NetworkAPIService // contains filtered or unexported fields }
APIClient manages communication with the Rosetta API v1.3.0 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangeBasePath ¶
ChangeBasePath changes base path to allow switching to mocks
func (*APIClient) GetConfig ¶
func (c *APIClient) GetConfig() *Configuration
GetConfig allows for modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResonse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
type AccountAPIService ¶
type AccountAPIService service
AccountAPIService AccountAPI service
func (*AccountAPIService) AccountBalance ¶
func (a *AccountAPIService) AccountBalance( ctx _context.Context, accountBalanceRequest *models.AccountBalanceRequest, ) (*models.AccountBalanceResponse, *models.Error, error)
AccountBalance Get an array of all Account Balances for an Account Identifier and the Block Identifier at which the balance lookup was performed. Some consumers of account balance data need to know at which block the balance was calculated to reconcile account balance changes. To get all balances associated with an account, it may be necessary to perform multiple balance requests with unique Account Identifiers. If the client supports it, passing nil AccountIdentifier metadata to the request should fetch all balances (if applicable). It is also possible to perform a historical balance lookup (if the server supports it) by passing in an optional BlockIdentifier.
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BlockAPIService ¶
type BlockAPIService service
BlockAPIService BlockAPI service
func (*BlockAPIService) Block ¶
func (a *BlockAPIService) Block( ctx _context.Context, blockRequest *models.BlockRequest, ) (*models.BlockResponse, *models.Error, error)
Block Get a block by its Block Identifier. If transactions are returned in the same call to the node as fetching the block, the response should include these transactions in the Block object. If not, an array of Transaction Identifiers should be returned so /block/transaction fetches can be done to get all transaction information.
func (*BlockAPIService) BlockTransaction ¶
func (a *BlockAPIService) BlockTransaction( ctx _context.Context, blockTransactionRequest *models.BlockTransactionRequest, ) (*models.BlockTransactionResponse, *models.Error, error)
BlockTransaction Get a transaction in a block by its Transaction Identifier. This method should only be used when querying a node for a block does not return all transactions contained within it. All transactions returned by this method must be appended to any transactions returned by the /block method by consumers of this data. Fetching a transaction by hash is considered an Explorer Method (which is classified under the Future Work section). Calling this method requires reference to a BlockIdentifier because transaction parsing can change depending on which block contains the transaction. For example, in Bitcoin it is necessary to know which block contains a transaction to determine the destination of fee payments. Without specifying a block identifier, the node would have to infer which block to use (which could change during a re-org).
Implementations that require fetching previous transactions to populate the response (ex:
Previous UTXOs in Bitcoin) may find it useful to run a cache within the Rosetta server in the /data directory (on a path that does not conflict with the node).
type Configuration ¶
type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` Servers []ServerConfiguration HTTPClient *http.Client }
Configuration stores the configuration of the API client
func NewConfiguration ¶
func NewConfiguration(basePath string, userAgent string, httpClient *http.Client) *Configuration
NewConfiguration returns a new Configuration object
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
type ConstructionAPIService ¶
type ConstructionAPIService service
ConstructionAPIService ConstructionAPI service
func (*ConstructionAPIService) TransactionConstruction ¶
func (a *ConstructionAPIService) TransactionConstruction( ctx _context.Context, transactionConstructionRequest *models.TransactionConstructionRequest, ) (*models.TransactionConstructionResponse, *models.Error, error)
TransactionConstruction Get any information required to construct a transaction for a specific account. Metadata returned here could be a recent hash to use or an account sequence number. It is important to clarify that this endpoint should not pre-construct any transactions for the client. All account-specific metadata must be returned as a key-value mapping so that transaction construction can be audited and performed entirely offline. Any account-agnostic metadata does not need to be broken out into a key-value mapping and can be returned as a blob.
func (*ConstructionAPIService) TransactionSubmit ¶
func (a *ConstructionAPIService) TransactionSubmit( ctx _context.Context, transactionSubmitRequest *models.TransactionSubmitRequest, ) (*models.TransactionSubmitResponse, *models.Error, error)
TransactionSubmit Submit a pre-signed transaction to the node. This call should not block on the transaction being included in a block. Rather, it should return immediately with an indication of whether or not the transaction was included in the mempool. The transaction submission response should only return a 200 status if the submitted transaction could be included in the mempool. Otherwise, it should return an error.
type MempoolAPIService ¶
type MempoolAPIService service
MempoolAPIService MempoolAPI service
func (*MempoolAPIService) Mempool ¶
func (a *MempoolAPIService) Mempool( ctx _context.Context, mempoolRequest *models.MempoolRequest, ) (*models.MempoolResponse, *models.Error, error)
Mempool Get all Transaction Identifiers in the mempool
func (*MempoolAPIService) MempoolTransaction ¶
func (a *MempoolAPIService) MempoolTransaction( ctx _context.Context, mempoolTransactionRequest *models.MempoolTransactionRequest, ) (*models.MempoolTransactionResponse, *models.Error, error)
MempoolTransaction Get a transaction in the mempool by its Transaction Identifier. This is a separate request than fetching a block transaction (/block/transaction) because some blockchain nodes need to know that a transaction query is for something in the mempool instead of a transaction in a block. Transactions may not be fully parsable until they are in a block (ex: may not be possible to determine the fee to pay before a transaction is executed). On this endpoint, it is ok that returned transactions are only estimates of what may actually be included in a block.
type NetworkAPIService ¶
type NetworkAPIService service
NetworkAPIService NetworkAPI service
func (*NetworkAPIService) NetworkStatus ¶
func (a *NetworkAPIService) NetworkStatus( ctx _context.Context, networkStatusRequest *models.NetworkStatusRequest, ) (*models.NetworkStatusResponse, *models.Error, error)
NetworkStatus This method returns the current status of the network the node knows about. This method also returns the methods, operation types, and operation statuses the node supports.
type ServerConfiguration ¶
type ServerConfiguration struct { URL string Description string Variables map[string]ServerVariable }
ServerConfiguration stores the information about a server
type ServerVariable ¶
ServerVariable stores the information about a server variable