michael1011 / lightningtip

Get tips via the Lightning Network
MIT License
93 stars 28 forks source link

Lightning tip over Tor #14

Open adiack opened 6 years ago

adiack commented 6 years ago

Background

I am able to run lightningtip successfully on regular IP addresses but it is not working for onion addresses.

Your environment

version of lnd: 0.5 commit=73af09a06ae9cd5ba92a376e8253ae5450fe09cc which operating system (uname -a on *Nix): 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux Tor version (tor -v): Tor 0.2.9.15

Lightnintips.conf

# Host for the REST interface of LightningTip
 resthost = 0.0.0.0:8081

# The domain (or IP address) you are using LightningTip from
# Only needed if LightningTip is running on another port than the web server and no reverse proxy is used
# Set the value to "*" to allow all domains and IP addresses
# 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

# If the connection to LND gets lost LightningTip will try to reconnect at the interval (in seconds) below
# Set to 0 or comment out to disable
# reconnectinterval = 0

# If you are using LightningTip behind a firewall it could happen the connection to LND times out after a few minutes
# To prevent this keepalive requests (requests which contain meaningless data) will be sent at the interval (in seconds) below
# Set to 0 or comment out to disable
# keepaliveinterval = 0

[LND]
# LightningTip should work out of the box with LND
# You only have to change this settings if you edited the according settings in the LND config

# Host of the gRPC interface of LND
 lnd.grpchost = localhost:10009

# TLS certificate for the LND gRPC and REST services
 lnd.certfile = tls.cert

# Invoice macaroon file for authentication
# If you are using LND version 0.4.0 or lower use the file admin.macaroon
# Set an empty string if you disabled the usage of macaroons (not recommended)
 lnd.macaroonfile = /home/adiack/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon
lnd.conf
[Application Options]
listen=localhost
debuglevel=info
restlisten=localhost:8080

Steps to reproduce

Access webserver via onion address. Click on get request.

Expected behaviour

Invoice created

Actual behaviour

Error: Fail to reach backend.

Tor console:

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
Stack trace:
getInvoice/request.onreadystatechange@http://cxmu737kkbcpping.onion/lightningTip.js:63:40
  lightningTip.js:105:29
    getInvoice/request.onreadystatechange http://cxmu737kkbcpping.onion/lightningTip.js:105:29
Failed to reach backend  lightningTip.js:302:5
    showErrorMessage http://cxmu737kkbcpping.onion/lightningTip.js:302:5
    getInvoice/request.onreadystatechange http://cxmu737kkbcpping.onion/lightningTip.js:107:29
michael1011 commented 6 years ago

I don't have much experience with Tor services but I will look into a solution :thinking:

adiack commented 6 years ago

ok thanks for your work anyway. I will try to troubleshoot this as well. Let me know if there is a way I can help.

seth586 commented 5 years ago

I have it successfully working over tor:

http://seth576fk35mys5mem6s2bterxdcsma3cnp6do2tc33uidtndc3cbead.onion/lightningtip/

Just make sure your hidden service torrc forwards port 8081 to lightningTip's resthost=

And lightningTip.js has the onion address under requestUrl =