2

I can use the following code from example to receive payment event from public horizon. But the pos variable doesn't have memo information. Where should I get the memo from a certain paymente operation response?

paymentsRequest.stream(new EventListener<OperationResponse>() {
    @Override   public void onEvent(OperationResponse payment) {
    // Record the paging token so we can start from here next time.
    savePagingToken(payment.getPagingToken());
3

Memo can only be attached to a transaction, not operation. So you should rather listen to transactions stream or load a corresponding transaction by hash once a payment received.

The first option is better because transaction response contains XDR from which all related operations can be deserialized, while the second variant requires additional horizon requests.

  • Thanks. I was trying to use transaction with "now" cursor but the stream stuck for a while and after that, onEvent was not called when a transaction happened. If I don't use "now", everything is fine, except it processed every transactions. Do you have such experience? – Hai Bi Feb 4 '18 at 2:58
  • Plus, I got getMemo(), but only showed somethign like org.stellar.skdk.MemoText@5ea8cf9f. How do I change to text? – Hai Bi Feb 4 '18 at 3:22
  • There is another option. Prepare request builder for transactions, set limit to 1 and execute it. Once you get the response, you have a paging_token for the streaming mode. Create one more request builder and specify the obtained paging_token as a cursor. Such approach requires two requests instead of one, but 100% works. – Orbit Lens Feb 4 '18 at 3:25
  • MemoText is a class (check stellar.github.io/java-stellar-sdk/org/stellar/sdk/…), use getText() method to retrieve the content. – Orbit Lens Feb 4 '18 at 3:28

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.