Package org.xrpl.xrpl4j.client
Class XrplClient
java.lang.Object
org.xrpl.xrpl4j.client.XrplClient
A client which wraps a rippled network client and is responsible for higher order functionality such as signing and serializing transactions, as well as hiding certain implementation details from the public API such as JSON RPC request object creation.
Note: This client is currently marked as Beta
, and should be used as a reference implementation ONLY.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet theAccountChannelsResult
for the account specified inparams
by making an account_channels method call.Get theAccountCurrenciesResult
for the account specified inparams
by making an account_currencies method call.accountInfo
(AccountInfoRequestParams params) Get theAccountInfoResult
for the account specified inparams
by making an account_info method call.Get the trust lines for a given account by sending an account_lines method request.accountNfts
(AccountNftsRequestParams params) Get theAccountNftsResult
for the account specified inparams
by making an account_channels method call.accountNfts
(Address account) Return AccountNftsResult for anAddress
.Get theAccountObjectsResult
for the account specified inparams
by making an account_objects method call.Get theAccountOffersResult
for the account specified inparams
by making an account_offers method call.Get theAccountTransactionsResult
for the account specified inparams
by making an account_tx method call.accountTransactions
(Address address) Get theAccountTransactionsResult
for the specifiedaddress
by making an account_tx method call.ammInfo
(AmmInfoRequestParams params) Get info about an AMM by making a call to the amm_info rippled RPC method.bookOffers
(BookOffersRequestParams params) Send abook_offers
RPC request.Verify a payment channel claim signature by making a "channel_verify" rippled API method call.Indicates whether one account is authorized to send payments directly to another.fee()
Get the current state of the open-ledger requirements for transaction costs.Get the issued currency balances of an issuing account by making a "gateway_balances" rippled API method call.protected com.google.common.primitives.UnsignedInteger
Get the ledger index of a tx result response.protected Optional
<? extends TransactionResult<? extends Transaction>> getValidatedTransaction
(Hash256 transactionHash) Get theTransactionResult
for the transaction with the hash transactionHash.isFinal
(Hash256 transactionHash, LedgerIndex submittedOnLedgerIndex, com.google.common.primitives.UnsignedInteger lastLedgerSequence, com.google.common.primitives.UnsignedInteger transactionAccountSequence, Address account) Check if the transaction is final on the ledger or not.ledger
(LedgerRequestParams params) Get the contents of a ledger by sending a ledger method request.<T extends LedgerObject>
LedgerEntryResult<T> ledgerEntry
(LedgerEntryRequestParams<T> params) Retrieve aLedgerObject
by sending aledger_entry
RPC request.protected boolean
ledgerGapsExistBetween
(com.google.common.primitives.UnsignedLong submittedLedgerSequence, com.google.common.primitives.UnsignedLong lastLedgerSequence) Check if there missing ledgers in rippled in the given range.Get theNftBuyOffersResult
for theNfTokenId
specified inparams
by making an nft_buy_offers method call.nftInfo
(NftInfoRequestParams params) Returns information about a given NFT.Get theNftSellOffersResult
for theNfTokenId
specified inparams
by making an nft_sell_offers method call.Try to find a payment path for a rippling payment by sending a ripple_path_find method request.Get the "server_info" for the rippled nodeRippledServerInfo
, clio serverClioServerInfo
and reporting mode serverReportingModeServerInfo
.<T extends Transaction>
SubmitResult<T> submit
(SingleSignedTransaction<T> signedTransaction) Submit aSingleSignedTransaction
to the XRP Ledger.<T extends Transaction>
SubmitMultiSignedResult<T> submitMultisigned
(MultiSignedTransaction<T> transaction) Submit a multisignedTransaction
to the ledger.<T extends Transaction>
TransactionResult<T> transaction
(TransactionRequestParams params, Class<T> transactionType) Get a transaction from the ledger by sending a tx method request.
-
Constructor Details
-
XrplClient
public XrplClient(okhttp3.HttpUrl rippledUrl) Public constructor.- Parameters:
rippledUrl
- TheHttpUrl
of the rippled node to connect to.
-
-
Method Details
-
submit
public <T extends Transaction> SubmitResult<T> submit(SingleSignedTransaction<T> signedTransaction) throws JsonRpcClientErrorException, com.fasterxml.jackson.core.JsonProcessingException Submit aSingleSignedTransaction
to the XRP Ledger.- Type Parameters:
T
- The type of signedTransaction
that is being submitted.- Parameters:
signedTransaction
- ASingleSignedTransaction
to submit.- Returns:
- The
SubmitResult
resulting from the submission request. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.com.fasterxml.jackson.core.JsonProcessingException
- if any JSON is invalid.- See Also:
-
submitMultisigned
public <T extends Transaction> SubmitMultiSignedResult<T> submitMultisigned(MultiSignedTransaction<T> transaction) throws JsonRpcClientErrorException Submit a multisignedTransaction
to the ledger.- Type Parameters:
T
- A type parameter for the type ofTransaction
being submitted.- Parameters:
transaction
- AMultiSignedTransaction
.- Returns:
- A
SubmitMultiSignedResult
of typeXrplClient
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
fee
Get the current state of the open-ledger requirements for transaction costs.- Returns:
- A
FeeResult
containing information about current transaction costs. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.- See Also:
-
getMostRecentlyValidatedLedgerIndex
protected com.google.common.primitives.UnsignedInteger getMostRecentlyValidatedLedgerIndex() throws JsonRpcClientErrorExceptionGet the ledger index of a tx result response. If not present, throw an exception.- Returns:
- A string containing value of last validated ledger index.
- Throws:
JsonRpcClientErrorException
- when client encounters errors related to calling rippled JSON RPC API..
-
getValidatedTransaction
protected Optional<? extends TransactionResult<? extends Transaction>> getValidatedTransaction(Hash256 transactionHash) Get theTransactionResult
for the transaction with the hash transactionHash.- Parameters:
transactionHash
-Hash256
of the transaction to get the TransactionResult for.- Returns:
- the
TransactionResult
for a validated transaction and empty response for aTransaction
that is expired or not found.
-
ledgerGapsExistBetween
protected boolean ledgerGapsExistBetween(com.google.common.primitives.UnsignedLong submittedLedgerSequence, com.google.common.primitives.UnsignedLong lastLedgerSequence) Check if there missing ledgers in rippled in the given range.- Parameters:
submittedLedgerSequence
-LedgerIndex
at which theTransaction
was submitted on.lastLedgerSequence
- he ledger index/sequence of typeUnsignedInteger
after which the transaction will expire and won't be applied to the ledger.- Returns:
Boolean
to indicate if there are gaps in the ledger range.
-
isFinal
public Finality isFinal(Hash256 transactionHash, LedgerIndex submittedOnLedgerIndex, com.google.common.primitives.UnsignedInteger lastLedgerSequence, com.google.common.primitives.UnsignedInteger transactionAccountSequence, Address account) Check if the transaction is final on the ledger or not.- Parameters:
transactionHash
-Hash256
of the submitted transaction to check the status for.submittedOnLedgerIndex
-LedgerIndex
on which the transaction with hash transactionHash was submitted. This can be obtained from submit() response of the tx as validatedLedgerIndex.lastLedgerSequence
- The ledger index/sequence of typeUnsignedInteger
after which the transaction will expire and won't be applied to the ledger.transactionAccountSequence
- The sequence number of the account submitting theTransaction
. ATransaction
is only valid if the Sequence number is exactly 1 greater than the previous transaction from the same account.account
- The uniqueAddress
of the account that initiated this transaction.- Returns:
true
if theTransaction
is final/validated elsefalse
.
-
serverInformation
Get the "server_info" for the rippled nodeRippledServerInfo
, clio serverClioServerInfo
and reporting mode serverReportingModeServerInfo
. You should be able to handle all these response types asServerInfo
.- Returns:
- A
ServerInfoResult
containing information about the server. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.- See Also:
-
accountChannels
public AccountChannelsResult accountChannels(AccountChannelsRequestParams params) throws JsonRpcClientErrorException Get theAccountChannelsResult
for the account specified inparams
by making an account_channels method call.- Parameters:
params
- TheAccountChannelsRequestParams
to send in the request.- Returns:
- The
AccountChannelsResult
returned by the account_channels method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountCurrencies
public AccountCurrenciesResult accountCurrencies(AccountCurrenciesRequestParams params) throws JsonRpcClientErrorException Get theAccountCurrenciesResult
for the account specified inparams
by making an account_currencies method call.- Parameters:
params
- TheAccountCurrenciesRequestParams
to send in the request.- Returns:
- The
AccountCurrenciesResult
returned by the account_currencies method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountInfo
public AccountInfoResult accountInfo(AccountInfoRequestParams params) throws JsonRpcClientErrorException Get theAccountInfoResult
for the account specified inparams
by making an account_info method call.- Parameters:
params
- TheAccountInfoRequestParams
to send in the request.- Returns:
- The
AccountInfoResult
returned by the account_info method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountNfts
Return AccountNftsResult for anAddress
.- Parameters:
account
- to get the NFTs for.- Returns:
AccountNftsResult
containing list of accounts for an address.- Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountNfts
public AccountNftsResult accountNfts(AccountNftsRequestParams params) throws JsonRpcClientErrorException Get theAccountNftsResult
for the account specified inparams
by making an account_channels method call.- Parameters:
params
- TheAccountNftsRequestParams
to send in the request.- Returns:
- The
AccountNftsResult
returned by the account_nfts method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
nftBuyOffers
public NftBuyOffersResult nftBuyOffers(NftBuyOffersRequestParams params) throws JsonRpcClientErrorException Get theNftBuyOffersResult
for theNfTokenId
specified inparams
by making an nft_buy_offers method call.- Parameters:
params
- TheNftBuyOffersRequestParams
to send in the request.- Returns:
- The
NftBuyOffersResult
returned by the nft_buy_offers method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
nftSellOffers
public NftSellOffersResult nftSellOffers(NftSellOffersRequestParams params) throws JsonRpcClientErrorException Get theNftSellOffersResult
for theNfTokenId
specified inparams
by making an nft_sell_offers method call.- Parameters:
params
- TheNftSellOffersRequestParams
to send in the request.- Returns:
- The
NftSellOffersResult
returned by the nft_sell_offers method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
nftInfo
Returns information about a given NFT. This method is only supported on Clio servers. Sending this request to a Reporting Mode or rippled node will result in an exception.- Parameters:
params
- TheNftInfoRequestParams
to send in the request.- Returns:
- The
NftInfoResult
returned by thenft_info
method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error, or if the request was made to a non-Clio node.
-
accountObjects
public AccountObjectsResult accountObjects(AccountObjectsRequestParams params) throws JsonRpcClientErrorException Get theAccountObjectsResult
for the account specified inparams
by making an account_objects method call.- Parameters:
params
- TheAccountObjectsRequestParams
to send in the request.- Returns:
- The
AccountObjectsResult
returned by the account_objects method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountOffers
public AccountOffersResult accountOffers(AccountOffersRequestParams params) throws JsonRpcClientErrorException Get theAccountOffersResult
for the account specified inparams
by making an account_offers method call.- Parameters:
params
- TheAccountOffersRequestParams
to send in the request.- Returns:
- The
AccountOffersResult
returned by the account_offers method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
depositAuthorized
public DepositAuthorizedResult depositAuthorized(DepositAuthorizedRequestParams params) throws JsonRpcClientErrorException Indicates whether one account is authorized to send payments directly to another.- Parameters:
params
- ADepositAuthorizedRequestParams
to send in the request.- Returns:
- The
DepositAuthorizedResult
returned by the deposit_authorized method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountTransactions
public AccountTransactionsResult accountTransactions(Address address) throws JsonRpcClientErrorException Get theAccountTransactionsResult
for the specifiedaddress
by making an account_tx method call.- Parameters:
address
- TheAddress
of the account to request.- Returns:
- The
AccountTransactionsResult
returned by the account_tx method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountTransactions
public AccountTransactionsResult accountTransactions(AccountTransactionsRequestParams params) throws JsonRpcClientErrorException Get theAccountTransactionsResult
for the account specified inparams
by making an account_tx method call.- Parameters:
params
- TheAccountTransactionsRequestParams
to send in the request.- Returns:
- The
AccountTransactionsResult
returned by the account_tx method call. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
transaction
public <T extends Transaction> TransactionResult<T> transaction(TransactionRequestParams params, Class<T> transactionType) throws JsonRpcClientErrorException Get a transaction from the ledger by sending a tx method request.- Type Parameters:
T
- Type parameter for the type ofTransaction
that theTransactionResult
will- Parameters:
params
- TheTransactionRequestParams
to send in the request.transactionType
- TheTransaction
type of the transaction with the hashparams.transaction()
.- Returns:
- A
TransactionResult
containing the requested transaction and other metadata. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
ledger
Get the contents of a ledger by sending a ledger method request.- Parameters:
params
- TheLedgerRequestParams
to send in the request.- Returns:
- A
LedgerResult
containing the ledger details. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
ledgerEntry
public <T extends LedgerObject> LedgerEntryResult<T> ledgerEntry(LedgerEntryRequestParams<T> params) throws JsonRpcClientErrorException Retrieve aLedgerObject
by sending aledger_entry
RPC request.- Type Parameters:
T
- The type ofLedgerObject
that should be returned in rippled's response.- Parameters:
params
- ALedgerEntryRequestParams
containing the request parameters.- Returns:
- A
LedgerEntryResult
of typeXrplClient
. - Throws:
JsonRpcClientErrorException
-
ripplePathFind
public RipplePathFindResult ripplePathFind(RipplePathFindRequestParams params) throws JsonRpcClientErrorException Try to find a payment path for a rippling payment by sending a ripple_path_find method request.- Parameters:
params
- TheRipplePathFindRequestParams
to send in the request.- Returns:
- A
RipplePathFindResult
containing possible paths. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
bookOffers
public BookOffersResult bookOffers(BookOffersRequestParams params) throws JsonRpcClientErrorException Send abook_offers
RPC request.- Parameters:
params
- TheBookOffersRequestParams
to send in the request.- Returns:
- A
BookOffersResult
. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
accountLines
public AccountLinesResult accountLines(AccountLinesRequestParams params) throws JsonRpcClientErrorException Get the trust lines for a given account by sending an account_lines method request.- Parameters:
params
- TheAccountLinesRequestParams
to send in the request.- Returns:
- The
AccountLinesResult
containing the requested trust lines. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
channelVerify
public ChannelVerifyResult channelVerify(ChannelVerifyRequestParams params) throws JsonRpcClientErrorException Verify a payment channel claim signature by making a "channel_verify" rippled API method call.- Parameters:
params
- TheChannelVerifyRequestParams
to send in the request.- Returns:
- The result of the request, as a
ChannelVerifyResult
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
gatewayBalances
public GatewayBalancesResult gatewayBalances(GatewayBalancesRequestParams params) throws JsonRpcClientErrorException Get the issued currency balances of an issuing account by making a "gateway_balances" rippled API method call.- Parameters:
params
- TheGatewayBalancesRequestParams
to send in the request.- Returns:
- The result of the request, as a
GatewayBalancesResult
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
ammInfo
Get info about an AMM by making a call to the amm_info rippled RPC method.- Parameters:
params
- TheAmmInfoRequestParams
to send in the request.- Returns:
- A
AmmInfoResult
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
getJsonRpcClient
-