2

The Bitcoin RPC calls all use 8 digit decimals ('reals') to encode amounts of satoshis. For example, if I get a transaction output, it might look like this:

{
  "value" : 0.00050000,
  "n" : 1,
  "scriptPubKey" : {
  "asm" : "OP_HASH160 c6e0b29d2aa23b6436cec99e65dfeed2c64a2cad OP_EQUAL",
  "hex" : "a914c6e0b29d2aa23b6436cec99e65dfeed2c64a2cad87",
  "reqSigs" : 1,
  "type" : "scripthash",
  "addresses" : [
    "3KpatoAjz3H5huJJieSpH4j7qFUeTXMnFC"
  ]
}

Is there a reason the developers decided to work with "0.00050000" instead of just "50000"? A whole number seems like it would be better for computers to work with.


EDIT: I guess the other half of this is that if the RPC calls are being used by a person, then it is easier to use with amounts in decimals (a human can tell the difference between 5.5 and 0.55 a lot easier than 55000000 and 5500000). So I guess the real question is, is the RPC interface meant to be used more for human command line use or for coding applications' use?

1 Answer 1

3

I would say the RPC interface is intended mainly as an application interface, but it's also meant to be simple enough for a human to use. And the computer cares less than you think.

For human users, using decimal bitcoins (rather than integer satoshis) makes life significantly easier. For people writing software to interface with it, it makes their life only infinitesimally more complicated (you have to write maybe one extra line of code to insert and parse the decimal point). The computer running it takes maybe a few more nanoseconds to run the code, which nobody will notice. So on balance, it seems like more good is achieved by including the decimal point than not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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