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

got "0xNaN" when rlp decode number field #4

Closed
eiTT-01 opened this issue Aug 9, 2018 · 0 comments
Closed

got "0xNaN" when rlp decode number field #4

eiTT-01 opened this issue Aug 9, 2018 · 0 comments

Comments

@eiTT-01
Copy link

eiTT-01 commented Aug 9, 2018

Description

When I try to decode a raw tx and then retrive its transaction id or singer, I just got null. After that I found it's caused by rlp decode.

Actual behavior


let clauses = [{
    to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed',
    value: 0,
    data: '0x'
}]

let body = {
    chainTag: 0x9a,
    blockRef: '0x0000000000000000',
    expiration: 32,
    clauses: clauses,
    gasPriceCoef: 0,
    gas: 21000,
    dependsOn: null,
    nonce: 12345678
}

let tx = new Transaction(body)
let signingHash = cry.blake2b256(tx.encode())
tx.signature = cry.secp256k1.sign(signingHash, /* private key here */)

let raw = tx.encode()
let decoded = Transaction.decode(raw)

Decoded Transactin:

{
  "body": {
    "chainTag": 154,
    "blockRef": "0x0000000000000000",
    "expiration": 32,
    "clauses": [
      {
        "to": "0x7567d83b7b8d80addcb281a71d54fc7b3364ffed",
        "value": "0xNaN", // wrong
        "data": "0x"
      }
    ],
    "gasPriceCoef": "0xNaN", // wrong
    "gas": 21000,
    "dependsOn": null,
    "nonce": 12345678,
    "reserved": []
  },
  "signature": / * sig buffer */
  }
}

Suggestion

update rlp.ts file:

#89 const bn = new BigNumber('0x' + buf.toString('hex'))

to:

#89 const bn = new BigNumber(buf.toString('hex'), 16)

@qianbin qianbin closed this as completed in a09b010 Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant