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
Rounding error and incorrect fee #1174
Comments
Can you show the part of the code where you created the transaction please? We'll investigate |
I did something like var amount = 81.99 * 100000;
var fee = 1000;
var tx = new bitcore.Transaction().
from(cachedOutputs).
to(toAddress, amount).
fee(fee); Do you need a full working example? |
Please note that JavaScript has some problems when dealing with different bitcoin units. That's why we built the
could this be the problem? |
Thanks, good to know about
|
aaah, I missunderstood your two points, sorry. Yes, I agree with your two ideas. I'll move this issue to "ready". Feel free to implement this fixes in a PR, or we'll look at it in the future |
I may try next weekend but it's a bit of a hassle since my employer needs to approve before I can contribute code to an open source project. So don't hold your breath. |
gulp test runs all the tests. Is there a way to run only an individual test? |
In development, you can append
you can also run just one file with:
|
Where would I write this it.only? And what would I then do to run that test? What exactly do you mean by "in development"? Is there maybe some guide I should read that explains all of this? I found https://github.com/bitpay/bitcore/blob/master/CONTRIBUTING.md but it only talks about coding style and briefly about pull requests, unless I missed a section. By the way, I tried Unit but Transaction.to() doesn't actually accept a Unit amount. It passes the Unit to a BN which crashes because it isn't a number. |
What's the best way to get some help contributing? Maybe not on this issue thread? |
Let's chat on IRC, you can find me on #bitcoin-dev, #bitcoin, #bitcoinjs-dev, etc on freenode. Ping me |
IRC doesn't seem to work very well. I seem to have been disconnected so I don't know if you answered my last question. Can you tell me what your development cycle is? What do you do after making a small change to see if it fixed a particular test? Do you let gulp fire up a bunch of browsers or is there a way where you just reload a single page in an existing browser and run only a few tests? |
you can run a single test with
If you don't want to run tests using karma, you can try opening the https://github.com/bitpay/bitcore/blob/master/test/index.html in your browser ( |
Part 1 should be fixed in: 3005e19 |
Part 2 fixed in #1214 |
Thanks dskloet, for contributing this fix! You're welcome! |
Thanks for the contribution :) |
I enjoyed it :). Hopefully I can do more in the future. |
Great work @dskloet ! |
I tried to create a transaction with an output of 81.99 mBTC and a fee of 10 bits. But because 81.99 * 100000 becomes 8198999.999999999 I actually created a transaction with a non-integer amount of satoshis. This should simply have failed (or at most rounded to 81.99000 satoshis) but instead bitcore seems to have truncated it down to 8198999 satoshis because the resulting transaction was:
https://test-insight.bitpay.com/tx/8ed23b2513a8960e78602d2fb5b9e12eb7ba922f63ada6ddc4a75faf44f50e31
Since I didn't specify a change address, this also affected the fee, which became 1001 even though I explicitly specified it to be 1000.
So I see 2 bugs here:
The text was updated successfully, but these errors were encountered: