Some auto-formatting

This commit is contained in:
bumi 2022-04-14 20:58:13 -04:00
parent 488eef551f
commit e400782449
1 changed files with 39 additions and 38 deletions

View File

@ -50,23 +50,23 @@ A list of existing tags is available [here](https://github.com/bumi/lnme/pkgs/co
To connect to the lnd node the cert, macaroon and address of the lnd node has to be configured. LnMe uses the LND defaults.
* `lnd-address`: Host and port of the LND gRPC service. default: localhost:10009
* `lnd-cert-path`: Path to the LND TLS cert file. default: ~/.lnd/tls.cert
* `lnd-macaroon-path`: Path to the LND macaroon file. default: ~/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon (invoice.macaroon is recommended)
- `lnd-address`: Host and port of the LND gRPC service. default: localhost:10009
- `lnd-cert-path`: Path to the LND TLS cert file. default: ~/.lnd/tls.cert
- `lnd-macaroon-path`: Path to the LND macaroon file. default: ~/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon (invoice.macaroon is recommended)
Instead of the path to the macaroon and cert files you can also provide the hex strings:
* `lnd-cert`: LND TLS cert as HEX string.
* `lnd-macaroon`: LND macaroon HEX string. (invoice.macaroon is recommended)
- `lnd-cert`: LND TLS cert as HEX string.
- `lnd-macaroon`: LND macaroon HEX string. (invoice.macaroon is recommended)
#### Other configuration
* `static-path`: Path to a folder that you want to serve with LnMe (e.g. /home/bitcoin/lnme/website). Use this if you want to customize your ⚡website. default: disabled
* `disable-website`: Disable the default LnMe website. Disable the website if you only want to embed the LnMe widget on your existing website.
* `disable-cors`: Disable CORS headers. (default: false)
* `disable-ln-address`: Disable [Lightning Address](https://lightningaddress.com/) handling.
* `port`: Port to listen on. (default: 1323)
* `request-limit`: Limit the allowed requests per second. (default: 5)
- `static-path`: Path to a folder that you want to serve with LnMe (e.g. /home/bitcoin/lnme/website). Use this if you want to customize your ⚡website. default: disabled
- `disable-website`: Disable the default LnMe website. Disable the website if you only want to embed the LnMe widget on your existing website.
- `disable-cors`: Disable CORS headers. (default: false)
- `disable-ln-address`: Disable [Lightning Address](https://lightningaddress.com/) handling.
- `port`: Port to listen on. (default: 1323)
- `request-limit`: Limit the allowed requests per second. (default: 5)
Depending on your deployment needs LnMe can be configured using the following options:
@ -98,8 +98,8 @@ All environment variables must be prefixed by `LNME_` use `_` instead of `-`
LnMe needs the following LND permissions:
* Read/Write permission for `invoices`
* Write permission for `address` (if you want to use the onchain option)
- Read/Write permission for `invoices`
- Write permission for `address` (if you want to use the onchain option)
Use the LND [macaroon bakery](http://macaroon-bakery.freedomnode.com/) to create a new macaroon for LnMe.
@ -109,24 +109,24 @@ To get the HEX versions of the files use `xxd -plain` e.g. `xxd -plain invoice.m
LnMe can connect to your lightning node through [Tor](https://www.torproject.org/). You need to have Tor installed on your system and then simply provide your LND `.onion` address (don't forget to specify the port).
## Deployment
It is the easiest to run LnMe on the same node as LND. But you can run it anywhere as long as your LND node is accessible. Simply run the binary and make sure the PORT is accessible.
If you run LNMe on a different server you will need your LND address, the LND TLS certificate (HEX) and the macaroon (HEX). (see above)
When getting the HEX of the LND files use `xxd -plain YOUR_FILE.cert | tr -d '\n'`. For example for the TLS certificate, use `xxd -plain tls.cert | tr -d '\n'`.
When getting the HEX of the LND files use `xxd -plain YOUR_FILE.cert | tr -d '\n'`. For example for the TLS certificate, use `xxd -plain tls.cert | tr -d '\n'`.
The TLS cert is located in the lnd directory:
* ~/umbrel/lnd/tls.cert on Umbrel
* /mnt/hdd/lnd/tls.cert on Raspiblitz
* Can also be located in ~/.lnd
You should find the macaroon files in the LND data dir (e.g. ~.lnd/data/chain/bitcoin/mainnet/) or see "LND Permissions" how to create a new one.
- ~/umbrel/lnd/tls.cert on Umbrel
- /mnt/hdd/lnd/tls.cert on Raspiblitz
- Can also be located in ~/.lnd
You should find the macaroon files in the LND data dir (e.g. ~.lnd/data/chain/bitcoin/mainnet/) or see "LND Permissions" how to create a new one.
### Heroku
One click deployment with Heroku:
[![Deploy on Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/bumi/lnme)
@ -138,7 +138,6 @@ This buildpack can be disabled and removed if not needed or desired, through the
Lastly, using the Heroku deployment, you can link the app to your own domain by following the directions here: https://help.heroku.com/MTG1BIA7/how-do-i-connect-a-domain-to-my-heroku-app
### Deployment Notes
To run LnMe as systemd service have a look at the [systemd service example config](https://github.com/bumi/lnme/blob/master/examples/lnme.service)
@ -146,13 +145,14 @@ To run LnMe as systemd service have a look at the [systemd service example confi
I am running LnMe behind a reverse proxy using [caddy](https://caddyserver.com/) which comes with [fully-managed HTTPS](https://caddyserver.com/docs/quick-starts/https) via [letsencrypt](https://letsencrypt.org/).
Example Caddyfile:
```
lnme.michaelbumann.com {
reverse_proxy 127.0.0.1:1323
}
```
`$ caddy --config /etc/caddy/Caddyfile`
`$ caddy --config /etc/caddy/Caddyfile`
## Feature Usage
@ -171,7 +171,6 @@ if you got the Lightning Address enabled you also get a LNURL-pay URL:
https://`{your domain}/lnurlp/{anything}`
### Customize your ⚡ website
LnMe comes with a default website but you can easily configure and build your own using the the LnMe JavaScript widget or JSON API.
@ -182,7 +181,6 @@ Take a look at the [embedded default website](https://github.com/bumi/lnme/blob/
2. Create your index.html
3. Run lnme: `lnme --static-path=/home/satoshi/my-ln-page
### JavaScript Widget integration
You can integrate the LnMe widget in your existing website.
@ -190,7 +188,10 @@ You can integrate the LnMe widget in your existing website.
#### 1. Add the LnMe JavaScript files
```html
<script data-lnme-base-url="https://your-lnme-host.com:1323" src="https://your-lnme-host.com/lnme/lnme.js"></script>
<script
data-lnme-base-url="https://your-lnme-host.com:1323"
src="https://your-lnme-host.com/lnme/lnme.js"
></script>
```
#### 2. Usage
@ -198,37 +199,40 @@ You can integrate the LnMe widget in your existing website.
To request a lightning payment simply call `request()` on a `new LnMe({value: value, memo: memo})`:
```js
var lnme = new LnMe({ value: 1000, memo: 'high5' });
var lnme = new LnMe({ value: 1000, memo: "high5" });
lnme.request();
```
Use it from a plain HTML link:
```html
<a href="#" onclick="javascript:new LnMe({ value: 1000, memo: 'high5' }).request();return false;">Tip me</a>
<a
href="#"
onclick="javascript:new LnMe({ value: 1000, memo: 'high5' }).request();return false;"
>Tip me</a
>
```
##### More advanced JS API:
```js
let lnme = new LnMe({ value: 1000, memo: 'high5' });
let lnme = new LnMe({ value: 1000, memo: "high5" });
// get a new invoice and watch for a payment
// promise resolves if the invoice is settled
lnme.requestPayment().then(invoice => {
alert('YAY, thanks!');
lnme.requestPayment().then((invoice) => {
alert("YAY, thanks!");
});
// create a new invoice
lnme.addInvoice().then(invoice => {
console.log(invoice.PaymentRequest)
lnme.addInvoice().then((invoice) => {
console.log(invoice.PaymentRequest);
});
// periodically watch if an invoice is settled
lnme.watchPayment().then(invoice => {
alert('YAY, thanks!');
lnme.watchPayment().then((invoice) => {
alert("YAY, thanks!");
});
```
## Motivation
@ -238,15 +242,12 @@ BTCPay Server is too big and hard to run for that and I do not need most of its
## Development
Use `go run` to ron the service locally:
Use `go run` to run the service locally:
$ go run lnme.go --address=127.0.0.1:10009 --cert=/home/bitcoin/lightning/tls.cert --macaroon=/home/bitcoin/lightning/invoice.macaroon
## Build
LnMe uses [go.rice](https://github.com/GeertJohan/go.rice) to embed assets (HTML, JS, and CSS files). run `rice embed-go` (needs to be [installed](https://github.com/GeertJohan/go.rice#installation))
$ rice embed-go
$ go build
## Contributing