Post
Topic
Board Development & Technical Discussion
Re: Best data type for Bitcoin in go
by
ETFbitcoin
on 24/10/2018, 17:32:46 UTC
I just remember BIP70 about Payment Protocol (or usually referred as Payment Request) uses uint64. Almost all wallet these days recognize it, so IMO it's safe option.
But you can choose any data type for storing amount/balance, as long as it's not overflow. Even custom decimal configuration (if programming language or SQL database support it) such as decimal(7,8) would work.

That's the issue, what if a conversion goes bad and a user gets in his balance 1000's of bitcoin?

If you get the amount from another nodes/server, you simply need to find out data type they uses. For example, JSON-RPC used by Bitcoin core uses double.
If you get the amount from input from user, just specify default Bitcoin unit (BTC, mBTC or Satoshi) and there won't be any problem.


I never learn golang, but yes since i (and perhaps you) don't know standard that bitcoin and golang uses.