1
1
# lnp-node: Lightning Network Protocol Node
2
2
3
3
` lnp-node ` is a new Lightning Network node written from scratch in Rust.
4
- Actually, it's a suite of daemons able to run both Lightning Network Protocol
5
- and Generalized Lightning Channels.
6
-
7
- One may ask: another LN node? Why we need it? And what is "Generalized Lightning
8
- Channels"?
4
+ Actually, it's a suite of daemons/microservices able to run both Lightning
5
+ Network Protocol (LNP) and Generalized Lightning Channels (GLC).
6
+
7
+ One may ask: another LN node? Why we need it? And what is "Lightning network
8
+ protocol" and "Generalized Lightning Channels"?
9
+
10
+ ** Lightning Network Protocol** is normal Lightning messaging protocol extracted
11
+ from BOLTs and extended to support arbitrary messaging, RPC, P2P and publish/
12
+ subscribe APIs over TCP/IP, TCP/Tor, UDP, ZeroMQ and high latency communication
13
+ channels (mesh/satellite networks) with end-to-end encryption. It is 100% LN
14
+ compatible (and in these terms Lightning Network runs on this protocol de-facto)
15
+ but allows much more than current LN uses. The protocol is defined as a set of
16
+ LNPBP15-19 standards, which are strict extensions of BOLTs. In other words, with
17
+ this protocol you can do an arbitrary messaging (and build complex distrubuted
18
+ systems without central authorities like DNS, SSL, IP addresses), so at LNP/BP
19
+ we use it everywhere, even for internal communications between microservices.
20
+
21
+ ** Generalized Lightning Channels** is a way of defining payment channels in a
22
+ modular and extensible way such that you can easily add new transaction outputs
23
+ to the commitment transaction, switch from HTLCs to PTLCs payments, use eltoo &
24
+ do a lot of experimenttion without inventing new messages and standards each
25
+ time: peers are using LNP to negotiate channel and transaction structure with
26
+ partially-signed transactions.
27
+
28
+ Idea for both protocols came from Dr Maxim Orlovsky, Dr Christian Decker and
29
+ Giacomo Zucco discussions in 2019-2020 and implemented by Maxim Orlovsky as a
30
+ part of [ LNP/BP Core Library] ( https://github.com/LNP-BP/rust-lnpbp ) .
31
+ We recommend to watch to [ Potzblitz about LNP Node] ( https://www.youtube.com/watch?v=YmmNsWS5wiM&t=5s&ab_channel=Fulmo%E2%9A%A1 )
32
+ and [ LNP/BP networking presentation] ( https://www.youtube.com/watch?v=kTwZKsbIPbc&t=2123s&ab_channel=LNPBPStandardsAssociation )
33
+ to get a deeper insight into these topics. Presentations slides are also
34
+ avaliable:
35
+ * [ LNP/BP Decentralization Solutions] ( )
36
+ * [ Future of the Lightning Network] ( ) (slides from the Postblitz talk)
37
+
38
+ ## Rationale & features
9
39
10
40
The problem with the existing Lightning node implementations is their very
11
41
limited extensibility for such things as:
@@ -51,12 +81,84 @@ This new node will be used to implement:
51
81
52
82
The node must maintain simple/modular upgradability for:
53
83
84
+ * RGB smart contracts (client-validated smart contract system)
85
+ * Discrete log contracts (DLCs)
54
86
* Schnorr's/Taproot
55
- * Pay-to-elliptic curve point replacement for HTLCs
87
+ * Pay-to-elliptic curve point lock contracts (PTLC) - replacement for HTLCs
56
88
* eltoo
57
89
90
+ ## Design
91
+
92
+ The node (as other nodes maitained by LNP/BP Standards Association and Pandora
93
+ Core company subsidiaries) consists of multiple microservices, communicating
94
+ with each other via LNP ZMQ RPC interface.
95
+
96
+ ![ Node architacture] ( doc/node_arch.jpeg )
97
+
98
+ The set of microservices representing node can run as either:
99
+ 1 ) single daemon process on desktop or a server;
100
+ 2 ) cloud of docker-based daemons, one per microservice, with instance
101
+ scalability and in geo-distributed environment;
102
+ 3 ) inside a single mobile app as threads;
103
+ 4 ) and even different nodes can be combined in their services between themselves
104
+ into a single executables/mobile apps;
105
+ 5 ) all P2P communications are end-to-end encrypted and work over Tor.
106
+
107
+ Other nodes, designed an maintained by LNP/BP Standards Association with the
108
+ same architecture include:
109
+ * [ RGB Node] ( https://github.com/LNP-BP/bp-node ) for running RGB smart contracts
110
+ over bitcoin and lightning network
111
+ * [ BP Node] ( https://github.com/LNP-BP/bp-node ) for indexing bitcoin blockchain
112
+ (you may think of it as a more efficient Electrum server alternative)
113
+ * Bifrost – node for storing/passing client-side-validated data with watchtower
114
+ functionality and used for Storm/RGB/DEX infrastructure
115
+
116
+ Other third parties provide their own nodes:
117
+ * [ Keyring] ( https://github.com/pandoracore/keyring ) for managing private key
118
+ accounts, storage and signatures with support for miniscript and PSBTs
119
+ * [ MyCitadel] ( https://github.com/mycitadel/mycitadel-node ) Bitcoin, LN & RGB
120
+ enabled wallet service with support for other LNP/BP protocols
121
+
122
+ ## Project organization & architecture
123
+
124
+ * [ ` src/api/ ` ] ( src/api/ ) – LNP messages for all daemons used for message bus
125
+ * [ ` src/bin/ ` ] ( src/api/ ) – binaries for daemons & CLI launching main process
126
+ * [ ` src/cli/ ` ] ( src/api/ ) – CLAP-based command line API talking to message bus
127
+ * [ ` src/i8n/ ` ] ( src/api/ ) – functions exposed to FFI talking to message bus
128
+ * [ ` src/<name>d/ ` ] ( src/api/ ) – service/daemon-specific code:
129
+ - [ ` src/wired/ ` ] ( src/wired ) – daemon managing peer connections within
130
+ Lightning peer network using LNP (Lightning network protocol). Specific
131
+ supported message types are defined as a part of
132
+ [ LNP/BP Core Library] ( https://github.com/LNP-BP/rust-lnpbp )
133
+ - [ ` src/channeld ` ] ( src/channeld ) – daemon managing generalized Lightning
134
+ channels with their extensions
135
+ - [ ` src/lightningd ` ] ( src/lightningd ) – daemon initializing creation of new
136
+ channels
137
+ - [ ` src/routed ` ] ( src/routed ) – daemon managing routing information
138
+ - [ ` src/gossip ` ] ( src/gossip ) – daemon managing gossip data
139
+ - [ ` src/keyd ` ] ( src/keyd ) - key managing daemon
140
+
141
+ Each daemon (more correctly "microservice", as it can run as a thread, not
142
+ necessary a process) or other binary (like CLI tool) follows the same
143
+ organization concept for module/file names:
144
+ * ` error.rs ` – daemon-specific error types
145
+ * ` config.rs ` – CLAP arguments & daemon configuration data
146
+ * ` runtime.rs ` – singleton managing main daemon thread and keeping all ZMQ/P2P connections and sockets; receiving and processing messages through them
147
+ * ` processor.rs ` – business logic functions & internal state management which does not depend on external communications/RPC
148
+ * ` index/ ` , ` storage/ ` , ` cache/ ` – storage interfaces and engines
149
+ * ` db/ ` – SQL-specific schema and code, if needed
150
+
151
+ ## Ways of communication
152
+
153
+ * IRC channels on Freenode
154
+ * \# lnp-bp: discussions on this and other LNP/BP projects
155
+ * \# rust-bitcoin: here you can get general support on rust-lightning
156
+ * \# lightning-dev: here better to ask generic lightning-network questions
157
+ * dr_orlovsky: my account on IRC
158
+ * Lightning Hackdays Mattermost channel:
159
+ < https://mm.fulmo.org/fulmo/channels/x-rust-ln-node >
58
160
59
- ## Previous work & docs
161
+ ## Previous (mostly independent/unrelated) work
60
162
61
163
* ` rust-lightning ` architecture explanation:
62
164
< https://github.com/rust-bitcoin/rust-lightning/blob/master/ARCH.md >
@@ -77,16 +179,3 @@ The node must maintain simple/modular upgradability for:
77
179
< https://github.com/LNP-BP/txserv >
78
180
* SquareCrypto Development Kit based on ` rust-lightning ` library:
79
181
< http://lightningdevkit.org/ >
80
-
81
-
82
- ## Ways of communication
83
-
84
- * IRC channels on Freenode
85
- * \# lnp-bp: discussions on this and other LNP/BP projects
86
- * \# rust-bitcoin: here you can get general support on rust-lightning
87
- * \# lightning-dev: here better to ask generic lightning-network questions
88
- * dr_orlovsky: my account on IRC
89
- * Lightning Hackdays Mattermost channel:
90
- < https://mm.fulmo.org/fulmo/channels/x-rust-ln-node >
91
-
92
- ## Architecture
0 commit comments