mirror of https://github.com/bumi/lntip
Compare commits
9 Commits
d20a73b0a0
...
cc73ef7a9f
Author | SHA1 | Date |
---|---|---|
bumi | cc73ef7a9f | |
bumi | 2c6b946f8d | |
bumi | 986b8d3aa4 | |
bumi | 8e45d9206c | |
bumi | bf30744d2a | |
bumi | 1278780cbc | |
bumi | 56cfbfd714 | |
bumi | 9afa340725 | |
bumi | 37ebaf3834 |
14
README.md
14
README.md
|
@ -14,7 +14,7 @@ otherwise an overlay will be shown with the payment request and a QR code.
|
|||
|
||||
I wanted a simple way for people to send Lightning payments using my own lightning node.
|
||||
|
||||
BTCPay Server is too big and hard to run for that as I do not need most of its features.
|
||||
BTCPay Server is too big and hard to run for that and I do not need most of its features.
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -22,8 +22,8 @@ BTCPay Server is too big and hard to run for that as I do not need most of its f
|
|||
LnMe connects to your [LND node](https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md), so a running LND node is required.
|
||||
LnMe can easily run next to LND on the same system.
|
||||
|
||||
1. Download the latest [release](https://github.com/bumi/lntip/releases)
|
||||
2. Run `lnme` (to run it as systemd service have a look at the [systemd service example config](https://github.com/bumi/lntip/blob/master/examples/invoices-proxy.service))
|
||||
1. Download the latest [release](https://github.com/bumi/lnme/releases)
|
||||
2. Run `lnme` (to run it as systemd service have a look at the [systemd service example config](https://github.com/bumi/lnme/blob/master/examples/lnme.service))
|
||||
3. Done.
|
||||
|
||||
### Configuration
|
||||
|
@ -46,16 +46,16 @@ To connect to the lnd node the cert, macaroon and address of the lnd node has to
|
|||
|
||||
#### Examples:
|
||||
|
||||
$ ./lnme --help
|
||||
$ ./lnme --address=lndhost.com:10009 --bind=localhost:4711
|
||||
$ ./lnme --disable-website
|
||||
$ lnme --help
|
||||
$ lnme --address=lndhost.com:10009 --bind=localhost:4711
|
||||
$ lnme --disable-website
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
Take a look at the [embedded default website](https://github.com/bumi/lntip/blob/master/files/root/index.html) for an example and use the `--static-path` option to configure LnMe to serve your static file.
|
||||
Take a look at the [embedded default website](https://github.com/bumi/lnme/blob/master/files/root/index.html) for an example and use the `--static-path` option to configure LnMe to serve your static file.
|
||||
|
||||
1. Create a new folder (e.g. /home/satoshi/my-ln-page)
|
||||
2. Create your index.html
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
[Unit]
|
||||
Description=LND invoices proxy
|
||||
Wants=lnd.service
|
||||
After=lnd.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/home/bitcoin/lntip
|
||||
ExecStart=/home/bitcoin/lntip/invoices_proxy --address=localhost:10009 --cert=/home/bitcoin/.lnd/tls.cert --macaroon=/home/bumi/bitcoin/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon --static-path=/home/bitcoin/lntip/assets
|
||||
|
||||
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
Type=simple
|
||||
KillMode=process
|
||||
LimitNOFILE=128000
|
||||
TimeoutSec=240
|
||||
Restart=always
|
||||
RestartSec=60
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=LnMe your friendly lightning payment page
|
||||
Wants=lnd.service
|
||||
After=lnd.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/home/bitcoin/lnme --address=localhost:10009 --cert=/home/bitcoin/.lnd/tls.cert --macaroon=/home/bumi/bitcoin/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon
|
||||
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
Type=simple
|
||||
KillMode=process
|
||||
LimitNOFILE=128000
|
||||
TimeoutSec=240
|
||||
Restart=always
|
||||
RestartSec=60
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -101,12 +101,12 @@ class LnMe {
|
|||
payWithWebln() {
|
||||
if (!webln.isEnabled) {
|
||||
webln.enable().then((weblnResponse) => {
|
||||
return webln.sendPayment({ paymentRequest: this.invoice.payment_request })
|
||||
return webln.sendPayment(this.invoice.payment_request);
|
||||
}).catch((e) => {
|
||||
return this.showPaymentRequest();
|
||||
})
|
||||
} else {
|
||||
return webln.sendPayment({ paymentRequest: this.invoice.payment_request })
|
||||
return webln.sendPayment(this.invoice.payment_request);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,13 @@
|
|||
color: #fff;
|
||||
opacity: 0.3;
|
||||
}
|
||||
input[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
input.amount {
|
||||
width: 300px;
|
||||
}
|
||||
|
|
BIN
lnme-demo.gif
BIN
lnme-demo.gif
Binary file not shown.
Before Width: | Height: | Size: 731 KiB After Width: | Height: | Size: 599 KiB |
37
lnme.go
37
lnme.go
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"github.com/GeertJohan/go.rice"
|
||||
"github.com/bumi/lntip/ln"
|
||||
"github.com/bumi/lnme/ln"
|
||||
"github.com/didip/tollbooth/v6"
|
||||
"github.com/didip/tollbooth/v6/limiter"
|
||||
"github.com/labstack/echo/v4"
|
||||
|
@ -48,10 +48,10 @@ func main() {
|
|||
|
||||
e := echo.New()
|
||||
|
||||
// Serve static files if configured
|
||||
// Serve static files if configured
|
||||
if *staticPath != "" {
|
||||
e.Static("/", *staticPath)
|
||||
// Serve default page
|
||||
// Serve default page
|
||||
} else if !*disableWebsite {
|
||||
rootBox := rice.MustFindBox("files/root")
|
||||
indexPage, err := rootBox.String("index.html")
|
||||
|
@ -62,28 +62,27 @@ func main() {
|
|||
})
|
||||
} else {
|
||||
stdOutLogger.Printf("Failed to run embedded website: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Embed static files and serve those on /lnme (e.g. /lnme/lnme.js)
|
||||
assetHandler := http.FileServer(rice.MustFindBox("files/assets").HTTPBox())
|
||||
e.GET("/lnme/*", echo.WrapHandler(http.StripPrefix("/lnme/", assetHandler)))
|
||||
|
||||
|
||||
// CORS settings
|
||||
// CORS settings
|
||||
if !*disableCors {
|
||||
e.Use(middleware.CORS())
|
||||
}
|
||||
|
||||
// Recover middleware recovers from panics anywhere in the request chain
|
||||
// Recover middleware recovers from panics anywhere in the request chain
|
||||
e.Use(middleware.Recover())
|
||||
|
||||
// Request limit per second. DoS protection
|
||||
// Request limit per second. DoS protection
|
||||
if *requestLimit > 0 {
|
||||
limiter := tollbooth.NewLimiter(*requestLimit, nil)
|
||||
e.Use(LimitMiddleware(limiter))
|
||||
}
|
||||
|
||||
// Setup lightning client
|
||||
// Setup lightning client
|
||||
stdOutLogger.Printf("Connection to %s using macaroon %s and cert %s", *address, *macaroonFile, *certFile)
|
||||
lndOptions := ln.LNDoptions{
|
||||
Address: *address,
|
||||
|
@ -97,8 +96,8 @@ func main() {
|
|||
}
|
||||
|
||||
// Endpoint URLs compatible to the LND REST API v1
|
||||
//
|
||||
// Create new invoice
|
||||
//
|
||||
// Create new invoice
|
||||
e.POST("/v1/invoices", func(c echo.Context) error {
|
||||
i := new(Invoice)
|
||||
if err := c.Bind(i); err != nil {
|
||||
|
@ -115,17 +114,17 @@ func main() {
|
|||
return c.JSON(http.StatusOK, invoice)
|
||||
})
|
||||
|
||||
// Get next BTC onchain address
|
||||
e.POST("/v1/newaddress", func(c echo.Context) error {
|
||||
address, err := lnClient.NewAddress()
|
||||
if err != nil {
|
||||
// Get next BTC onchain address
|
||||
e.POST("/v1/newaddress", func(c echo.Context) error {
|
||||
address, err := lnClient.NewAddress()
|
||||
if err != nil {
|
||||
stdOutLogger.Printf("Error getting a new BTC address: %s", err)
|
||||
return c.JSON(http.StatusInternalServerError, "Error getting address")
|
||||
}
|
||||
return c.JSON(http.StatusOK, address)
|
||||
})
|
||||
}
|
||||
return c.JSON(http.StatusOK, address)
|
||||
})
|
||||
|
||||
// Check invoice status
|
||||
// Check invoice status
|
||||
e.GET("/v1/invoice/:invoiceId", func(c echo.Context) error {
|
||||
invoiceId := c.Param("invoiceId")
|
||||
invoice, err := lnClient.GetInvoice(invoiceId)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue