question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TransactionEnvelope & TransactionResult fromXRP methods throw error on blockchain data

See original GitHub issue

Describe the bug Greetings! Block Trac uses the stellar-sdk to subscribe to validated blocks and import transactions. When processing a recent block (38115807 @ 2021-11-03 15:00:15 UTC), we came across transaction ec6e4745f0ac7d7536dd4cebdd65a5c4ac7837e71aff2034cb52775ae7aaab9c which results in an error when parsed (see below)

What version are you on? 9.0.1

To Reproduce Run the following test script:

const StellarSdk = require('stellar-sdk')

var sdk = new StellarSdk.Server('https://horizon.stellar.org');

var transaction =
  sdk.transactions()
     .transaction("ec6e4745f0ac7d7536dd4cebdd65a5c4ac7837e71aff2034cb52775ae7aaab9c")
     .call()
     .then(function(tx){
       console.log(tx.hash);
       //console.log(JSON.stringify(tx, null, 2));
       console.log(StellarSdk.xdr.TransactionEnvelope.fromXDR(tx.envelope_xdr));
       console.log(StellarSdk.xdr.TransactionResult.fromXDR(tx.result_xdr));

     }).catch(function(e){
       console.log(e)
     });

To see the following output:

ec6e4745f0ac7d7536dd4cebdd65a5c4ac7837e71aff2034cb52775ae7aaab9c
Error: XDR Read Error: Unknown EnvelopeType member for value 1094795585
    at Function.read (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/enum.js:46:15)
    at Function.read (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/union.js:111:36)
    at Function.fromXDR (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/io-mixin.js:51:23)
    at /home/mmorsi/Workspace/exp/ss.js:12:55
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

If TransactionEnvelope.fromXDR is commented above, the following error is produced:

ec6e4745f0ac7d7536dd4cebdd65a5c4ac7837e71aff2034cb52775ae7aaab9c
Error: XDR Read Error: Unknown TransactionResultCode member for value 1111048513
    at Function.read (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/enum.js:46:15)
    at Function.read (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/union.js:111:36)
    at /home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/struct.js:57:26
    at arrayMap (/home/mmorsi/Workspace/exp/node_modules/lodash/_arrayMap.js:16:21)
    at map (/home/mmorsi/Workspace/exp/node_modules/lodash/map.js:50:10)
    at Function.read (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/struct.js:52:38)
    at Function.fromXDR (/home/mmorsi/Workspace/exp/node_modules/js-xdr/lib/io-mixin.js:51:23)
    at /home/mmorsi/Workspace/exp/ss.js:13:53
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Expected behavior The XDR should be successfully parsed and no error produced.

Additional context N/A. Thank you for the great library.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
movittocommented, Nov 4, 2021

👍 thanks @Shaptic it worked. Funny, we were having trouble yesterday parsing the XDR (passing the encoding in) but everything is back working. Chalk it up to a fluke, I apologize for the noise. Thanks again!

0reactions
Shapticcommented, Nov 4, 2021

Hah, got it. You need to pass the encoding type to fromXDR, which defaults to "raw". If you pass "base64", it will work! You can also use the helper StellarSdk.TransactionBuilder.fromXDR(tx.envelope_xdr, StellarSdk.Networks.PUBLIC) which will give you a nicer structure to work with (i.e. a StellarSdk.Transaction instance rather than a raw StellarSdk.xdr.Transaction).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn best practices for debugging and error handling in an ...
Blockchain is a shared, replicated immutable ledger for recording transactions, tracking assets, and building trust.
Read more >
The Truth About Blockchain - Harvard Business Review
If a stock transaction took place on a blockchain-based system, it would be settled within seconds, securely and verifiably.
Read more >
Blockchain Facts: What Is It, How It Works, and How It Can Be ...
A blockchain is a distributed database or ledger that is shared among the nodes of a computer network. As a database, a blockchain...
Read more >
Blockchain - Wikipedia
A blockchain is a type of distributed ledger technology (DLT) that consists of growing lists of records, called blocks, that are securely linked...
Read more >
Blockchain For Health Data and Its Potential Use in Health IT ...
Due to improvements in genetic research and the advancement of precision medicine, health care is witnessing an innovative approach to disease prevention and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found