Documentation
¶
Index ¶
- Constants
- Variables
- func OperationTypes() []string
- type AccountBalanceRequest
- type AccountBalanceResponse
- type AccountCoinsRequest
- type AccountCoinsResponse
- type AccountIdentifier
- type Allow
- type Amount
- type BalanceExemption
- type Block
- type BlockIdentifier
- type BlockRequest
- type BlockResponse
- type BlockTransactionRequest
- type BlockTransactionResponse
- type Coin
- type CoinChange
- type CoinIdentifier
- type ConstructionCombineRequest
- type ConstructionCombineResponse
- type ConstructionDeriveRequest
- type ConstructionDeriveResponse
- type ConstructionHashRequest
- type ConstructionHashResponse
- type ConstructionMetadataRequest
- type ConstructionMetadataResponse
- type ConstructionParseRequest
- type ConstructionParseResponse
- type ConstructionPayloadsRequest
- type ConstructionPayloadsResponse
- type ConstructionPreprocessRequest
- type ConstructionPreprocessResponse
- type ConstructionSubmitRequest
- type ConstructionSubmitResponse
- type Currency
- type Error
- type MempoolResponse
- type MempoolTransactionRequest
- type MempoolTransactionResponse
- type MetadataRequest
- type NetworkIdentifier
- type NetworkListResponse
- type NetworkOptionsResponse
- type NetworkRequest
- type NetworkStatusResponse
- type Operation
- type OperationIdentifier
- type OperationStatus
- type PartialBlockIdentifier
- type Peer
- type PublicKey
- type RelatedTransaction
- type Server
- type ServerConfig
- type Signature
- type SigningPayload
- type SubAccountIdentifier
- type SyncStatus
- type Transaction
- type TransactionIdentifier
- type Version
Constants ¶
const ( OpInput = "input" OpOutput = "output" OpStakeKeyRegistration = "stakeKeyRegistration" OpStakeKeyDeregistration = "stakeKeyDeregistration" OpStakeDelegation = "stakeDelegation" OpWithdrawal = "withdrawal" OpPoolRegistration = "poolRegistration" OpPoolRegistrationWithCert = "poolRegistrationWithCert" OpPoolRetirement = "poolRetirement" OpVoteDRepDelegation = "dRepVoteDelegation" OpPoolGovernanceVote = "poolGovernanceVote" )
Operation type constants matching the Cardano Foundation's cardano-rosetta-java implementation.
const ( StatusSuccess = "success" StatusInvalid = "invalid" )
Operation status constants.
const ( CoinCreated = "coin_created" CoinSpent = "coin_spent" )
CoinAction constants.
const (
Ed25519 = "ed25519"
)
Signature type constants.
const (
Edwards25519 = "edwards25519"
)
Curve type constants.
Variables ¶
var ( ErrNetworkNotSupported = &Error{ Code: 1, Message: "network not supported", Description: "The requested network is not supported " + "by this server.", Retriable: false, } ErrBlockNotFound = &Error{ Code: 2, Message: "block not found", Description: "The requested block could not be found.", Retriable: false, } ErrTransactionNotFound = &Error{ Code: 3, Message: "transaction not found", Description: "The requested transaction could " + "not be found.", Retriable: false, } ErrAccountNotFound = &Error{ Code: 4, Message: "account not found", Description: "The requested account could not " + "be found.", Retriable: false, } ErrInvalidRequest = &Error{ Code: 5, Message: "invalid request", Description: "The request was invalid or malformed.", Retriable: false, } ErrInternal = &Error{ Code: 6, Message: "internal error", Description: "An internal server error occurred.", Retriable: true, } ErrNotImplemented = &Error{ Code: 7, Message: "not implemented", Description: "This endpoint is not yet implemented.", Retriable: false, } ErrInvalidPublicKey = &Error{ Code: 8, Message: "invalid public key", Description: "The provided public key is invalid.", Retriable: false, } ErrInvalidTransaction = &Error{ Code: 9, Message: "invalid transaction", Description: "The provided transaction is " + "invalid or malformed.", Retriable: false, } ErrSubmitFailed = &Error{ Code: 10, Message: "transaction submit failed", Description: "The transaction could not be " + "submitted to the network.", Retriable: true, } Code: 11, Message: "service unavailable", Description: "The service is temporarily " + "unavailable. Please retry.", Retriable: true, } )
Standard Mesh API error codes following the specification.
Functions ¶
func OperationTypes ¶
func OperationTypes() []string
OperationTypes returns all supported operation types.
Types ¶
type AccountBalanceRequest ¶
type AccountBalanceRequest struct {
AccountIdentifier *AccountIdentifier `json:"account_identifier"`
BlockIdentifier *PartialBlockIdentifier `json:"block_identifier,omitempty"`
Currencies []*Currency `json:"currencies,omitempty"`
// contains filtered or unexported fields
}
AccountBalanceRequest is for balance lookups.
type AccountBalanceResponse ¶
type AccountBalanceResponse struct {
BlockIdentifier *BlockIdentifier `json:"block_identifier"`
Balances []*Amount `json:"balances"`
Metadata map[string]any `json:"metadata,omitempty"`
}
AccountBalanceResponse returns balances.
type AccountCoinsRequest ¶
type AccountCoinsRequest struct {
AccountIdentifier *AccountIdentifier `json:"account_identifier"`
IncludeMempool bool `json:"include_mempool"`
Currencies []*Currency `json:"currencies,omitempty"`
// contains filtered or unexported fields
}
AccountCoinsRequest is for UTXO lookups.
type AccountCoinsResponse ¶
type AccountCoinsResponse struct {
BlockIdentifier *BlockIdentifier `json:"block_identifier"`
Coins []*Coin `json:"coins"`
Metadata map[string]any `json:"metadata,omitempty"`
}
AccountCoinsResponse returns UTXOs.
type AccountIdentifier ¶
type AccountIdentifier struct {
Address string `json:"address"`
SubAccount *SubAccountIdentifier `json:"sub_account,omitempty"`
}
AccountIdentifier uniquely identifies an account.
type Allow ¶
type Allow struct {
OperationStatuses []*OperationStatus `json:"operation_statuses"`
OperationTypes []string `json:"operation_types"`
Errors []*Error `json:"errors"`
HistoricalBalanceLookup bool `json:"historical_balance_lookup"`
CallMethods []string `json:"call_methods,omitempty"`
BalanceExemptions []*BalanceExemption `json:"balance_exemptions,omitempty"`
MempoolCoins bool `json:"mempool_coins"`
BlockHashCase *string `json:"block_hash_case,omitempty"`
TransactionHashCase *string `json:"transaction_hash_case,omitempty"`
}
Allow specifies what the server supports.
type BalanceExemption ¶
type BalanceExemption struct {
SubAccountAddress string `json:"sub_account_address,omitempty"`
Currency *Currency `json:"currency,omitempty"`
ExemptionType string `json:"exemption_type,omitempty"`
}
BalanceExemption allows operations to change balances without affecting account balances.
type Block ¶
type Block struct {
BlockIdentifier *BlockIdentifier `json:"block_identifier"`
ParentBlockIdentifier *BlockIdentifier `json:"parent_block_identifier"`
Timestamp int64 `json:"timestamp"`
Transactions []*Transaction `json:"transactions"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Block represents a blockchain block.
type BlockIdentifier ¶
BlockIdentifier uniquely identifies a block.
type BlockRequest ¶
type BlockRequest struct {
BlockIdentifier *PartialBlockIdentifier `json:"block_identifier"`
// contains filtered or unexported fields
}
BlockRequest identifies a block to fetch.
type BlockResponse ¶
type BlockResponse struct {
Block *Block `json:"block,omitempty"`
OtherTransactions []*TransactionIdentifier `json:"other_transactions,omitempty"`
}
BlockResponse returns a block.
type BlockTransactionRequest ¶
type BlockTransactionRequest struct {
BlockIdentifier *BlockIdentifier `json:"block_identifier"`
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
// contains filtered or unexported fields
}
BlockTransactionRequest identifies a tx in a block.
type BlockTransactionResponse ¶
type BlockTransactionResponse struct {
Transaction *Transaction `json:"transaction"`
}
BlockTransactionResponse returns a transaction.
type Coin ¶
type Coin struct {
CoinIdentifier *CoinIdentifier `json:"coin_identifier"`
Amount *Amount `json:"amount"`
}
Coin represents a UTXO.
type CoinChange ¶
type CoinChange struct {
CoinIdentifier *CoinIdentifier `json:"coin_identifier"`
CoinAction string `json:"coin_action"`
}
CoinChange describes the change to a coin (created or spent).
type CoinIdentifier ¶
type CoinIdentifier struct {
Identifier string `json:"identifier"`
}
CoinIdentifier uniquely identifies a UTXO coin.
type ConstructionCombineRequest ¶
type ConstructionCombineRequest struct {
UnsignedTransaction string `json:"unsigned_transaction"`
Signatures []*Signature `json:"signatures"`
// contains filtered or unexported fields
}
ConstructionCombineRequest combines unsigned tx + sigs.
type ConstructionCombineResponse ¶
type ConstructionCombineResponse struct {
SignedTransaction string `json:"signed_transaction"`
}
ConstructionCombineResponse returns signed tx.
type ConstructionDeriveRequest ¶
type ConstructionDeriveRequest struct {
PublicKey *PublicKey `json:"public_key"`
Metadata map[string]any `json:"metadata,omitempty"`
// contains filtered or unexported fields
}
ConstructionDeriveRequest derives an address.
type ConstructionDeriveResponse ¶
type ConstructionDeriveResponse struct {
AccountIdentifier *AccountIdentifier `json:"account_identifier,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ConstructionDeriveResponse returns a derived address.
type ConstructionHashRequest ¶
type ConstructionHashRequest struct {
SignedTransaction string `json:"signed_transaction"`
// contains filtered or unexported fields
}
ConstructionHashRequest computes a tx hash.
type ConstructionHashResponse ¶
type ConstructionHashResponse struct {
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ConstructionHashResponse returns a tx hash.
type ConstructionMetadataRequest ¶
type ConstructionMetadataRequest struct {
Options map[string]any `json:"options,omitempty"`
PublicKeys []*PublicKey `json:"public_keys,omitempty"`
// contains filtered or unexported fields
}
ConstructionMetadataRequest fetches tx metadata.
type ConstructionMetadataResponse ¶
type ConstructionMetadataResponse struct {
Metadata map[string]any `json:"metadata"`
SuggestedFee []*Amount `json:"suggested_fee,omitempty"`
}
ConstructionMetadataResponse returns tx metadata.
type ConstructionParseRequest ¶
type ConstructionParseRequest struct {
Signed bool `json:"signed"`
Transaction string `json:"transaction"`
// contains filtered or unexported fields
}
ConstructionParseRequest parses a transaction.
type ConstructionParseResponse ¶
type ConstructionParseResponse struct {
Operations []*Operation `json:"operations"`
AccountIdentifierSigners []*AccountIdentifier `json:"account_identifier_signers,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ConstructionParseResponse returns parsed operations.
type ConstructionPayloadsRequest ¶
type ConstructionPayloadsRequest struct {
Operations []*Operation `json:"operations"`
Metadata map[string]any `json:"metadata,omitempty"`
PublicKeys []*PublicKey `json:"public_keys,omitempty"`
// contains filtered or unexported fields
}
ConstructionPayloadsRequest creates unsigned tx.
type ConstructionPayloadsResponse ¶
type ConstructionPayloadsResponse struct {
UnsignedTransaction string `json:"unsigned_transaction"`
Payloads []*SigningPayload `json:"payloads"`
}
ConstructionPayloadsResponse returns unsigned tx.
type ConstructionPreprocessRequest ¶
type ConstructionPreprocessRequest struct {
Operations []*Operation `json:"operations"`
Metadata map[string]any `json:"metadata,omitempty"`
// contains filtered or unexported fields
}
ConstructionPreprocessRequest preprocesses operations.
type ConstructionPreprocessResponse ¶
type ConstructionPreprocessResponse struct {
Options map[string]any `json:"options,omitempty"`
RequiredPublicKeys []*AccountIdentifier `json:"required_public_keys,omitempty"`
}
ConstructionPreprocessResponse returns options.
type ConstructionSubmitRequest ¶
type ConstructionSubmitRequest struct {
SignedTransaction string `json:"signed_transaction"`
// contains filtered or unexported fields
}
ConstructionSubmitRequest submits a signed tx.
type ConstructionSubmitResponse ¶
type ConstructionSubmitResponse struct {
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ConstructionSubmitResponse returns submit result.
type Currency ¶
type Currency struct {
Symbol string `json:"symbol"`
Decimals int32 `json:"decimals"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Currency represents a currency with symbol and decimals.
type Error ¶
type Error struct {
Code int32 `json:"code"`
Message string `json:"message"`
Description string `json:"description,omitempty"`
Retriable bool `json:"retriable"`
Details map[string]any `json:"details,omitempty"`
}
Error represents a Mesh API error response.
type MempoolResponse ¶
type MempoolResponse struct {
TransactionIdentifiers []*TransactionIdentifier `json:"transaction_identifiers"`
}
MempoolResponse lists mempool transactions.
type MempoolTransactionRequest ¶
type MempoolTransactionRequest struct {
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
// contains filtered or unexported fields
}
MempoolTransactionRequest identifies a mempool tx.
type MempoolTransactionResponse ¶
type MempoolTransactionResponse struct {
Transaction *Transaction `json:"transaction"`
Metadata map[string]any `json:"metadata,omitempty"`
}
MempoolTransactionResponse returns a mempool tx.
type MetadataRequest ¶
MetadataRequest is used for network list.
type NetworkIdentifier ¶
type NetworkIdentifier struct {
Blockchain string `json:"blockchain"`
Network string `json:"network"`
}
NetworkIdentifier identifies a blockchain network.
type NetworkListResponse ¶
type NetworkListResponse struct {
NetworkIdentifiers []*NetworkIdentifier `json:"network_identifiers"`
}
NetworkListResponse lists supported networks.
type NetworkOptionsResponse ¶
type NetworkOptionsResponse struct {
Version *Version `json:"version"`
Allow *Allow `json:"allow"`
}
NetworkOptionsResponse describes network options.
type NetworkRequest ¶
type NetworkRequest struct {
Metadata map[string]any `json:"metadata,omitempty"`
// contains filtered or unexported fields
}
NetworkRequest identifies the target network.
type NetworkStatusResponse ¶
type NetworkStatusResponse struct {
CurrentBlockIdentifier *BlockIdentifier `json:"current_block_identifier"`
CurrentBlockTimestamp int64 `json:"current_block_timestamp"`
GenesisBlockIdentifier *BlockIdentifier `json:"genesis_block_identifier"`
OldestBlockIdentifier *BlockIdentifier `json:"oldest_block_identifier,omitempty"`
SyncStatus *SyncStatus `json:"sync_status,omitempty"`
Peers []*Peer `json:"peers"`
}
NetworkStatusResponse describes network status.
type Operation ¶
type Operation struct {
OperationIdentifier *OperationIdentifier `json:"operation_identifier"`
RelatedOperations []*OperationIdentifier `json:"related_operations,omitempty"`
Type string `json:"type"`
Status *string `json:"status,omitempty"`
Account *AccountIdentifier `json:"account,omitempty"`
Amount *Amount `json:"amount,omitempty"`
CoinChange *CoinChange `json:"coin_change,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Operation describes a single mutation to state.
type OperationIdentifier ¶
type OperationIdentifier struct {
Index int64 `json:"index"`
NetworkIndex *int64 `json:"network_index,omitempty"`
}
OperationIdentifier uniquely identifies an operation.
type OperationStatus ¶
OperationStatus describes the status of an operation.
func OperationStatuses ¶
func OperationStatuses() []*OperationStatus
OperationStatuses returns the supported operation statuses.
type PartialBlockIdentifier ¶
type PartialBlockIdentifier struct {
Index *int64 `json:"index,omitempty"`
Hash *string `json:"hash,omitempty"`
}
PartialBlockIdentifier is used in requests where either index or hash may be specified.
type Peer ¶
type Peer struct {
PeerID string `json:"peer_id"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Peer represents a network peer.
type RelatedTransaction ¶
type RelatedTransaction struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier,omitempty"`
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
Direction string `json:"direction"`
}
RelatedTransaction identifies a related transaction.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Mesh-compatible REST API server.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
NewServer creates a new Mesh API server instance. Returns an error if required configuration fields are missing.
type ServerConfig ¶
type ServerConfig struct {
Logger *slog.Logger
EventBus *event.EventBus
LedgerState *ledger.LedgerState
Database *database.Database
Chain *chain.Chain
Mempool *mempool.Mempool
ListenAddress string
Network string
NetworkMagic uint32
// GenesisHash is the Byron genesis block hash
// (hex-encoded).
GenesisHash string
// GenesisStartTimeSec is the Unix timestamp (seconds)
// of slot 0 for the configured network. Used to
// convert slot numbers to absolute timestamps.
GenesisStartTimeSec int64
}
ServerConfig holds configuration for the Mesh API server.
type Signature ¶
type Signature struct {
SigningPayload *SigningPayload `json:"signing_payload"`
PublicKey *PublicKey `json:"public_key"`
SignatureType string `json:"signature_type"`
HexBytes string `json:"hex_bytes"`
}
Signature is a signed payload.
type SigningPayload ¶
type SigningPayload struct {
AccountIdentifier *AccountIdentifier `json:"account_identifier,omitempty"`
HexBytes string `json:"hex_bytes"`
SignatureType string `json:"signature_type,omitempty"`
}
SigningPayload is the payload to be signed.
type SubAccountIdentifier ¶
type SubAccountIdentifier struct {
Address string `json:"address"`
}
SubAccountIdentifier identifies a sub-account.
type SyncStatus ¶
type SyncStatus struct {
CurrentIndex *int64 `json:"current_index,omitempty"`
TargetIndex *int64 `json:"target_index,omitempty"`
Stage *string `json:"stage,omitempty"`
Synced *bool `json:"synced,omitempty"`
}
SyncStatus describes the sync state.
type Transaction ¶
type Transaction struct {
TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"`
Operations []*Operation `json:"operations"`
RelatedTransactions []*RelatedTransaction `json:"related_transactions,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Transaction represents a blockchain transaction.
type TransactionIdentifier ¶
type TransactionIdentifier struct {
Hash string `json:"hash"`
}
TransactionIdentifier uniquely identifies a transaction.