btcpayserver / btcpayserver-docker

Docker resources for hosting BTCPayServer easily
MIT License
580 stars 356 forks source link

Bluewallet LNDHub URI #477

Open jaonoctus opened 3 years ago

jaonoctus commented 3 years ago

The Connection QR Code is wrong.

Not a valid LNDHub URI

Expected behavior

The QR Code content should be https://btcpayserverurl/bluewallet_lndhub_app/

Actual behavior

The QR Code content is https://btcpayserverurl/

Steps to Reproduce

  1. Add opt-add-bluewallet-lndhub fragment.
  2. Access the app via IPV4, which will be something like https://btcpayserverurl/bluewallet_lndhub_app.
  3. Scan the QR code on BlueWallet app, under Settings > Network > Lightning Settings.

Versions

jaonoctus commented 3 years ago

https://github.com/BlueWallet/LndHub/blob/1eaf6c5a47fa702c89c612b82a243efc9b2fc95f/controllers/website.js#L98-L101

Since,

if (process.env.TOR_URL) {
  host = process.env.TOR_URL; 
}

const url = 'bluewallet:setlndhuburl?url=' + encodeURIComponent(req.protocol + '://' + host);

A workaround is to set TOR_URL environment variable to ${BTCPAY_HOST}/bluewallet_lndhub_app

jaonoctus commented 3 years ago

@maltokyo thoughts?

maltokyo commented 3 years ago

Thanks. Good find. I'll try to fix on the weekend.

jaonoctus commented 3 years ago

Another topic, but important to note: I think this /bluewallet_lndhub_app should be customizable somehow.

If I know some btcpayserver URL, I can try this lndhub endpoint and get the node exactly balance (from the public channels, at least). And possibly flood with invoices creation. Also end with the inbound-liquidity (not smart, but it is possible)

maltokyo commented 3 years ago

Been working on fixing this (the URL being wrong in QR code) on BTCPay side, but I have no clue how to manage that. Anyone have some advice?

maltokyo commented 3 years ago

@rockstardev @Kukks would you have some advice? For people who use the QR code, I guess it is quite critical. But I can not work that out without requesting LNDHub team to make the change on their side..

cc: @Overtorment

Overtorment commented 3 years ago

try this patch:

diff --git a/controllers/website.js b/controllers/website.js
index 7785937..d9af611 100644
--- a/controllers/website.js
+++ b/controllers/website.js
@@ -98,7 +98,8 @@ router.get('/qr', function (req, res) {
   if (process.env.TOR_URL) {
     host = process.env.TOR_URL;
   }
-  const url = 'bluewallet:setlndhuburl?url=' + encodeURIComponent(req.protocol + '://' + host);
+  const customPath = req.url.replace('/qr/', '');
+  const url = 'bluewallet:setlndhuburl?url=' + encodeURIComponent(req.protocol + '://' + host + customPath);
   var code = qr.image(url, { type: 'png' });
   res.setHeader('Content-type', 'image/png');
   code.pipe(res);

if it works for you I will include it in next release