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

Invalid block balance weirdness #60

Open
neurofluxation opened this issue Jun 17, 2019 · 4 comments
Open

Invalid block balance weirdness #60

neurofluxation opened this issue Jun 17, 2019 · 4 comments

Comments

@neurofluxation
Copy link

neurofluxation commented Jun 17, 2019

Hey there (yet again),

So I have been getting an invalid block balance when mining an empty block all of a sudden and I can't seem to work out why. Doesn't matter if I restart the blockchain or not. Seems to happen randomly.

This is the exact error:
Invalid block balance: inputs sum '46.04300000000003', outputs sum '46.04300000000004

Obviously the amounts will differ, it's been bugging me for a while now.

Thanks!

Edit:
Here's my config...
https://i.imgur.com/FA0TWEt.png

@neurofluxation
Copy link
Author

Bump. I have found out nothing more, this just seem to "happen" after running for a while...?

@JSKitty
Copy link
Contributor

JSKitty commented Oct 18, 2019

This is due to the weirdness in JavaScript's float processing.
Whatever you do, do NOT use floats in a blockchain / cryptocurrency, it's a road to doom haha.
Instead, use full integers as "Satoshis". And on the interface of the wallet / terminal, display those divided by 100,000,000 (If you're wanting 8 decimal places, like Bitcoin).
And also make sure to round to the nearest integer during operations like multiplication/division, juuust to ensure JS doesn't pull any tricks.

If you want a package designed for handling these kind of numbers, try "bignum" packages.

@neurofluxation
Copy link
Author

Good Kitty - Thank you, solved!

@NetOpWibby
Copy link

BigInt is a thing now so native JS should work.

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

3 participants