diff --git a/README.md b/README.md index 64dcf8d..763ddc3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The default config file location is `lightningTip.conf` in the directory you are Embedding LightningTip is also quite easy. Upload all files excluding `lightningTip.html` to your webserver. Copy the contents of the head tag of the before mentioned HTML file into a 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 you server. -Make sure that the executable of **LightningTip is always running** in the background. It connects LND and the widget on your website. +Make sure that the executable of **LightningTip is always running** in the background. It connects LND and the widget on your website. A sample configuration for systemd can be found [on this wiki page](https://github.com/michael1011/lightningtip/wiki/Running-LightningTip-with-systemd). If you are not running LightningTip on the same domain or IP address as your webserver or not on port 8081 change the variable `requestUrl` (which is in the first line) in the file `lightningTip.js` accordingly. diff --git a/backends/backend.go b/backends/backend.go index a672dc2..c91d1a7 100644 --- a/backends/backend.go +++ b/backends/backend.go @@ -8,6 +8,8 @@ type PublishInvoiceSettled func(invoice string, eventSrv *eventsource.Server) type Backend interface { Connect() error - // Amount in satoshis and expiry in seconds + // Amount in satoshi and expiry in seconds GetInvoice(description string, amount int64, expiry int64) (invoice string, err error) + + SubscribeInvoices(callback PublishInvoiceSettled, eventSrv *eventsource.Server) error } diff --git a/backends/lnd.go b/backends/lnd.go index f43bb9c..2d1b127 100644 --- a/backends/lnd.go +++ b/backends/lnd.go @@ -56,16 +56,6 @@ func (lnd *LND) Connect() error { return err } -func getMacaroon(macaroonFile string) (macaroon metadata.MD, err error) { - data, err := ioutil.ReadFile(macaroonFile) - - if err == nil { - macaroon = metadata.Pairs("macaroon", hex.EncodeToString(data)) - } - - return macaroon, err -} - func (lnd *LND) GetInvoice(message string, amount int64, expiry int64) (invoice string, err error) { var response *lnrpc.AddInvoiceResponse @@ -131,3 +121,13 @@ func (lnd *LND) SubscribeInvoices(callback PublishInvoiceSettled, eventSrv *even return err } + +func getMacaroon(macaroonFile string) (macaroon metadata.MD, err error) { + data, err := ioutil.ReadFile(macaroonFile) + + if err == nil { + macaroon = metadata.Pairs("macaroon", hex.EncodeToString(data)) + } + + return macaroon, err +} \ No newline at end of file diff --git a/config.go b/config.go index 4d4cb62..e8f4ab2 100644 --- a/config.go +++ b/config.go @@ -140,6 +140,8 @@ func initConfig() { log.Debug("Initialized log file: " + cfg.LogFile) } + backends.UseLogger(*log) + // TODO: add more backend options like for example c-lighting and eclair backend = cfg.LND } diff --git a/lightningtip.go b/lightningtip.go index b1a2e52..086a45f 100644 --- a/lightningtip.go +++ b/lightningtip.go @@ -107,7 +107,7 @@ func main() { log.Info("Subscribing to invoices") go func() { - err = cfg.LND.SubscribeInvoices(publishInvoiceSettled, eventSrv) + err = backend.SubscribeInvoices(publishInvoiceSettled, eventSrv) if err != nil { log.Error("Failed to subscribe to invoices: " + fmt.Sprint(err))