I need to get the transaction records. This information seems to be in XDR. How can I parse it in Java?
4 Answers
To get the last transactions you can make a request to an Horizon server, if you don't have one you can use public horizon server (horizon.stellar.org) but its limited.
For query transactions you have to call transactions endpoint HERE AN EXAMPLE as you can see there are also human readble informations isn't necessary translating from XDR.
Here the infos that you can receive from transactions' endpoint
- Transaction's ID/Hash
- Paging_token
- Ledger count
- created_at (datetime of transaction)
- source_account
- source_account_sequence (sequence number of source account's transaction)
- fee_paid (in stroops)
- operation_count
- memo_type
- memo (content of memo field)
I have just written a patch for the Java SDK to deserialize TransactionEnvelope XDR.
https://github.com/stellar/java-stellar-sdk/pull/117
If you can wait, hopefully it will be approved and merged. After which you can simply call Transaction.fromEnvelopeXdrBase64(base64String)
.
If you can't wait, you can copy the code in that PR directly to your project. Specifically, this method and the methods it calls.
If you have the Transaction XDR encoded as a base64 string, you can use Transaction.fromEnvelopeXdr(string)
to get a Transaction
object back.
The XDR classes in the sdk are generated using xdrgen from the xdr idl files in stellar core. So if you want to parse XDR either use the stubs in the sdk or generate them yourself using that.