A simple way to accept tips via the Lightning Network on your website.
If want to see LightningTip in action, you can tip me a few sats! ⚡
Kudos to michael1011 for the original LightningTip. The difference between the two projects are shown in this table.
LightningTip | LightningTip-PHP | |
---|---|---|
Backend | An executable (always running) |
PHP |
Email notification | Yes | Yes |
lnd communication | gRPC | REST |
testnet/mainnet selection | No | Yes |
Keeps track of tips? |
Yes | No |
Installing an executable either on the lnd host, or on a 3rd party web host can be problematic. Using PHP improves portability and removes the need for a separate executable running as a service.
The invoice.macroon file limits the functionality available to LightningTip.php to only invoice related functions. Importantly, if someone steals your invoice.macaroon, they can NOT spend any of your funds.
- Enable REST on your lnd instance(s). See the restlisten parameter in the lnd documentation.
- Open any necessary firewall ports on your lnd host, and router port-forwards as needed.
- Generate a hex version of the invoice.macaroon file on your lnd instance.
- Linux:
xxd -ps -u -c 1000 /path/to/invoice.macaroon
- Generic: http://tomeko.net/online_tools/file_to_hex.php?lang=en
- Linux:
Your webserver will need to have the php-curl package installed.
On a typical Linux webserver you can check as follows. The example below shows that it is installed.
$ dpkg -l php-curl
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-======================-================-================-=================================================
ii php-curl 1:7.0+49 all CURL module for PHP [default]
If you see no packages found matching php-curl
then install as follows.
$ sudo apt-get update
$ sudo apt-get install php-curl
- Download the latest release, and unzip.
- From the frontend folder: Upload these files to your webserver:
- lightningTip.php
- lightningTip.js
- lightningTip.css
- lightningTip_light.css (Optional)
- Edit the CHANGE ME section of
lightningTip.php
. This is where you enter the HEX version of your invoice.macaroon. - Edit the CHANGE ME section of
lightningTip.js
. - Copy the contents of the head tag from
lightningTip.php
into the head section of the HTML file you want to show LightningTip in. The div below the head tag is LightningTip itself. Paste it into any place in the already edited HTML file on your server.
There is a light theme available for LightningTip. If you want to use it add this to the head tag of your HTML file:
<link rel="stylesheet" href="lightningTip_light.css">
Do not use LightningTip on XHTML sites. That causes some weird scaling issues.
That's it! The only things you need to take care of is keeping the LND node and web server online. LightningTip will take care of everything else.
Use your browser to visit either of these:
https://your.web.server/path/lightningTip.php
https://your.web.server/path/lightningTip.php?testnet=1