Closed pedrobranco closed 6 years ago
@pedrobranco I am unable to reproduce this issue and don't actually see the originally reported issue anymore (nor a test preventing a regression). I also fail to understand what exactly this PR does as there is no BigInt returned on the verificationprogress field, nor one stored as a string as it was supposed to. Can you clarify a bit the changes?
Actually, when syncing the blockchain in mainnet
(or testnet
) the value returned by bitcoind
is a double, which will loss precision on its JS interpretation:
> cli.getBlockchainInfo().then(data => console.log(data.verificationprogress)).catch(console.err)
0.01725915139476017
@pedrobranco in that case, shouldn't that be returned as a string?
@pedrobranco in that case, shouldn't that be returned as a string?
JSONBitInt only converts numeric values that will lose precision when parsing as JS object.
@pedrobranco: me and @joaopaulofonseca took a look at this PR and there are a couple of things we feel important to be part of a general improvement to response handling, in which this change is included. Therefor, please refer to https://github.com/ruimarinho/bitcoin-core/pull/50 for further progress on this.
This PR adds support for parsing big numbers as string to prevent losing precision due to Javascript number precision problem.
Fixes #35 .