This commit is contained in:
Shannon Appelcline 2020-10-13 14:41:38 -10:00 committed by GitHub
parent 36b6fc9062
commit f232bd1c05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
# Interlude: Accessing a Second Lightning Node
When you played with Bitcoin you were accessing an existing network, and that made it relatively easy to work with: you just turned on `bitcoind` and you were immediately interacting with the network. That's now how Lightning works. It's fundamentally a peer-to-peer network, built up from the connections between any two individual nodes. In other words, to interact with the Lightning Network, you'll need to first find a node to connect to.
When you played with Bitcoin you were accessing an existing network, and that made it relatively easy to work with: you just turned on `bitcoind` and you were immediately interacting with the network. That's now how Lightning works: it's fundamentally a peer-to-peer network, built up from the connections between any two individual nodes. In other words, to interact with the Lightning Network, you'll need to first find a node to connect to.
There are three ways to do so:
@ -23,17 +23,17 @@ They can then tell you their `id` (`02f3d74746934494fa378235e5bc44cfdbb5b8779d83
## Creating a New c-lightning Node
However, for testing purposes, you probably want to have a second node under you own power. The easiest way to do so is to create a second c-lightning node on a new machine, using either Bitcoin Standup, per [§2.1](02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md) or compiling it by hand, per [§18.1](18_1_Verifying_Your_Lightning_Setup.md).
However, for testing purposes, you probably want to have a second node under you own control. The easiest way to do so is to create a second c-lightning node on a new machine, using either Bitcoin Standup, per [§2.1](02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md) or compiling it by hand, per [§18.1](18_1_Verifying_Your_Lightning_Setup.md).
Once you have your node up, you can run `getinfo` to retrieve your information, as shown above.
Once you have your node running, you can run `getinfo` to retrieve your information, as shown above.
## Creating a New LND Node
However, for our examples in the next chapter, we're instead going to create an LND node. This will allow us to demonstrate a bit of the depth of the Lightning ecosystem by showing how similar commands work on the two different platforms.
One way to do so is to run the Bitcoin Standup Scripts again on a new machine, but this time to choose LND, per [§2.1](2_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md).
One way to create an LND node is to run the Bitcoin Standup Scripts again on a new machine, but this time to choose LND, per [§2.1](2_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md).
Another is to compile LND from source code on a machine that you've set up with a Bitcoin node, as follows.
Another is to compile LND from source code on a machine where you'rea already running a Bitcoin node, as follows.
### Compiling the LND Source Code
@ -56,7 +56,7 @@ $ go version
go version go1.14.4 linux/amd64
```
You'll also need `git` and `make`:
````
```
$ sudo apt-get install git
$ apt-get install build-essential
```
@ -73,15 +73,10 @@ $ make install
```
This will install to `~/gocode/bin`, which is `$GOPATH/bin`.
And this will put it in global directories:
You should move it to global directories:
```
$ sudo cp $GOPATH/bin/lnd $GOPATH/bin/lncli /usr/bin
```
Finally, this will create some standard directories:
```
$ sudo mkdir -p /etc/lnd /var/lib/lnd
$ sudo chown standup -R /var/lib/lnd
```
### Creating an LND Config File
@ -174,7 +169,7 @@ RestartSec=60
WantedBy=multi-user.target
EOF
```
You'll then need to install that:
You'll then need to install that and start things up:
```
$ sudo cp ~/lnd.service /etc/systemd/system
$ sudo systemctl enable lnd
@ -188,7 +183,7 @@ The first time you run LND, you must create a wallet:
```
$ lncli --network=testnet create
```
It will ask you for a password and then ask if you want to enter an existing mnemonic (just hit `n` for the latter one).
LND will ask you for a password and then ask if you want to enter an existing mnemonic (just hit `n` for the latter one).
You should now have a functioning `lnd`, which you can verify with `getinfo`:
```
@ -260,8 +255,10 @@ This node's ID is `032a7572dc013b6382cde391d79f292ced27305aa4162ec3906279fc43346
## Summary: Accessing a Second Lightning Node
You always need two Lightning nodes to form a channel. If you don't have someone else who is testing things out with you, you're going to need to create a second one, either using c-lightning or (as we will in our examples) LND
You always need two Lightning nodes to form a channel. If you don't have someone else who is testing things out with you, you're going to need to create a second one, either using c-lightning or (as we will in our examples) LND.
## What's Next?
Though you've possibly created an LND, c-lightning will remain the heart of our examples until we need to start using both of them, in [Chapter 19](19_0_Understanding_Your_Lightning_Setup.md).
Continue "Understanding Your Lightning Setup" with [§18.3: Setting Up_a_Channel](18_3_Setting_Up_a_Channel.md).