# [[gRPC]] over [[Tor]] ## Resources ### [[Google]] search https://www.google.com/search?q=%22grpc%22+over+%22tor%22&oq=%22grpc%22+over+%22tor%22&aqs=chrome..69i57.4670j0j1&sourceid=chrome&ie=UTF-8 ### grpc-node issue https://github.com/grpc/grpc-node/issues/992 - Lots of back-and-forth between [[mrfelton]] and the repo maintainer, possibly relevant ### PR in grpc-node https://github.com/grpc/grpc-node/pull/1369 - It seems they managed to get it to work but it got broken with a later change - This later PR fixes it (again) https://github.com/grpc/grpc-node/pull/1379 ### [[StopAndDecrypt]]'s Guide https://stopanddecrypt.medium.com/running-bitcoin-lightning-nodes-over-the-tor-network-2021-edition-489180297d5 [[StopAndDecrypt]] wrote a guide for running a Bitcoin + Lightning node over [[Tor]]; includes some lines in `bitcoin.conf`: ```text ## Tor Settings debug=tor onlynet=onion proxy=127.0.0.1:9050 bind=127.0.0.1 dnsseed=0 dns=0 ``` Also in `lnd.conf`: ```text ## Zap Settings # Enables LND's REST interface # Zap mobile wallet will connect over Tor through this interface restlisten=localhost:8080 # Tor Settings tor.active=true tor.v3=true tor.streamisolation=true listen=localhost ``` But I haven't yet seen anything about connecting to the Tor node using a gRPC client. #### "Zap connects to LND over Tor via REST" > Depending on how Zap connects to LND, it will either use LND’s gRPC interface, or LND’s REST interface. Since this tutorial is all about Tor, we’ll be configuring LND to listen over the REST interface. - It looks like I could look into [[Zap]]'s code to see how they connect to [[lnd]] over [[Tor]] using [[REST]] #### "4-A) Install ‘LND Connect’ & Connecting Zap To LND" First we will need to install LND Connect, which is a small piece of software that will generate a QR code we will use to connect our Zap wallet to LND. After that we will need get our onion hostname so LND Connect can generate the QR code, and then scan that with our Zap wallet. #### Installing LND Connect To install LND Connect, just run the following commands and make sure you replace ‘satoshi’ with your username: ```bash go get -d github.com/LN-Zap/lndconnect cd /home/satoshi/go/src/github.com/LN-Zap/lndconnect make ``` #### Connecting Zap With LND running, in a terminal enter the following _(replace the bold text with your onion address)_: ```bash cd ~ lndconnect --host=ONIONADDRESS --port=8080 --image ``` ![[Pasted image 20210904163911.png]] ### zap-iOS Issue: Support [[gRPC]] over [[Tor]] Open: https://github.com/LN-Zap/zap-iOS/issues/368 - No responses - Referenced by "Support [[lndconnect]] via [[Tor]]" https://github.com/LN-Zap/zap-iOS/issues/62 - It's all specific to [[iOS]] anyway, not sure it's helpful... ### [[Zap]] desktop is open-source https://github.com/LN-Zap/zap-desktop - Several matches searching for "Tor" - Written in [[Javascript]] https://github.com/LN-Zap/zap-desktop/blob/b9591f19a2a188a770c01f845cb7366ff12b0df0/renderer/reducers/utils.js#L58 ```javascript const { loading, starting_lnd, connecting_to_lnd, starting_neutrino, fetching_tickers, starting_tor_proxy, } = messages if (neutrinoSelectors.isStartingNeutrino(state)) { return starting_neutrino } const { isTorProxyStarting } = state.lnd if (isTorProxyStarting) { return starting_tor_proxy } ``` Couldn't find anything substantive re Tor on the first pass - they're all display messages. Maybe Tor support is implemented somewhere else... node-lndconnect: https://github.com/LN-Zap/node-lndconnect - No matches searching for "Tor" ### node-lnd-grpc: https://github.com/LN-Zap/node-lnd-grpc - `tor.js` https://github.com/LN-Zap/node-lnd-grpc/blob/06bafc8b0e5aa89b56b063b3ecbda03875da758f/src/utils/tor.js ### [[mrfelton]] thread Quoted tweet: "Making progress on tor support for node-lnd-grpc... It’s working with the native grpc bindings but not yet with grpc-js. Will get there eventually" First tweet: "I managed to get gRPC over Tor working in Zap Desktop ... [[Zap]] rather, lol" https://twitter.com/mrfelton/status/1254404563194580992?s=20 https://mobile.twitter.com/mrfelton/status/1254404563194580992 - Can ask him how he did it Follow-on discussion - Notably, mentions that it works with the native [[gRPC]] client... perhaps I should simple use the [[Rust]] wrapper - See [[grpc-rs]] ![[Screen Shot 2021-09-04 at 4.58.30 PM.png]] ### [[Zeus]] has gotten [[Tor]] working; if it's open-source... ### Other [[Rust]] gRPC clients I'm inclined to try [[grpc-rs]] (1.4k stars), but in case that doesn't work... - [[tonic]]: - https://crates.io/crates/tonic - https://github.com/hyperium/tonic (4k stars) - grpc: - https://crates.io/crates/grpc - https://docs.rs/grpc/0.8.3/grpc/ - https://github.com/stepancheg/grpc-rust (1.2k stars) This blog post recommends [[tonic]] over grpc https://blog.logrocket.com/rust-and-grpc-a-complete-guide/ ### Setting up [[Tor]] with [[c-lightning]] https://lightning.readthedocs.io/TOR.html #### Case 4: c-lightning has no public IP address, but has a fixed Tor hidden service address that is persistent https://lightning.readthedocs.io/TOR.html#case-4-c-lightning-has-no-public-ip-address-but-has-a-fixed-tor-hidden-service-address-that-is-persistent #### Case 7: c-lightning has no public IP address, a fixed Tor V3 service address https://lightning.readthedocs.io/TOR.html#case-7-c-lightning-has-no-public-ip-address-a-fixed-tor-v3-service-address