Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lnproxy support #586

Merged
merged 18 commits into from May 18, 2023
Merged

Fix lnproxy support #586

merged 18 commits into from May 18, 2023

Conversation

ghost
Copy link

@ghost ghost commented May 15, 2023

What does this PR do?

Fixes #560

This PR introduces a GitHub workflow. The workflow fetches the LnProxy relay list which is now stored in a standalone JSON file: https://github.com/lnproxy/lnproxy-webui2/blob/e2b8cf00393e0e2d1b71a346d24e6b7ac3ad95eb/assets/relays.json

The LnProxy API calls have also been updated to reflect the new structure used in that project.

Lastly this PR refactors the error handling slightly, since Tor-only relays seem to be a thing

Checklist before merging

  • [✅] Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.
  • [✅] If I added new phrases to the user interface, I have ran prettier cd frontend/static/locales; python collect_phrases.py to collect them for translation.

Note: The output of the collect_phrases.py script was a bit of a mess, so I didn't commit the changes

+shyfire131 and others added 7 commits May 13, 2023 21:57
- Use POST instead of GET, so create and send a body parameter
- Path is /spec/ instead of /api/, and list of relays from lnproxy will contain /spec already, so path parameter for ApiClient.post() is an empty string
doing this so that the “scripts” subfolder in .github/workflows can be added
Locale strings not added yet
Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This so soo top! 🚀 Thank you very much for investing the time into getting this done.

I will find the time before tomorrow to run the UI and comment on it.

.github/workflows/lnproxy-sync.yml Outdated Show resolved Hide resolved
const fs = require('fs');

let rawRelays = JSON.parse(fs.readFileSync('./lnproxy_relays.json'));
let formattedRelays = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a chance the /lnproxy/...relays.json does not see much action (or stops being maintained altogether). In such case, we might start adding ourselves new relays into ./frontend/static/lnproxies.json . This script will remove the new proxies we add. Maybe it's best to join existing and incoming proxies instead of starting blank [].

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I updated the script so that only new proxies that appear in /lnproxy/...relays.json will be added to the RoboSats list. We can easily make a more sophisticated merge in the future if needed.

.gitignore Outdated
### VirtualEnv template
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. On a recent PR I also moved a couple scripts into /scripts and deleted these lines from .gitignore . Maybe that creates a small merge conflict, not a problem though.

clearnetCount++;
}

let relayName = `LNProxy ${relayType}${relayType === "TOR" ? torCount : ''}${relayType === "I2P" ? i2pCount : ''}${relayType === "Clearnet" ? clearnetCount : ''}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using the first 6 characters of the domain name ? e.g.:

let relayName = ${relayType}${relayType === "TOR" ? torCount : ''}${relayType === "I2P" ? i2pCount : ''}${relayType === "Clearnet" ? clearnetCount : ''} ${url.split('/')[2].substring(0,6)}

So it would read: TOR1 w3sqmn I think something in this line will make the dropdown menu more transparent for the user (rather than just a number, as the user does not know what is behind the number)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this could go in many ways, there's probably more you could inspect on a relay other than just the name. For example status - some kind of ping to show whether the host is up (currently one of the tor lnproxy relays is down).

But first six is a good start :)

Copy link
Author

@ghost ghost May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will just need to keep an eye on the relay list - it's OK for now but something like "https://www.paidrelayproxiesfromthefuture.com" would render as "Clearnet1 www.pa"

Copy link
Collaborator

@Reckless-Satoshi Reckless-Satoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking great. Was just able to test it over TOR / mainnet. The filtered list showed me only the Clearnet1 server, not sure where the issue was, maybe the missing dependency settings.host .

I was able to get a request through, but the response was "Internal Error", I think though that everything is working fine with those three fixes I commented.

- Change hook deps from settings.network to settings
- routing_msat param updates for lnproxy API
@ghost
Copy link
Author

ghost commented May 16, 2023

Thanks! I've made the changes. Busy trying to figure out how I can also test these changes over TOR/mainnet. I've got the mainnet onion wired up, just figuring out how to expose my running npm as a hidden service.

@ghost
Copy link
Author

ghost commented May 17, 2023

Updated and tested on mainnet

@ghost ghost marked this pull request as ready for review May 17, 2023 01:15
@Reckless-Satoshi
Copy link
Collaborator

Reckless-Satoshi commented May 18, 2023

Tested successfully over Clearnet and TOR. The proxied payment made it through on the first attempt, completing the whole order process 🚀 I did not get to text the GH workflow, but we will see how that works :D

Thank you once again for this great work! @shyfire131 Please, accept a small tip from our devfund of 200K Sats. Submit an invoice with a +24h expiration time and from a proxy nodeid (...lnproxy!?).

@Reckless-Satoshi Reckless-Satoshi merged commit 3bd7ade into RoboSats:main May 18, 2023
@ghost
Copy link
Author

ghost commented May 18, 2023

lnbc2m1pjxv7wepp5uw0e9ggdjjc6rzutcy8gxrq73qp2scqn8mq4evnmr6k2xzk6y4nsdqqcqpjsp5w2vygz377ty752x96nwgywq7k970tggduszatlqs7nmkdazrx0lq9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcllczrm9kqyzs5sqqqqlgqqqqqeqqjqz45lq0j8d5jdslhrcj4gcz25zl05964fpn0m0krmmgdt876sf5kr0ve83yydylpzzrarf637vxqfh576pppwact74uya9q87j9df63sqr7ngjv

image

@Reckless-Satoshi
Copy link
Collaborator

lnbc2m1pjxv7wepp5uw0e9ggdjjc6rzutcy8gxrq73qp2scqn8mq4evnmr6k2xzk6y4nsdqqcqpjsp5w2vygz377ty752x96nwgywq7k970tggduszatlqs7nmkdazrx0lq9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcllczrm9kqyzs5sqqqqlgqqqqqeqqjqz45lq0j8d5jdslhrcj4gcz25zl05964fpn0m0krmmgdt876sf5kr0ve83yydylpzzrarf637vxqfh576pppwact74uya9q87j9df63sqr7ngjv

Payment Pathfinding Failed To Find Possible Route Probably the node is offline.

@Reckless-Satoshi
Copy link
Collaborator

b65a75953e044a64e42a1a3101e0edb60f241dfd89d963e90b48678091609552

@ghost
Copy link
Author

ghost commented May 21, 2023

Received, thanks! (apologies, I had deleted my comment with the invoice because it had a 24 HR expiry and not > 24 hours as you had commented)

@ghost ghost deleted the fix/lnproxy branch May 22, 2023 02:49
@ghost ghost mentioned this pull request May 22, 2023
1 task
@Reckless-Satoshi Reckless-Satoshi assigned ghost Aug 3, 2023
@Reckless-Satoshi Reckless-Satoshi added ⚡Eligible for Sats ⚡ This issue or pull request rewards bitcoin enhancement 🆙 New feature or request labels Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡Eligible for Sats ⚡ This issue or pull request rewards bitcoin enhancement 🆙 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lnproxy support is broken
1 participant