Package org.xrpl.xrpl4j.client
Class XrplClient
- java.lang.Object
-
- org.xrpl.xrpl4j.client.XrplClient
-
@Beta public class XrplClient extends Object
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 Constructor Description XrplClient(okhttp3.HttpUrl rippledUrl)
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccountChannelsResult
accountChannels(AccountChannelsRequestParams params)
Get theAccountChannelsResult
for the account specified inparams
by making an account_channels method call.AccountCurrenciesResult
accountCurrencies(AccountCurrenciesRequestParams params)
Get theAccountCurrenciesResult
for the account specified inparams
by making an account_currencies method call.AccountInfoResult
accountInfo(AccountInfoRequestParams params)
Get theAccountInfoResult
for the account specified inparams
by making an account_info method call.AccountLinesResult
accountLines(AccountLinesRequestParams params)
Get the trust lines for a given account by sending an account_lines method request.AccountObjectsResult
accountObjects(AccountObjectsRequestParams params)
Get theAccountObjectsResult
for the account specified inparams
by making an account_objects method call.AccountOffersResult
accountOffers(AccountCurrenciesRequestParams params)
Get theAccountOffersResult
for the account specified inparams
by making an account_offers method call.AccountTransactionsResult
accountTransactions(AccountTransactionsRequestParams params)
Get theAccountTransactionsResult
for the account specified inparams
by making an account_tx method call.AccountTransactionsResult
accountTransactions(Address address)
Get theAccountTransactionsResult
for the specifiedaddress
by making an account_tx method call.ChannelVerifyResult
channelVerify(Hash256 channelId, XrpCurrencyAmount amount, String signature, String publicKey)
Verify a payment channel claim signature by making a "channel_verify" rippled API method call.DepositAuthorizedResult
depositAuthorized(DepositAuthorizedRequestParams params)
Indicates whether one account is authorized to send payments directly to another.FeeResult
fee()
Get the current state of the open-ledger requirements for transaction costs.JsonRpcClient
getJsonRpcClient()
LedgerResult
ledger(LedgerRequestParams params)
Get the contents of a ledger by sending a ledger method request.RipplePathFindResult
ripplePathFind(RipplePathFindRequestParams params)
Try to find a payment path for a rippling payment by sending a ripple_path_find method request.ServerInfo
serverInfo()
Get the "server_info" for the rippled node.<T extends Transaction>
SignedTransaction<T>signTransaction(Wallet wallet, T unsignedTransaction)
Sign aTransaction
with the private key from aWallet
.<T extends Transaction>
SubmitResult<T>submit(SignedTransaction signedTransaction)
Submit aSignedTransaction
to the XRP Ledger.<T extends Transaction>
SubmitResult<T>submit(SignedTransaction<T> signedTransaction)
Submit aSignedTransaction
to the ledger.<T extends Transaction>
SubmitResult<T>submit(Wallet wallet, T unsignedTransaction)
Submit aTransaction
to the XRP Ledger.<T extends Transaction>
SubmitMultiSignedResult<T>submitMultisigned(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.
-
-
-
Method Detail
-
submit
public <T extends Transaction> SubmitResult<T> submit(Wallet wallet, T unsignedTransaction) throws JsonRpcClientErrorException
Submit aTransaction
to the XRP Ledger.- Type Parameters:
T
- The type ofTransaction
that is being submitted.- Parameters:
wallet
- TheWallet
of the XRPL account submittingunsignedTransaction
.unsignedTransaction
- An unsignedTransaction
to submit.Transaction.transactionSignature()
must not be provided, andTransaction.signingPublicKey()
must be provided.- Returns:
- The
SubmitResult
resulting from the submission request. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.- See Also:
- "https://xrpl.org/submit.html"
-
submit
public <T extends Transaction> SubmitResult<T> submit(SignedTransaction<T> signedTransaction) throws JsonRpcClientErrorException
Submit aSignedTransaction
to the ledger.- Type Parameters:
T
- The type ofTransaction
contained in theSignedTransaction
object.- Parameters:
signedTransaction
- ASignedTransaction
to submit.- Returns:
- The
SubmitResult
resulting from the submission request. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.
-
submit
public <T extends Transaction> SubmitResult<T> submit(SignedTransaction signedTransaction) throws JsonRpcClientErrorException, com.fasterxml.jackson.core.JsonProcessingException
Submit aSignedTransaction
to the XRP Ledger.- Type Parameters:
T
- The type of signedTransaction
that is being submitted.- Parameters:
signedTransaction
- ASignedTransaction
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:
- "https://xrpl.org/submit.html"
-
submitMultisigned
public <T extends Transaction> SubmitMultiSignedResult<T> submitMultisigned(T transaction) throws JsonRpcClientErrorException
Submit a multisignedTransaction
to the ledger.- Type Parameters:
T
- A type parameter for the type ofTransaction
being submitted.- Parameters:
transaction
- A multisignedTransaction
.- Returns:
- A
SubmitMultiSignedResult
of typeXrplClient
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
fee
public FeeResult fee() throws JsonRpcClientErrorException
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:
- "https://xrpl.org/fee.html"
-
serverInfo
public ServerInfo serverInfo() throws JsonRpcClientErrorException
Get the "server_info" for the rippled node.- Returns:
- A
ServerInfo
containing information about the server. - Throws:
JsonRpcClientErrorException
- IfjsonRpcClient
throws an error.- See Also:
- "https://xrpl.org/server_info.html"
-
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.
-
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(AccountCurrenciesRequestParams 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
public LedgerResult ledger(LedgerRequestParams params) throws JsonRpcClientErrorException
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.
-
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.
-
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(Hash256 channelId, XrpCurrencyAmount amount, String signature, String publicKey) throws JsonRpcClientErrorException
Verify a payment channel claim signature by making a "channel_verify" rippled API method call.- Parameters:
channelId
- AHash256
containing the Channel ID.amount
- AnXrpCurrencyAmount
representing the amount of the claim.signature
- The signature of thePaymentChannelClaim
transaction.publicKey
- AString
containing the public key associated with the key used to generate the signature.- Returns:
- The result of the request, as a
ChannelVerifyResult
. - Throws:
JsonRpcClientErrorException
- ifjsonRpcClient
throws an error.
-
signTransaction
public <T extends Transaction> SignedTransaction<T> signTransaction(Wallet wallet, T unsignedTransaction)
Sign aTransaction
with the private key from aWallet
.- Type Parameters:
T
- The actual polymorphic type ofTransaction
to sign.- Parameters:
wallet
- AWallet
with a private key to sign the transaction with.unsignedTransaction
- ATransaction
without a signature.- Returns:
- A
SignedTransaction
.
-
getJsonRpcClient
public JsonRpcClient getJsonRpcClient()
-
-