indutny / bn.js

BigNum in pure javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with 2,100,000,000,000,000,000 satoshi

sengtha opened this issue · comments

I am using @RavenDevKit lib with also use BN.js to send asset on Ravencoin blockchain.
When I try to send 21,000,000,000 unit, I got error "Assertion failed". This error happened at

  `assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  this.words = [
    number & 0x3ffffff,
    (number / 0x4000000) & 0x3ffffff,
    1
  ];
  this.length = 3;`

Does anyone know the solution? Thanks

Because it's not safe to use numbers more than Number.MAX_SAFE_INTEGER in JS. If you want create bn.js instance for such number you can pass argument as string.