nimiq / nimiq-utils

Simple helper libraries for Nimiq frontends
Apache License 2.0
6 stars 14 forks source link

Add support for currencies other than NIM in payment links #49

Open rraallvv opened 3 years ago

rraallvv commented 3 years ago

This could come in handy for website owners with no knowledge of HTML and Javascript that want to add a payment or donation button in a currency other than NIM.

There is a discussion thread on the forum addressing this issue.

sisou commented 3 years ago

We now plan to add support to the Wallet to enter an amount in a fiat currency while creating a request link, but the link will still be denominated in crypto. The request links follow the BIP-21 specification which does not allow specifying a different currency than the protocol determines (https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki). We want the links be able to be read by any other BTC and NIM wallets (such as TrustWallet), which means we need to adhere to the standard.

rraallvv commented 3 years ago

We now plan to add support to the Wallet to enter an amount in a fiat currency while creating a request link

Thanks for the the info @sisou. That would be awesome.

What follows is just me thinking out loud... after reading the specification, particularly in the section forward compatibility, where it says:

Any other variables which are not implemented, but which are not prefixed with a req-, can be safely ignored.

It occurred to me that perhaps some optional parameters would do the trick, for instance nimiq-currency and nimiq-amount for specifying the parameters that were used when creating the payment link. Those parameters would be safely ignored by any wallet other than the official wallet, and the value in NIM specified in the parameter amount would be used instead.

Although with such implementation, most people might end up receiving a different amount that the specified when creating the link, and they wouldn't know for sure what the payment was for or the exchange rate that was used, assuming it was the actual rate and not someone trying to use a fake one.

sisou commented 3 years ago

You are right, we can use custom variables. It likely makes no sense for request links created in the Wallet. But for the use case that started this discussion, the donation button, it does make sense. Since the donation button links to the Wallet, we can use custom variables and interpret them, while all other wallets that use this link would simply not pre-fill the amount (because we would leave the amount variable out and use a custom one, e.g. fiat-amount instead). That could work.