CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
112 stars 79 forks source link

Rounding error when determining fee for Contract Transaction #146

Open jimtendo opened 1 year ago

jimtendo commented 1 year ago

[In ](bitcoincash:pr0qgla00u9rq34pael3ayjf7tuqm2p3kyyrvzcsak) the following line can sometimes lead to an incorrect fee as it does a Math.ceil on the value.

This means that if JS's Math engine, for example, gave a result of something like 620.00000001 in the preceding math, the Math.ceil() would round this up to 621, causing an off-by-one error.

Math.round() will probably resolve this as, even with JS Math's inconsistencies, it should always round back to the correct target integer.