Jump to content
Lightning Bitcoin
Sign in to follow this  
Return...

How to Run Lightning BTC Node and Start Mining by Daniel Wang

Recommended Posts

Founder of Loopring Foundation Daniel Wang shared in his blog clear instruction on how to forge Lightning Bitcoin

1*AgrL-MA5qdczQrCGx9K0zA.png

Original link:

I invested 50 BTC into Lighting BTC (LBTC), so during the weekend I tried to mine LBTC for fun.

Install and Run

1. Start an EC2 Server

Without prior knowledge, I chose a x1e.4xlarge instance and added 400G SSD storage.

1*rcVTr9_uTkY2fNvB7gun9A.jpeg
1*KwRoKAbSc27NaYLzUPLsXg.jpeg

2. Secure My Server

I need to setup the firewall to secure my server.

sudo ufw allow ssh
sudo ufw allow 8333
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable

[edited]: Lighting network use 9333 instead of 8333.

sudo ufw allow 9333

3. Install LightingBTC software

Ligiting BTC node is being actively developed, and the documentation is really incomplete. I decided to go with bitcoin-unlimited and then replace the binaries with those downloaded on lbtc.io.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin-unlimited/bu-ppa
sudo apt-get update
sudo apt-get install -y bitcoind

Then I installed libraries required by LBTC, just in case they are not required by bitcoin-unlimited.

sudo apt-get install -y libzmq5 libevent-dev libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev libboost-dev libboost-all-dev

You can download bitcoind and bitcoin-cli from lbtc.io. I found there is no directly URL to download, so I downloaded them manually and put it into my own github repository. You should ALWAYS download the software from lbtc.io.

wget https://github.com/dong77/lbtcnode/raw/master/bitcoind
wget https://github.com/dong77/lbtcnode/raw/master/bitcoin-cli
chmod +x bitcoind bitcoin-cli
sudo mv bitcoind /usr/bin
sudo mv bitcoin-cli /usr/bin

4. Config Swap Space

Running a full bitcoin node uses a little over 1GB of memory, and I don’t know how much memory it needs to run a Lighting BTC node. The node I created has 16GB, but in case the one you run has less memory, I’ll make some spare “virtual memory” using swap space.

sudo fallocate -l 1g /swap1.swap
sudo chmod 0600 /swap1.swap
sudo mkswap /swap1.swap
sudo swapon /swap1.swap
sudo vi /etc/fstab

Add this line at the end of the file:

/swap1.swap  none  swap  sw  0  0

5. Add a User

I’ll make a bitcoin user account and give it the ability to use “sudo” so you can do some system administration from the bitcoin user if you want to.

sudo adduser --system --group --shell /bin/bash bitcoin
sudo usermod -a -G sudo bitcoin

6. Set up log rotation for your bitcoin logs.

This will ensure that your logs don’t grow too big and use up all your disk space.

sudo vi /etc/logrotate.d/bitcoin-debug

Enter into it:

/home/bitcoin/.bitcoin/debug.log
{
    rotate 5
    copytruncate
    daily
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
}

7. Configure Bitcoind

sudo mkdir /home/bitcoin/.bitcoin
sudo vi /home/bitcoin/.bitcoin/bitcoin.conf

And paste the following as content:

server=1
daemon=1
rpcuser=bitcoin
rpcpassword=ANY_PASSWORD_WILL_DO

Then copy the file so that I can use bitcoin-cli as the default “ubuntu” user.

sudo mkdir .bitcoin
sudo cp /home/bitcoin/.bitcoin/bitcoin.conf .bitcoin/

8. Set Up a Systemd Service

Set up the bitcoin daemon to auto-run:

sudo vi /etc/systemd/system/multi-user.target.wants/bitcoind.service

Enter into it:

[Unit]
Description=Bitcoin Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=bitcoind.service
[Service]
User=bitcoin
Group=bitcoin
Type=forking
# Start main service
ExecStart=/usr/bin/bitcoind --daemon
ExecStop=/usr/bin/bitcoin-cli stop
Restart=always
PrivateTmp=false

Reboot the server:

sudo reboot

Now bitcoind should have been started automatically; or you can reload systemd and start bitcoind manually:

sudo systemctl restart bitcoind
sudo systemctl status bitcoind

If you want to stop bitcoind, use this command:

sudo systemctl stop bitcoind

Start to Mine LBTC

First I need an address:

sudo bitcoin-cli getnewaddress
1L3ur9z8AydjnKdE8fXmpRTi3wtxcWJ2eJ
sudo bitcoin-cli dumpprivkey 1L3ur9z8AydjnKdE8fXmpRTi3wtxcWJ2eJ

I need to backup the private key printed by this command.

sudo bitcoin-cli register 1L3ur9z8AydjnKdE8fXmpRTi3wtxcWJ2eJ loopring
error code: -6
error message:
Insufficient funds

Apparently I need some LBTC to register as a miner, so I asked someone for 5 LRC. Then run the registration command again, it succeeded.

Now I’m ready to mine.

sudo bitcoin-cli startforging 1L3ur9z8AydjnKdE8fXmpRTi3wtxcWJ2eJ

Future Work

I need to ask other LBTC miners to vote for me, and I may have to vote back so we can form a partnership.

References

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×