0

I am new to stellar develop. Recently I got an issue when running some code that was fine before. The code is trying to get a transaction from a transaction response. Here is the code,

public Transaction getTransaction(TransactionResponse transactionResponse) 
{
   byte[] bytes = Base64.getDecoder().decode(transactionResponse.getEnvelopeXdr());
   TransactionEnvelope transactionEnvelope = TransactionEnvelope.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
   return transactionEnvelope.getTx();
}

This code runs fine before, but recently it always give errors "java.lang.RuntimeException: Unknown enum value: 2" at TransactionEnvelope.decode (the second line).

Does anyone know why? Is this the right way to get a transaction from a transactionResponse. I have tested the string from transactionResponse.getEnvelopeXdr() in Stellar lab, it can show the whole transaction envelope.

https://laboratory.stellar.org/#xdr-viewer?input=AAAAAgAAAADuwuGFfkhi4WtXmr%2FHNUPoa6f6kNO1i01zSgLIo0HfwAAAAGQAAFMzAAAAOAAAAAEAAAAAAAAAAAAAAABe0cHSAAAAAAAAAAEAAAAAAAAAAAAAAAC%2BddPLMNHMNvTJNrvSWog9oZT2LfyVba3szRUCd9t%2BIwAAAAABfXnQAAAAAAAAAAGjQd%2FAAAAAQPtIamlP8kkZZ1X6n7LaLIRW9bC96xg7kAz0TA4lXxfIAKBLdot5tZoyKLgM2kidr6jXgOpzCFZfvT%2FjnDttngI%3D&type=TransactionEnvelope&network=test

Thank you for help!

2
  • the code is using stellar sdk 0.6.0 and I see the latest version is 0.17.0, is that possible that this issue is due to version. – Ming Wu Jun 3 '20 at 22:27
  • Thanks, Johan. I have contacted java stellar sdk github and I was told that it is due to the version. I have to use the latest version. However, I can not find any insruction on how to get a transaction from a transaction response using the latest version. Just wondering whether you have any idea on it or know where I can find the right documentation. Thanks – Ming Wu Jun 8 '20 at 3:45

Your Answer

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

Browse other questions tagged or ask your own question.