ElementsProject / lightning-charge

A simple drop-in solution for accepting lightning payments
MIT License
554 stars 80 forks source link

Feature request: Add support for displaying in satoshis #74

Closed kaloudis closed 4 years ago

kaloudis commented 4 years ago

mBTC isn't very commonly used and sats are becoming somewhat of a standard. It would be awesome if lightning-charge displayed units in satoshis, especially when used on a paywall like wordpress-lightning-publisher

kaloudis commented 4 years ago

I'm happy to implement this myself, but would like to get some discussion going first on how this should function.

shesek commented 4 years ago

Implementing this was pretty straightforward so I went ahead and made the BTC display unit configurable using a new metadata.checkout.display_unit field. It can be set to one of msat, sat, bit, milli or btc. For example:

$ curl $CHARGE/invoice -d msatoshi=150000 -d metadata[checkout][display_unit]=bit

Or with json:

$ curl $CHARGE/invoice -H 'Content-Type: application/json' -d '{"msatoshi":150000,"metadata":{"checkout":{"display_unit":"bit"}}}'

I also changed the default display unit to satoshis.

Cheers!

kaloudis commented 4 years ago

Great job! Closing this out and opening https://github.com/ElementsProject/wordpress-lightning-publisher/issues/8 to track in Wordpress Lightning Publisher