bitrequest / bitrequest.github.io

Web Application for crypto payment requests
https://www.bitrequest.io
GNU Affero General Public License v3.0
46 stars 11 forks source link

Rendering exact amounts #5

Closed benkaiser closed 3 years ago

benkaiser commented 3 years ago

I noticed that the request window shows a rounded amount:

Screen Shot 2021-08-05 at 1 03 21 am

The raw amount that actually gets requested in the QR code is 0.446323.

I'm concerned if a user is manually making a payment (rather than scanning the QR code / clicking the open in wallet button), then they will send slightly the wrong amount and the payment will fail in exact mode.

Would you be happy with a PR to show the number of digits that are non-zero?

bitrequest commented 3 years ago

I think i got this, sometimes it uses 5 decimals and sometimes 6. Shall i make 6 the standard?

benkaiser commented 3 years ago

@bitrequest can we just make it as granular as the value is (i.e. show the number up to however many decimals are non+zero)?

bitrequest commented 3 years ago

I think 6 decimals is good, otherwise it can go up to more then 20 decimals (When converted via Xchange rates). Which is not really userfriendly. And not practical for the UX.

benkaiser commented 3 years ago

@bitrequest will the 6 decimals always match what is shown with the QR code? I'm just concerned with the change in logic for exact payments, that they may not match up

benkaiser commented 3 years ago

(just to add, the other reason I like more decimals is that I plan on passing small differences in USD amounts to make the transactions more likely to be unique, and for BTC 6 decimals is almost 4 cents difference in USD price)

bitrequest commented 3 years ago

If someone pays the exact amount from input or QR i'm pretty sure they will match. Gonna round the receiving amount to 6 decimals as well and it should be a 100% match. More then 6 decimals is only relevant for BTC at the moment cause of it's high price relative to the other crypto's but even that should be enough for now i think. And i've tested with 8 decimals and it starts having rendering problems. Think i will need to implement big number libraries for that. Which is not something i want to do in the short term.

bitrequest commented 3 years ago

Ok i tested on all coins and had 100% match each time! (6 decimal standard) https://github.com/bitrequest/bitrequest.github.io/commit/5e6a7c82989df5ca01dc0bbe84f0ecefa5af29e9

benkaiser commented 3 years ago

Perfect, thanks @bitrequest !