Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding transaction with algosdk.decodeObj fails #433

Open
hernandp opened this issue Sep 4, 2021 · 2 comments
Open

Decoding transaction with algosdk.decodeObj fails #433

hernandp opened this issue Sep 4, 2021 · 2 comments
Labels

Comments

@hernandp
Copy link

hernandp commented Sep 4, 2021

Subject of the issue

Decoding transaction using algosdk.decodeObj will fail. The same procedure using msgpack-lite decode function will go thru without problems.

Your environment

Steps to reproduce

  1. Read the attached TXN file
  2. Decode using algosdk.decodeObj( ... )

Expected behaviour

As msgpack-lite decode function output:

 msgpack.decode(tx)
{
  fee: 1000,
  fv: 16011880,
  lv: 16012880,
  snd: <Buffer 9c ca 3c ee a0 28 af 2f a2 0a f4 01 1b da 0d 2c 37 0d 90 1d 40 c7 35 d0 79 c9 45 a3 3c 32 c1 ba>,
  type: 'appl',
  gen: 'mainnet-v1.0',
  gh: <Buffer c0 61 c4 d8 fc 1d bd de d2 d7 60 4b e4 56 8e 3f 6d 04 19 87 ac 37 bd e4 b6 20 b5 ab 39 24 8a df>,
  apid: 320310902,
  apaa: [
    <Buffer 69 41>,
    <Buffer 00 00 00 00 13 16 c4 98>,
    <Buffer 02 20 03 f6 9c de 98 01 00 02 26 01>,
    <Buffer ba 28 48 33 00 18 22 12 33 00 19 23 12 33 00 19 24 12 11 10 31 16 23 13 10 37 00 1c 01 31 00 12 10 31 20 32 03 12 10>
  ]
}

Actual behaviour

 algosdk.decodeObj(tx)
Uncaught RangeError: Extra 157 of 368 byte(s) found at buffer[211]
    at Decoder.createNoExtraBytesError (C:\src\multisig-dispatcher\node_modules\algo-msgpack-with-bigint\dist\Decoder.js:78:16)
    at Decoder.doDecodeSingleSync (C:\src\multisig-dispatcher\node_modules\algo-msgpack-with-bigint\dist\Decoder.js:88:24)
    at Decoder.decode (C:\src\multisig-dispatcher\node_modules\algo-msgpack-with-bigint\dist\Decoder.js:83:21)
    at Object.decode (C:\src\multisig-dispatcher\node_modules\algo-msgpack-with-bigint\dist\decode.js:13:20)
    at Object.decode (C:\src\multisig-dispatcher\node_modules\algosdk\dist\cjs\src\encoding\encoding.js:71:20)
    at Object.decodeObj (C:\src\multisig-dispatcher\node_modules\algosdk\dist\cjs\src\main.js:210:21)
>
@hernandp hernandp added the new-bug Bug report that needs triage label Sep 4, 2021
@hernandp
Copy link
Author

hernandp commented Sep 4, 2021

Test file:

init-app-mainnet.zip

@AlgoDoggo
Copy link
Contributor

This RangeError means you have probably several msgpack object encoded in a single buffer. msgpack-lite is decoding the first one without alerting you there is more data to the buffer, the better behavior is to throw the error.

If your example errors at position 211 try slicing the buffer and decoding the following: tx.slice(0,211) and tx.slice(211).

We could add a method to decode multiple mspack objects to make this easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@hernandp @yaovi-a @AlgoDoggo and others