denpamusic / php-bitcoinrpc

Fully unit-tested Bitcoin JSON-RPC client based on GuzzleHttp.
MIT License
282 stars 100 forks source link

to_satoshi() breaks when dealing with large numbers #47

Closed partyka1 closed 5 years ago

partyka1 commented 5 years ago

Describe the bug Trying to run to_satoshi on big btc value(ie 2.1 mln), resulted in return value 0. This pull request aims to fix that, mostly by fixing castings and adding bcmul

To Reproduce

>>> \Denpa\Bitcoin\to_satoshi('2100')
=> "210000000000"
>>> \Denpa\Bitcoin\to_satoshi('21000')
=> "2100000000000"
>>> \Denpa\Bitcoin\to_satoshi('210000')
=> "21000000000000"
>>> \Denpa\Bitcoin\to_satoshi('2100000')
=> "0"
>>> \Denpa\Bitcoin\to_satoshi('21000000')
=> "0"
denpamusic commented 5 years ago

Thank you for your contribution! Sorry for long wait - didn't have enough time to work on this.

partyka1 commented 5 years ago

no worries! I hope nobody lost any big monies because of it 🙃🙂🙃