{"mvjWntqo6nos9XuskZPyvnWUqR69SqAJsh": 5.4750000000000005, "mugHAcC484RLgqNS8hr1aBk7fhMMaFxuUY": 5.495}
JSONRPC error: Invalid amount
Many JSON serialisers do not give people the freedom to choose exact precision of Numbers.
{"mvjWntqo6nos9XuskZPyvnWUqR69SqAJsh": 5.4750000000000005, "mugHAcC484RLgqNS8hr1aBk7fhMMaFxuUY": 5.495}
JSONRPC error: Invalid amount
Many JSON serialisers do not give people the freedom to choose exact precision of Numbers.
Disagree, this is dealing with money.
Precision is important.
There seems to be some disagreement within the code:
I think we already had this and the workaround was to use strings. Still, something needs to be done to solve this issue.
I agree with @pstratem.
The parser is not affected IMO. You probably mean the client side JSON encoder. Because bitcoind RPCs input structures are relatively simple, you could - in case of problematic rounding/percicions - easily write your one JSON encoding.
A solution to this "problem" would be to change every monetary amount to int32 satoshis. But to do this, it would require a v2/ RPC API, which is a overkill IMO.
@jonasschnelli You can represent every valid amount of bitcoins as a double. In case the exact representation is not possible, you can get back the original amount by rounding. There will never be an issue up to 21e6. I think the first off-by-one satoshi rounding error is somewhere in the order of 60e6.
I see no reason to drop support for floating point. Especially given that the documentation indicates that rounding was intended and probably working in earlier versions of core. Can someone test this with 0.9, etc?
We've explicitly decided not to use rounding in the parser. Amounts that cannot be represented in our number format (.8 decimal fixed point) are rejected. So 0.12000000000000000000 is ok, but 0.12000000000000000001 is rejected. See the
tests:https://github.com/bitcoin/bitcoin/blob/master/src/test/util_tests.cpp#L424
(and yes, you can pass strings if your JSON formatter refuses to generate decimals of the correct precision - see #6380). Possibly the documentation needs to be updated, but IMO rounding is not acceptable when dealing with money.
@laanwj So the documentation needs an update?
Yes