0
I am developing a bitcoin wallet for education purposes, and i'm working on a getbalance method that given an address i return the balance of the address.
Problem is, when communicating via the RPC protocol i am given the amount in a double format rather than satoshi (int). And i would like to provide the amount in Satoshi's.
How do i properly convert the double amount, into uint64 satoshi amount? Since double is not an accurate value, how do I make sure that my "users" get the correct value for their balance, or on their transactions?
Thanks,
Thank you for your quick reply! I'm using jsonrpccpp to communicate with the bitcoin core using RPC. Since you say that the bitcoin core is accurate, the jsonrpccpp allows me to parse the information and view the amount as Double, String etc. Double seems to be the correct amount. how do i make sure, that the parser it self stores it correctly? – Haim – 2019-03-13T09:28:50.423
I suggest that you store it as a string and not as a double. – Andrew Chow – 2019-03-13T14:40:08.887
i tried your approach. I've converted 0.00018281 BTC to Satoshi's in two ways. from double i got 18281 Satoshi's and from string i got 18280999999999999 satoshi's. it seems like the string isn't converting the value properly (from the jsonrpccpp). any suggestions? (all i did in the string was to remove the '.' character) – Haim – 2019-03-14T07:27:55.177
Sorry, I am not familiar with how jsonrpccpp works. – Andrew Chow – 2019-03-14T14:52:31.360