2

I want to display all transactions of given users. Using the Java API, I presume I would do:

server.transactions().forAccount(destination2).execute();

I would then page through the result. Each item would be a TransactionResponse instance. Now from this, one of things I want to retrieve is the amount of the transaction. Yet, I don't see any field that could represent this. Here is a TransactionResponse.java source code I looked at.

Thoughts?

2

In this particular case you should use server.payments().forAccount(destination2) (if you want to track only payments) or server.operations().forAccount(destination2) (for all operation types) because a transaction itself does not transfer any funds. Think of it as a batch (unit of work) that contains one or more operations.

Read more about transaction and operation concepts.

  • Thanks. This is weird. I looked at payments() at it returns OperationResponse object. What I would need is PaymentOperationResponse. However, casting that the result of payments() to PaymentOperationResponse results in ClassCastException. I searched through the java-stellar-sdk and PaymentOperationResponse is used nowehere except for test deserialization classes. What am I missing? – Klaus Jun 5 '18 at 18:54
  • 2
    Ok. Got it. The results of payments() are different types. Some are CreateAccountOperationResponse and others are PaymentOperationResponse. So I have to check each type and figure out what it is and cast accordingly. – Klaus Jun 5 '18 at 19:04
  • 1
    Recent Horizon versions also include account_merge operations (AccountMergeOperationResponse) in /payments. – Bartek Nowotarski Jun 6 '18 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.