diff --git a/README.md b/README.md index f9c2767..64dcf8d 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,22 @@ To get all necessary files for setting up LightningTip you can either [download LightningTip is using [LND](https://github.com/lightningnetwork/lnd) as backend. Please make sure it is installed and fully synced before you install LightningTip. -The default config file location is `lightningTip.conf` in the directory you are executing LightningTip in. The [sample config](https://github.com/michael1011/lightningtip/blob/master/sample-lightningTip.conf) contains everything you need to know about the configuration. To use a custom config file location use the flag `--config filename`. +The default config file location is `lightningTip.conf` in the directory you are executing LightningTip in. The [sample config](https://github.com/michael1011/lightningtip/blob/master/sample-lightningTip.conf) contains everything you need to know about the configuration. To use a custom config file location use the flag `--config filename`. You can use all keys in the config as command line flag. Command line flags *always* override values in the config. 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. + + 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. -That's it! The only two things you need to take care about is keeping the LND node online and making sure that your channels are funded well enough to receive tips. LightningTip will take care of everything else. +When using LightningTip behind a proxy make sure the proxy supports [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource). Without support for it the users will not see the "Thank you for your tip!" screen. + + +That's it! The only two things you need to take care about is keeping the LND node online and making sure that your channels are funded well enough to receive tips. LightningTip will take care of everything else. ## How to build First of all make sure [Golang](https://golang.org/) and [Dep](https://github.com/golang/dep) are both correctly installed. Golang version 1.10 or newer is recommended. diff --git a/config.go b/config.go index 309d0ba..ee56895 100644 --- a/config.go +++ b/config.go @@ -16,7 +16,10 @@ const ( defaultLogFile = "lightningTip.log" defaultLogLevel = "debug" - defaultRESTHost = "localhost:8081" + defaultRESTHost = "0.0.0.0:8081" + defaultTlsCertFile = "" + defaultTlsKeyFile = "" + defaultAccessDomain = "" defaultTipExpiry = 3600 @@ -32,7 +35,10 @@ type config struct { LogFile string `long:"logfile" Description:"Location of the log file"` LogLevel string `long:"loglevel" Description:"Log level: debug, info, warning, error"` - RESTHost string `long:"resthost" Description:"Host for the REST interface of LightningTip"` + RESTHost string `long:"resthost" Description:"Host for the REST interface of LightningTip"` + TlsCertFile string `long:"tlscertfile" Description:"Certificate for using LightningTip via HTTPS"` + TlsKeyFile string `long:"tlskeyfile" Description:"Certificate for using LightningTip via HTTPS"` + AccessDomain string `long:"accessdomain" Description:"The domain you are using LightningTip from"` TipExpiry int64 `long:"tipexpiry" Description:"Invoice expiry time in seconds"` @@ -53,7 +59,10 @@ func initConfig() { LogFile: defaultLogFile, LogLevel: defaultLogLevel, - RESTHost: defaultRESTHost, + RESTHost: defaultRESTHost, + TlsCertFile: defaultTlsCertFile, + TlsKeyFile: defaultTlsKeyFile, + AccessDomain: defaultAccessDomain, TipExpiry: defaultTipExpiry, @@ -65,12 +74,13 @@ func initConfig() { }, } - _, err := flags.Parse(&cfg) + // Ignore unknown flags the first time parsing command line flags to prevent showing the unknown flag error twice + flags.NewParser(&cfg, flags.IgnoreUnknown).Parse() errFile := flags.IniParse(cfg.ConfigFile, &cfg) // Parse flags again to override config file - _, err = flags.Parse(&cfg) + _, err := flags.Parse(&cfg) // Default log level logLevel := logging.DEBUG @@ -118,4 +128,4 @@ func getDefaultLndDir() (dir string) { } return dir -} +} \ No newline at end of file diff --git a/frontend/lightningTip.css b/frontend/lightningTip.css index 649cb9c..f9d3253 100644 --- a/frontend/lightningTip.css +++ b/frontend/lightningTip.css @@ -1,5 +1,5 @@ .lightningTipInput { - width: 100%; + width: 90%; display: inline-block; @@ -151,4 +151,4 @@ 100% { transform: rotate(360deg); } -} \ No newline at end of file +} diff --git a/lightningtip.go b/lightningtip.go index 1675bc9..dda8196 100644 --- a/lightningtip.go +++ b/lightningtip.go @@ -119,7 +119,14 @@ func main() { log.Info("Starting HTTP server") go func() { - err = http.ListenAndServe(cfg.RESTHost, nil) + var err error + + if cfg.TlsCertFile != "" && cfg.TlsKeyFile != "" { + err = http.ListenAndServeTLS(cfg.RESTHost, cfg.TlsCertFile, cfg.TlsKeyFile, nil) + + } else { + err = http.ListenAndServe(cfg.RESTHost, nil) + } if err != nil { log.Error("Failed to start HTTP server: " + fmt.Sprint(err)) diff --git a/sample-lightningTip.conf b/sample-lightningTip.conf index 77de6cc..03e5fbf 100644 --- a/sample-lightningTip.conf +++ b/sample-lightningTip.conf @@ -14,6 +14,11 @@ # This value is used for the HTTP header: "Access-Control-Allow-Origin" # accessdomain = +# It is possible to use LightningTip over HTTPS instead of HTTP +# If you want to: edit "tlscertfile" and "tlskeyfile" accordingly +# tlscertfile = +# tlskeyfile = + # After how many seconds invoices should expire # tipexpiry = 3600