sparrowwallet / sparrow

Desktop Bitcoin Wallet focused on security and privacy. Free and open source.
https://sparrowwallet.com/
Apache License 2.0
1.36k stars 192 forks source link

Handle amounts with excessive precision #1529

Closed casey closed 2 weeks ago

casey commented 3 weeks ago

I sometimes use a calculator to convert a dollar amount to a bitcoin amount by doing AMOUNT / BTC_PRICE. However, this yields a value with excessive precision, like 0.005329040877821366, which the amount field does not accept.

It might be nice if it accepted the value, noted that it had excessive precision, so I could manually delete digits at the end until it was valid.

As always, thanks for Sparrow!

craigraw commented 2 weeks ago

Good idea. Implemented in 60e3d4e1, but I've taken a slightly different approach. Numbers with excessive precision are simply truncated after 8 decimal places, which I think is the least surprising approach. This has the added side benefit of allowing numbers to be extracted from strings containing letters and numbers, with the first available sequence of digits being pasted.

casey commented 2 weeks ago

Nice! I think that's definitely better.