Devpool work: express amounts in satoshis in RPC commands

theZerg

Moderator
Staff member
Aug 28, 2015
1,012
2,327
Amounts are currently expressed in BTC as decimal numbers. But an RPC-using script can't read these numbers as floating points or you could get rounding problems. You could use your scripting language's perfect decimal object (python Decimal.Decimal for example), but the problem is that the JSON parser is probably using floats.

The RPC interface shouldn't just be possible to use, it should be easy! So let sidestep the decimal problem entirely by providing values in integer satoshis. First step is to make a PR for one RPC call and get that reviewed and committed. Please start with the gettransaction RPC, which currently returns fields called "amount" in two places in the JSON hierarchy. For every amount field, create a new field called "satoshis" (located as a sibling to "amount") and put the amount as an integer in it.
 

torusJKL

Active Member
Nov 30, 2016
497
1,156
From the release notes of BUCash 1.2.0 I understand that this development has been done.

  • satoshi field added to any RPC call that returns an amount. The satoshi field is the amount in satoshis (as an integer). This field makes scripting easier since script authors do not need to use "perfect" fraction libraries such as financial decimal or binary coded decimal numbers.
paging @theZerg
 
  • Like
Reactions: solex

torusJKL

Active Member
Nov 30, 2016
497
1,156
It's great to have these small devpool developments.
I find myself wishing I'm a C++ developer. :)