Class Server
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaccounts()
assets()
void
close()
effects()
feeStats()
okhttp3.OkHttpClient
okhttp3.OkHttpClient
submitHttpClient is used only for submitting transactions.ledgers()
loadAccount
(String address) Fetches an account's most current state in the ledger, then creates and returns anAccount
object.offers()
payments()
root()
void
setHttpClient
(okhttp3.OkHttpClient httpClient) void
setSubmitHttpClient
(okhttp3.OkHttpClient submitHttpClient) submitHttpClient is used only for submitting transactions.submitTransaction
(FeeBumpTransaction transaction) Submits a fee bump transaction to the networksubmitTransaction
(FeeBumpTransaction transaction, boolean skipMemoRequiredCheck) Submits a fee bump transaction to the networksubmitTransaction
(Transaction transaction) Submits a transaction to the networksubmitTransaction
(Transaction transaction, boolean skipMemoRequiredCheck) Submits a transaction to the networksubmitTransactionAsync
(FeeBumpTransaction transaction) Submits a base64 asynchronous transaction to the network.submitTransactionAsync
(FeeBumpTransaction transaction, boolean skipMemoRequiredCheck) Submits a base64 asynchronous transaction to the network.submitTransactionAsync
(Transaction transaction) Submits a base64 asynchronous transaction to the network.submitTransactionAsync
(Transaction transaction, boolean skipMemoRequiredCheck) Submits a base64 asynchronous transaction to the network.submitTransactionXdr
(String transactionXdr) Submits a base64 encoded transaction envelope to the networksubmitTransactionXdrAsync
(String transactionXdr) Submits a base64 asynchronous transaction to the network.tradeAggregations
(Asset baseAsset, Asset counterAsset, long startTime, long endTime, long resolution, long offset) trades()
-
Constructor Details
-
Server
Constructs a new Server object with default HTTP clients.- Parameters:
uri
- The URI of the Horizon server.
-
Server
public Server(String serverURI, okhttp3.OkHttpClient httpClient, okhttp3.OkHttpClient submitHttpClient) Constructs a new Server object with custom HTTP clients.- Parameters:
serverURI
- The URI of the Horizon server.httpClient
- The OkHttpClient to use for general requests.submitHttpClient
- The OkHttpClient to use for submitting transactions.
-
-
Method Details
-
loadAccount
Fetches an account's most current state in the ledger, then creates and returns anAccount
object.- Parameters:
address
- The address of the account to load, muxed accounts are supported.- Returns:
Account
object- Throws:
NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
root
- Returns:
RootRequestBuilder
instance.
-
accounts
- Returns:
AccountsRequestBuilder
instance.
-
assets
- Returns:
AssetsRequestBuilder
instance.
-
claimableBalances
- Returns:
ClaimableBalancesRequestBuilder
instance.
-
effects
- Returns:
EffectsRequestBuilder
instance.
-
ledgers
- Returns:
LedgersRequestBuilder
instance.
-
offers
- Returns:
OffersRequestBuilder
instance.
-
operations
- Returns:
OperationsRequestBuilder
instance.
-
feeStats
- Returns:
FeeStatsResponse
instance.
-
orderBook
- Returns:
OrderBookRequestBuilder
instance.
-
trades
- Returns:
TradesRequestBuilder
instance.
-
tradeAggregations
public TradeAggregationsRequestBuilder tradeAggregations(Asset baseAsset, Asset counterAsset, long startTime, long endTime, long resolution, long offset) - Returns:
TradeAggregationsRequestBuilder
instance.
-
strictReceivePaths
- Returns:
StrictReceivePathsRequestBuilder
instance.
-
strictSendPaths
- Returns:
StrictSendPathsRequestBuilder
instance.
-
payments
- Returns:
PaymentsRequestBuilder
instance.
-
transactions
- Returns:
TransactionsRequestBuilder
instance.
-
liquidityPools
- Returns:
LiquidityPoolsRequestBuilder
instance.
-
submitTransactionXdr
Submits a base64 encoded transaction envelope to the network- Parameters:
transactionXdr
- base64 encoded transaction envelope to submit to the network- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
submitTransaction
public TransactionResponse submitTransaction(Transaction transaction, boolean skipMemoRequiredCheck) Submits a transaction to the network- Parameters:
transaction
- transaction to submit to the networkskipMemoRequiredCheck
- set to true to skip memoRequiredCheck- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
submitTransaction
public TransactionResponse submitTransaction(FeeBumpTransaction transaction, boolean skipMemoRequiredCheck) Submits a fee bump transaction to the network- Parameters:
transaction
- transaction to submit to the networkskipMemoRequiredCheck
- set to true to skip memoRequiredCheck- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
submitTransaction
Submits a transaction to the networkThis function will always check if the destination account requires a memo in the transaction as defined in SEP-0029 If you want to skip this check, use
submitTransaction(Transaction, boolean)
.- Parameters:
transaction
- transaction to submit to the network.- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
submitTransaction
Submits a fee bump transaction to the networkThis function will always check if the destination account requires a memo in the transaction as defined in SEP-0029 If you want to skip this check, use
submitTransaction(Transaction, boolean)
.- Parameters:
transaction
- transaction to submit to the network.- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
submitTransactionXdrAsync
Submits a base64 asynchronous transaction to the network. Unlike the synchronous version, which blocks and waits for the transaction to be ingested in Horizon, this endpoint relays the response from core directly back to the user.- Parameters:
transactionXdr
- base64 encoded transaction envelope to submit to the network- Returns:
SubmitTransactionAsyncResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.- See Also:
-
submitTransactionAsync
public SubmitTransactionAsyncResponse submitTransactionAsync(Transaction transaction, boolean skipMemoRequiredCheck) Submits a base64 asynchronous transaction to the network. Unlike the synchronous version, which blocks and waits for the transaction to be ingested in Horizon, this endpoint relays the response from core directly back to the user.- Parameters:
transaction
- transaction to submit to the networkskipMemoRequiredCheck
- set to true to skip memoRequiredCheck- Returns:
TransactionResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.- See Also:
-
submitTransactionAsync
public SubmitTransactionAsyncResponse submitTransactionAsync(FeeBumpTransaction transaction, boolean skipMemoRequiredCheck) Submits a base64 asynchronous transaction to the network. Unlike the synchronous version, which blocks and waits for the transaction to be ingested in Horizon, this endpoint relays the response from core directly back to the user.- Parameters:
transaction
- transaction to submit to the networkskipMemoRequiredCheck
- set to true to skip memoRequiredCheck- Returns:
SubmitTransactionAsyncResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.- See Also:
-
submitTransactionAsync
Submits a base64 asynchronous transaction to the network. Unlike the synchronous version, which blocks and waits for the transaction to be ingested in Horizon, this endpoint relays the response from core directly back to the user.This function will always check if the destination account requires a memo in the transaction as defined in SEP-0029 If you want to skip this check, use
submitTransactionAsync(Transaction, boolean)
.- Parameters:
transaction
- transaction to submit to the network.- Returns:
SubmitTransactionAsyncResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.- See Also:
-
submitTransactionAsync
Submits a base64 asynchronous transaction to the network. Unlike the synchronous version, which blocks and waits for the transaction to be ingested in Horizon, this endpoint relays the response from core directly back to the user.This function will always check if the destination account requires a memo in the transaction as defined in SEP-0029 If you want to skip this check, use
submitTransactionAsync(Transaction, boolean)
.- Parameters:
transaction
- transaction to submit to the network.- Returns:
SubmitTransactionAsyncResponse
- Throws:
AccountRequiresMemoException
- when a transaction is trying to submit an operation to an account which requires a memo.NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.- See Also:
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getHttpClient
public okhttp3.OkHttpClient getHttpClient() -
setHttpClient
public void setHttpClient(okhttp3.OkHttpClient httpClient) -
getSubmitHttpClient
public okhttp3.OkHttpClient getSubmitHttpClient()submitHttpClient is used only for submitting transactions. The read timeout is longer. -
setSubmitHttpClient
public void setSubmitHttpClient(okhttp3.OkHttpClient submitHttpClient) submitHttpClient is used only for submitting transactions. The read timeout is longer.
-