{"action":"created","issue":{"url":"https://api.github.com/repos/bitpay/bitcore/issues/1174","labels_url":"https://api.github.com/repos/bitpay/bitcore/issues/1174/labels{/name}","comments_url":"https://api.github.com/repos/bitpay/bitcore/issues/1174/comments","events_url":"https://api.github.com/repos/bitpay/bitcore/issues/1174/events","html_url":"https://github.com/bitpay/bitcore/issues/1174","id":66465107,"number":1174,"title":"Rounding error and incorrect fee","user":{"login":"dskloet","id":6271274,"avatar_url":"https://avatars.githubusercontent.com/u/6271274?v=3","gravatar_id":"","url":"https://api.github.com/users/dskloet","html_url":"https://github.com/dskloet","followers_url":"https://api.github.com/users/dskloet/followers","following_url":"https://api.github.com/users/dskloet/following{/other_user}","gists_url":"https://api.github.com/users/dskloet/gists{/gist_id}","starred_url":"https://api.github.com/users/dskloet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dskloet/subscriptions","organizations_url":"https://api.github.com/users/dskloet/orgs","repos_url":"https://api.github.com/users/dskloet/repos","events_url":"https://api.github.com/users/dskloet/events{/privacy}","received_events_url":"https://api.github.com/users/dskloet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-05T18:00:21Z","updated_at":"2015-04-06T19:37:30Z","closed_at":null,"body":"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:\r\n\r\nhttps://test-insight.bitpay.com/tx/8ed23b2513a8960e78602d2fb5b9e12eb7ba922f63ada6ddc4a75faf44f50e31\r\n\r\nSince I didn't specify a change address, this also affected the fee, which became 1001 even though I explicitly specified it to be 1000.\r\n\r\nSo I see 2 bugs here:\r\n1. A non-integer amount of satoshis was truncated without error.\r\n2. A transaction was serialized with a fee different from the explicitly specified fee."},"comment":{"url":"https://api.github.com/repos/bitpay/bitcore/issues/comments/90210291","html_url":"https://github.com/bitpay/bitcore/issues/1174#issuecomment-90210291","issue_url":"https://api.github.com/repos/bitpay/bitcore/issues/1174","id":90210291,"user":{"login":"maraoz","id":287189,"avatar_url":"https://avatars.githubusercontent.com/u/287189?v=3","gravatar_id":"","url":"https://api.github.com/users/maraoz","html_url":"https://github.com/maraoz","followers_url":"https://api.github.com/users/maraoz/followers","following_url":"https://api.github.com/users/maraoz/following{/other_user}","gists_url":"https://api.github.com/users/maraoz/gists{/gist_id}","starred_url":"https://api.github.com/users/maraoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maraoz/subscriptions","organizations_url":"https://api.github.com/users/maraoz/orgs","repos_url":"https://api.github.com/users/maraoz/repos","events_url":"https://api.github.com/users/maraoz/events{/privacy}","received_events_url":"https://api.github.com/users/maraoz/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T19:37:30Z","updated_at":"2015-04-06T19:37:30Z","body":"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"}}