Skip to content

Instantly share code, notes, and snippets.

@05nelsonm
Last active August 30, 2019 03:51
Show Gist options
  • Save 05nelsonm/ef55dcc1fb3aa588c8135cd107ee5d8c to your computer and use it in GitHub Desktop.
Save 05nelsonm/ef55dcc1fb3aa588c8135cd107ee5d8c to your computer and use it in GitHub Desktop.
## Getting LND working with Dojo
## Written for use with Ubuntu Desktop 18.04 LTS & Dojo v1.0.0 ##
## Start Dojo
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh start
## Login to the bitcoind docker container as root
$ sudo docker exec -u root -it bitcoind /bin/bash
## Update and install a text editor
$ apt-get update && apt-get install nano
## Modify bitcoin.conf
$ nano /home/bitcoin/.bitcoin/bitcoin.conf
## Add to bitcoin.conf
zmqpubrawblock=tcp://0.0.0.0:28332
rpcthreads=20
## Save and exit
ctrl+x --> y --> return
## Log out of the container
$ exit
## Stop Dojo
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh stop
## Modify the docker-compose.yaml file to open docker ports for interaction with bitcoind
$ nano docker-compose.yaml
## Under the section for `bitcoind` add:
ports:
- "127.0.0.1:28256:28256"
- "127.0.0.1:28332:28332"
- "127.0.0.1:28333:9501"
## Your bitcoind section should now look something like the following ####
bitcoind:
image: "samouraiwallet/dojo-bitcoind:1.0.0"
container_name: bitcoind
build:
context: ./bitcoin
env_file:
- ./.env
- ./conf/docker-bitcoind.conf
restart: on-failure
command: "/wait-for-it.sh tor:9050 --timeout=360 --strict -- /restart.sh"
expose:
- "28256"
- "9501"
- "9502"
ports:
- "127.0.0.1:28256:28256"
- "127.0.0.1:28332:28332"
- "127.0.0.1:28333:9501"
volumes:
- data-bitcoind:/home/bitcoin/.bitcoin
depends_on:
- db
- tor
networks:
dojonet:
ipv4_address: 172.28.1.5
## Save and exit
ctrl+x --> y --> return
########## Install Tor ####################################################################################################
## The Dojo's tor container has the control port bound to it's container's localhost, and at the moment editing the
## /etc/tor/torrc file yeilds poor results as it reverts back after a Dojo stop and start cycle. My workaround is to just
## install tor on the machine because... why not?
$ sudo -s
## *** Follow the guide at https://2019.www.torproject.org/docs/debian.html.en ***
## Be sure to select the correct distribution of your Linux package
## Log out of root user
$ exit
## Add user to debian-tor group
$ sudo adduser $USER debian-tor
## Verify that your username has been added to the debian-tor group (should be the last line of what prints out)
$ cat /etc/group
## Edit /etc/tor/torrc
$ sudo nano /etc/tor/torrc
## Add to torrc
SocksPort 9050
Log notice stdout
ControlPort 9051
CookieAuthentication 1
## Save and exit
ctrl+x --> y --> return
## Reboot the machine
$ sudo shutdown -r now
########## If you already have LND installed ##############################################################################
## Skip to the bottom and update your ~/.lnd/lnd.conf file to reflect the appropriate changes.
## Note, I installed everything from scratch on this VM and just moved my ~/.lnd/ directory
## over after initially running LND the first time from command line. If you've already got LND
## running, I'm not entirely positive but just updating your lnd.conf file should do the trick.
########## If you are installing LND on the machine for the first time ###################################################
## Head over to --> https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md
## and follow the instructions **up to** and including, executing `make check` (be sure to run
## `$ make check`, it is important...)
## Start Dojo
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh start
## Get your external facing IP address by visiting --> https://www.iplocation.net/
## Start lnd ***Be sure in the below code to input your Dojo's RPC username and pass, as well as your external IP address***
$ lnd --bitcoin.active --bitcoin.mainnet --debuglevel=debug --bitcoin.node=bitcoind --bitcoind.rpchost=127.0.0.1:28256 --bitcoind.rpcuser=your_dojo_rpc_username --bitcoind.rpcpass=your_dojo_rpc_password --bitcoind.zmqpubrawblock=127.0.0.1:28332 --bitcoind.zmqpubrawtx=127.0.0.1:28333 --externalip=xxx.xxx.x.xxx
## Open another terminal and create a wallet (or unlock one if you transferred over your ~/.lnd/ directory)
## Let it run and process block data
## After processing the block data, in another terminal execute and making initial connections, stop lnd
$ lncli stop
## Create a lnd.conf file to save the flags we set when we first started lnd (This is where we'll add Tor only services)
$ nano ~/.lnd/lnd.conf
## Copy and paste the below text (between the ----------------'s), and then
## update ***alias, bitcoind.rpcuser, bitcoind.rpcpass*** to reflect
## those of your own.
Begin lnd.conf file
------------------------------------------------------------------------------------------------------
alias=***your_choice***
debuglevel=debug
## Bitcoin Settings
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
## Bitcoind Settings
bitcoind.rpchost=127.0.0.1:28256
bitcoind.rpcuser=***your_dojo_rpc_username***
bitcoind.rpcpass=***your_dojo_rpc_password***
bitcoind.zmqpubrawblock=127.0.0.1:28332
bitcoind.zmqpubrawtx=127.0.0.1:28333
## Tor Settings
tor.active=1
tor.socks=127.0.0.1:9050
tor.control=127.0.0.1:9051
tor.streamisolation=1
tor.v3=1
## Application Options
listen=localhost
#rpclisten=0.0.0.0:10009 # <-- uncoment if you plan to use Zap Android/iOS via VPN (it's awesome... you should)
----------------------------------------------------------------------------------------------------------------------------
End lnd.conf file
## Start LND to make sure everything works
$ lnd
## Check info (you should have a publickey@some.onion:port, no other address)
$ lncli getinfo
## Now go install Zap-Desktop because it rocks --> https://github.com/LN-Zap/zap-desktop
## Done
@BTCxZelko
Copy link

BTCxZelko commented Aug 30, 2019

So referencing the conf/bitcoin.conf file
Expose the RPC API to external apps
Warning: Do not expose your RPC API to internet!
See BITCOIND_RPC_EXTERNAL_IP
Value: on | off
BITCOIND_RPC_EXTERNAL=off<--- ON

Is there anything else you need to change? And should be as easy as ./dojo.sh stop --- make changes ---- ./dojo.sh start yeah?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment