决定安装lnd了,建议先烧柱香,拜拜中本聪,会减少些磨难和诡异。
#C-lightning、LND和Éclair的关系和区别:
闪电网络驱动的基础技术区别在于编码语言。Éclair用的是Scala,LND用的是Go-Long,而C-lightning用的是C语言。通过建立在Ska之上,Éclair兼容所有的Java语言,这可以让许多企业很容易就在当前的技术平台上工作。Éclair已经开发了安卓钱包和付款流程API;LND更关注于配合开发人员在闪电网络上构建以比特币为基础的新应用程序。值得注意的是,因为只有一个闪电协议,尽管有三种不同的驱动形式,但所有的驱动都互相兼容。
除此之外,lightningcn群里有位Ronald Wiplinger老师说:Big difference between lnd and c-lightning is that lnd funds channels at both noods, while c-lightning has only one direction channels. Worse, it cannot have A to B and B to A. It must use A to B and back B to C to A.(注意留言时间是2019.3.25,以后不一定一直如此)。
#lnd和btcd的安装
###环境:
浪潮云 ecs:2c4g,40g系统盘,300g数据盘,1m网络
ubuntu 16.04
系统安装之后只有ubuntu账户,没有root。
解决办法:
sudo passwd //输入两次当前用户密码
su //用这个密码登录root就可以了。
###安装go
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
sha256sum go1.11.5.linux-amd64.tar.gz | awk -F " " ‘{ print $1 }’
//下载安装go
最后的输出应该如果与下面一致,就是下载的文件经过验证没问题:ff54aafedff961eb94792487e827515da683d61a5f9482f668008832631e5d25
tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz //解压文件
export PATH=$PATH:/usr/local/go/bin //设置环境变量
为长远考虑,把下面内容加入~/.bashrc
export GOPATH=~/go/ //此处要加最后的斜杠,否则会出错。
export PATH=$PATH:$GOPATH/bin
###安装git
sudo apt-get install git
###安装lnd
go get -d github.com/lightningnetwork/lnd //下载lnd及其依赖包。由于golang被墙,估计难倒了80%想继续的人。看看这个缺少了多少个包:24个,几近崩溃。
我把报错的包全部贴出来了:
1.package golang.org/x/crypto/ripemd160: unrecognized import path “golang.org/x/crypto/ripemd160” (https fetch: Get https://golang.org/x/crypto/ripemd160?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
2、package google.golang.org/genproto/googleapis/api/httpbody: unrecognized import path “google.golang.org/genproto/googleapis/api/httpbody” (https fetch: Get https://google.golang.org/genproto/googleapis/api/httpbody?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
3、package google.golang.org/genproto/protobuf/field_mask: unrecognized import path “google.golang.org/genproto/protobuf/field_mask” (https fetch: Get https://google.golang.org/genproto/protobuf/field_mask?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
4、package google.golang.org/grpc/codes: unrecognized import path “google.golang.org/grpc/codes” (https fetch: Get https://google.golang.org/grpc/codes?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
5、package google.golang.org/grpc/grpclog: unrecognized import path “google.golang.org/grpc/grpclog” (https fetch: Get https://google.golang.org/grpc/grpclog?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
6、package google.golang.org/grpc/metadata: unrecognized import path “google.golang.org/grpc/metadata” (https fetch: Get https://google.golang.org/grpc/metadata?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
7、package google.golang.org/grpc/status: unrecognized import path “google.golang.org/grpc/status” (https fetch: Get https://google.golang.org/grpc/status?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
8.package golang.org/x/sys/cpu: unrecognized import path “golang.org/x/sys/cpu” (https fetch: Get https://golang.org/x/sys/cpu?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
9、package golang.org/x/net/proxy: unrecognized import path “golang.org/x/net/proxy” (https fetch: Get https://golang.org/x/net/proxy?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
10、package golang.org/x/crypto/chacha20poly1305: unrecognized import path “golang.org/x/crypto/chacha20poly1305” (https fetch: Get https://golang.org/x/crypto/chacha20poly1305?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
11、package golang.org/x/crypto/hkdf: unrecognized import path “golang.org/x/crypto/hkdf” (https fetch: Get https://golang.org/x/crypto/hkdf?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
12、package golang.org/x/time/rate: unrecognized import path “golang.org/x/time/rate” (https fetch: Get https://golang.org/x/time/rate?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
13、package golang.org/x/net/context: unrecognized import path “golang.org/x/net/context” (https fetch: Get https://golang.org/x/net/context?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
14、package google.golang.org/genproto/googleapis/api/annotations: unrecognized import path “google.golang.org/genproto/googleapis/api/annotations” (https fetch: Get https://google.golang.org/genproto/googleapis/api/annotations?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
15、package google.golang.org/grpc: unrecognized import path “google.golang.org/grpc” (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
16、package golang.org/x/crypto/curve25519: unrecognized import path “golang.org/x/crypto/curve25519” (https fetch: Get https://golang.org/x/crypto/curve25519?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
17、package golang.org/x/crypto/nacl/box: unrecognized import path “golang.org/x/crypto/nacl/box” (https fetch: Get https://golang.org/x/crypto/nacl/box?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
18、package golang.org/x/crypto/nacl/secretbox: unrecognized import path “golang.org/x/crypto/nacl/secretbox” (https fetch: Get https://golang.org/x/crypto/nacl/secretbox?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
19、package google.golang.org/grpc/peer: unrecognized import path “google.golang.org/grpc/peer” (https fetch: Get https://google.golang.org/grpc/peer?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
20、package golang.org/x/crypto/blake2b: unrecognized import path “golang.org/x/crypto/blake2b” (https fetch: Get https://golang.org/x/crypto/blake2b?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
21、package golang.org/x/net/html/charset: unrecognized import path “golang.org/x/net/html/charset” (https fetch: Get https://golang.org/x/net/html/charset?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
22、package golang.org/x/crypto/scrypt: unrecognized import path “golang.org/x/crypto/scrypt” (https fetch: Get https://golang.org/x/crypto/scrypt?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
23、package golang.org/x/crypto/salsa20: unrecognized import path “golang.org/x/crypto/salsa20” (https fetch: Get https://golang.org/x/crypto/salsa20?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
24、package google.golang.org/grpc/credentials: unrecognized import path “google.golang.org/grpc/credentials” (https fetch: Get https://google.golang.org/grpc/credentials?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
试过修改hosts文件,安装goproxy,gopm,想过搭建ss,后来看到一篇文章思路,使用git clone试试。
将上面的包逐个整理了一下,这些包的来源路径如下:
https://golang.org/x/crypto
https://google.golang.org/genproto/googleapis/api
https://google.golang.org/genproto/protobuf
https://google.golang.org/grpc
https://google.golang.org/grpc/
ttps://google.golang.org/grpc
https://google.golang.org/grpc
https://golang.org/x/sys
https://golang.org/x/net/
https://golang.org/x/crypto
https://golang.org/x/crypto
https://golang.org/x/time
https://golang.org/x/net
https://google.golang.org/genproto
https://google.golang.org/grpc
https://golang.org/x/crypto
https://golang.org/x/crypto
https://golang.org/x/crypto
https://google.golang.org/grpc
https://golang.org/x/crypto
https://golang.org/x/net/
https://golang.org/x/crypto
https://golang.org/x/crypto
https://google.golang.org/grpc
从以下地址进行clone:
git clone https://github.com/golang/crypto
git clone https://github.com/golang/sys
git clone https://github.com/golang/net
git clone https://github.com/golang/time
git clone https://github.com/grpc/grpc-go.git
mv grpc-go/ grpc/
git clone https://github.com/google/go-genproto.git
mv go-genproto/ genproto/
注意最后两个要修改目录名。
下载了之后,直接make && make install,出错了。网上搜索发现需要:
sudo apt-get install build-essential
make && make install //编译安装,最后可以使用make check检查下安装结果,发现Makefile:124: recipe for target ‘unit’ failed。
再回去看文档,发现可以做一次update,尝试了一下,竟然真的问题就解决了。
cd $GOPATH/src/github.com/lightningnetwork/lnd
git pull
make clean && make && make install
###开启btcd
make btcd //安装btcd
cd /data/btc
vi btcd.conf //编辑btcd.conf文件
rpcuser=xxx
rpcpass=****
configfile=/data/btc/btcd.conf # 我跟data放一起了,默认位置在/root/.btcd/btcd.conf)
datadir=/data/btc
logdir=/data/btc/logfile
maxpeers=50
nohup btcd --configfile=/data/btc/btcd.conf >/data/btc/20190417.out //后台运行btcd
检查区块同步情况。痛苦的区块同步过程竟然达到3周,3周啊,之前在家里使用bitcoind只需要3天就同步完成了。
btcctl getinfo
#运行lnd
首先配置lnd.conf文件,注意这里的参数要与btcd.conf保持一致。
#https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf
[Application Options]
debuglevel=debug
#debughtlc=true
maxpendingchannels=5
alias=ytm.ltd
color=#68F442
[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=btcd
# bitcoin.testnet=1
[bitcoind]
bitcoind.rpcuser=xxx #用户名一致
bitcoind.rpcpass=xxx #密码一致
[autopilot]
autopilot.active=1
autopilot.maxchannels=5
autopilot.allocation=0.6
lnd --configfile=/data/btc/lnd.conf >/data/btc/lnd20190417.out //开启lnd,也可以加nohup后台运行。
好的,下一章,我们继续lnd的管理。
参考文章:
闪电网络技术的前世今生
https://www.douban.com/note/680755028/
闪电网络lnd的github文档
https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md
[初版]人人都能搭建闪电网络
https://www.jianshu.com/p/4f997c5b57ff