3

I am currently working with a number of altcoins and and I need to support deposits and withdrawals in currencies with very large coin number cap like Dogecoin. I am wondering whether the Bitcoin Core client that is the basis for such altcoin clients supports such high denomination currencies internally and in its API (for example, when calling getbalance can it display balances of 10^12 coins with a precision of 1 satoshi?), or is there a limit to the precision used?

2

As Gracchus said, Bitcoin internally uses 64bit integers. Bitcoin's JSON interface on the other hand uses doubles, which give only 52 bit precision. Both types are big enough for bitcoin (double only for data exchange, the precision of doubles is not enough for actual calculations).

In the specific case of Dogecoin, the precision of the JSON interface (and parts of the GUI) is a known problem which we hope to fix in the future. Handling values in the range of hundreeds of million of dogecoin suffers from this currently.

The internally used 64bit integers are also a problem for Dogecoin which is being tracked. This is mostly a problem if anyone ever accumulates at leastn 2^64 Koinu (Satoshi) in a single wallet. This problem should be limited to the wallet, on the protocol level the size of transactions is limited to 10 billion doge.

I don't know how other coins handle this. There's at least one coin out there which supports arbitrary precision, but I forgot its name.

  • @Gracchus Floats are the textbook no-nos. Doubles less so. They appear to have 15 significant digits of precision, so unless you have 10^7 coins, you are still right down to a satoshi. – ThePiachu May 15 '14 at 3:47
  • Doubles are unusable as an internal format for Bitcoins (precision loss due to operations), but they are just big enough to convert a number in Satoshis into an number in BTC or the other way around. They are convienient enough to be "abused" for that by Bitcoin Core. – Jannis Froese May 15 '14 at 16:14
3

It appears as if the official client is using qint64, so there will be no resolution past the decimal point. The max value is bigger than Bitcoin's expected max.

Just use the same data types as the coins in question, and you should be ok.

You could use arbitrary precision for microbalances in your own app, but you won't be able to transfer them on the official blockchain. Others might support arbitrary precision, but I haven't seen one yet that does.

  • Well, the JSON API doesn't display balances in satoshis, but in BTC. How is that handled? – ThePiachu May 14 '14 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.