Lightning Clientにおける人格

なぜこんな形態になっているのか、LNDの仕組みから確認する。 結論から言えば、一つのクライアントにpeerは固有のもので、複数作れる構造になっていない。


これは、identity pubkeyとhostによって識別される。 下記で自分のpubkeyは確認できて、

lncli --network=testnet getinfo  
    "version": "0.5.2-99-beta commit=v0.5.1-beta-814-g2a652455aaea661b147b6adca0ff51edcd268508",
    "identity_pubkey": "026443cbf5d9915ab0ad1d710229a14823a96b3f643fb08c7ad4b875a4cee58ddb",
    "alias": "026443cbf5d9915ab0ad",
    "num_pending_channels": 0,
    "num_active_channels": 0,
    "num_inactive_channels": 0,
    "num_peers": 3,
    "block_height": 1483599,
    "block_hash": "00000000000000f058a0325b817372ae151985a475c5af0c43500743e34b07c1",
    "best_header_timestamp": 1551839165,
    "synced_to_chain": true,
    "testnet": true,
    "chains": [
            "chain": "bitcoin",
            "network": "testnet"
    "uris": null


lncli connect [command options] <pubkey>@host  

このconnect自体はTCP connectionを使った確立で、pubkeyは、基本的には一つのLN clientで一つしか確立されない。

// NetAddress represents information pertaining to the identity and network
// reachability of a peer. Information stored includes the node's identity
// public key for establishing a confidential+authenticated connection, the
// service bits it supports, and a TCP address the node is reachable at.
// TODO(roasbeef): merge with LinkNode in some fashion
type NetAddress struct {  
    // IdentityKey is the long-term static public key for a node. This node is
    // used throughout the network as a node's identity key. It is used to
    // authenticate any data sent to the network on behalf of the node, and
    // additionally to establish a confidential+authenticated connection with
    // the node.
    IdentityKey *btcec.PublicKey

    // Address is the IP address and port of the node. This is left
    // general so that multiple implementations can be used.
    Address net.Addr

    // ChainNet is the Bitcoin network this node is associated with.
    // TODO(roasbeef): make a slice in the future for multi-chain
    ChainNet wire.BitcoinNet