LND送金
lndでウォレットの作成までできたあと実際に送金を行う
bitcoinのノードは bitcoind を使用する。
ネットワークは testnet を使用する。
準備
今回は二者間での送金をする。(alice, bob)
$ mkdir alice bob
アリスのlndを起動
code:alice
$ cd alice
$ lnd --rpclisten=localhost:10001 --listen=localhost:10011 --restlisten=localhost:8001 --datadir=data --logdir=log --debuglevel=info --bitcoin.testnet --bitcoin.active --bitcoin.node=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 --bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
別ターミナルでbobのlndを起動
code:bob
$ cd bob
$ lnd --rpclisten=localhost:10002 --listen=localhost:10012 --restlisten=localhost:8002 --datadir=data --logdir=log --debuglevel=info --bitcoin.testnet --bitcoin.active --bitcoin.node=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 --bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
lnd.confを編集しておくと上記のオプションが省略できる
code:lnd.conf
$ vim /Users/username/Library/Application\ Support/Lnd/lnd.conf datadir=data
logdir=log
debuglevel=info
bitcoin.testnet=1
bitcoin.active=1
bitcoin.node=bitcoind
bitcoind.rpcuser=user
bitcoind.rpcpass=pass
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
上記に加えて alias を作成しておくと便利
code:alias
$ vim ~/.zshrc
alias lncli-alice="lncli --rpcserver=localhost:10001 --macaroonpath=data/chain/bitcoin/testnet/admin.macaroon"
alias lncli-bob="lncli --rpcserver=localhost:10002 --macaroonpath=data/chain/bitcoin/testnet/admin.macaroon"
ウォレットとチャネル作成
aliceのウォレットを作成
code:wallet
~alice $ lncli --rpcserver=localhost:10001 --macaroonpath=data/chain/bitcoin/testnet/admin.macaroon create
# passwordを入力
alice $lncli --rpcserver=localhost:10001 --macaroonpath=data/chain/bitcoin/testnet/admin.macaroon getinfo
{
"version": "0.12.99-beta commit=v0.12.0-beta-271-gd85d8282",
"commit_hash": "d85d82824ca5ce7da6434c589e32aa41130a6074",
"identity_pubkey": "02aa17e1d351db3a5427e58d752aae010fa17230055fa929b4a6b2f1292ecf0cd3",
"alias": "02aa17e1d351db3a5427",
"color": "#3399ff",
"num_pending_channels": 0,
"num_active_channels": 1,
"num_inactive_channels": 0,
"num_peers": 4,
"block_height": 1972747,
"block_hash": "000000000000001b0af4fa1e0e636d4779162d157a8501f342f447b78bbfb96d",
"best_header_timestamp": "1619432084",
"synced_to_chain": true,
"synced_to_graph": true,
"testnet": true,
"chains": [
{
"chain": "bitcoin",
"network": "testnet"
}
],
"uris": [
],
"features": {
"0": {
"name": "data-loss-protect",
"is_required": true,
"is_known": true
},
"5": {
"name": "upfront-shutdown-script",
"is_required": false,
"is_known": true
},
"7": {
"name": "gossip-queries",
"is_required": false,
"is_known": true
},
"9": {
"name": "tlv-onion",
"is_required": false,
"is_known": true
},
"12": {
"name": "static-remote-key",
"is_required": true,
"is_known": true
},
"14": {
"name": "payment-addr",
"is_required": true,
"is_known": true
},
"17": {
"name": "multi-path-payments",
"is_required": false,
"is_known": true
}
}
}
bobも同様に作成する
bob$ lncli --rpcserver=localhost:10002 --macaroonpath=data/chain/bitcoin/testnet/admin.macaroon create
アドレス作成
newaddressでPay to Nested Witness Key Hashのアドレスが得られる
code:address
alice$ lncli-alice newaddress np2wkh
{
"address": 2NAEbxJ6ugJ8R1axMSBRWTr7J2o7SLL14w8
}
bob$ lncli-bob newaddress np2wkh
{
"address": 2NBLEJ4uJJXXzKt25QJFVUdt5sEeLYefxnJ
}
作成したアドレスには残高がないため送金する。bitcoin Core などの送金で良い。
注意:lndではチャネルを開く際に0.01BTC必要となるため、どちらのアドレスにも0.01BTCを送っておく。