I am using the Stellar Java SDK to submit a PathPaymentStrictReceiveOperation transaction. I get back a SubmitTransactionResponse object. I would like to get the results of the (successful) transaction, specifically I would like to find out how much was actually sent and received (the equivalent of PathPaymentBaseOperationResponse) but I cannot see how to achieve that using the SDK.

I see that SubmitTransactionResponse has a getResultXdr() method, and using the decoder at https://laboratory.stellar.org/#xdr-viewer? I can see that has the information I want to access from the code, but I do not see any method in the SDK which would allow me to decode the result.

Anyone have any hints, or sample code?

1 Answer 1


Answering my own question in case it is useful to someone else in future. You seem to need to use the classes from package org.stellar.sdk.xdr even though that package is undocumented in the Java SDK.

Here is an example:

 SubmitTransactionResponse tr = server.submitTransaction(transaction);
 if (tr.usSuccess()) {
            Optional<TransactionResult> optionalDecodedTransactionResult = tr.getDecodedTransactionResult();
            TransactionResult decodedTransactionResult = optionalDecodedTransactionResult.get();
            TransactionResult.TransactionResultResult result = decodedTransactionResult.getResult();
            OperationResult opInner = result.getResults()[0];
            OperationResult.OperationResultTr tr1 = opInner.getTr();
            PathPaymentStrictReceiveResult pathPaymentStrictReceiveResult = tr1.getPathPaymentStrictReceiveResult();
            PathPaymentStrictReceiveResult.PathPaymentStrictReceiveResultSuccess success = pathPaymentStrictReceiveResult.getSuccess();
            SimplePaymentResult last = success.getLast();
            Int64 amount = last.getAmount();
            ClaimOfferAtom[] offers = success.getOffers();
            for (var offer : offers) {
                Int64 amountBought = offer.getAmountBought();
                Int64 amountSold = offer.getAmountSold();
                Int64 offerID = offer.getOfferID();
                Asset assetBought = Asset.fromXdr(offer.getAssetBought());
                System.out.println(amountBought.getInt64()+" "+amountSold.getInt64()+" "+offerID.getInt64()+" "+assetBought);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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