Skip to content

Commit 4e831f9

Browse files
Merge pull request #18 from valentinewallace/update-overview
Update overview
2 parents 8cbec31 + 31326cf commit 4e831f9

7 files changed

+161
-8
lines changed

docs/build_node.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This document covers everything you need to make a node using LDK.
99

1010
* [Setup](#setup) covers everything you need to do to set up LDK on startup.
1111
* [Running LDK](#running-ldk) covers everything you need to do while LDK is running to keep it operational.
12-
* [Using LDK](#using-ldk) covers most lightning operations you'll want to use, such as opening a channel. Sending and receiving payments are supported but not yet a part of this guide.
12+
* [Using LDK](#using-ldk) covers most lightning operations you'll want to use,
13+
such as opening a channel. Sending and receiving payments are supported but
14+
not yet a part of this guide.
1315

1416
Note that LDK does not assume that safe shutdown is available, so there is no
1517
shutdown checklist.
@@ -25,7 +27,9 @@ shutdown checklist.
2527
final fee_estimator = FeeEstimator.new_impl((confirmation_target -> 253));
2628
```
2729

28-
**Implementation notes:** Rather than using static fees, you'll want to fill in the lambda with fetching up-to-date fees from a source like bitcoin core or your own API endpoint.
30+
**Implementation notes:** Rather than using static fees, you'll want to fill in
31+
the lambda with fetching up-to-date fees from a source like bitcoin core or your
32+
own API endpoint.
2933

3034
**Dependencies:** *none*
3135

docs/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ can be supplied by the user or by one of LDK's sample modules.
1212

1313
## How To Use These Docs
1414
"Getting Started" + "Overview" provide an introduction to the architecture and
15-
design philosophy of LDK.
15+
design philosophy of LDK.
1616

1717
"Build a Node: Checklist" walks through how to specifically integrate LDK into
1818
your application, as well as documentation for what features are currently available

docs/open_channel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Opening a Channel with LDK"
44
---
55

66
## Prerequisites
7-
See "Build a Node: Checklist" for preparing LDK to open a channel. This guide
7+
See [Building a Node with LDK](build_node.md) for preparing LDK to open a channel. This guide
88
is a follow-up.
99

1010
## Overview

docs/overview.md

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,118 @@ title: Overview
44
slug: /
55
---
66

7+
import useBaseUrl from '@docusaurus/useBaseUrl';
8+
79
LDK is a flexible lightning implementation with supporting batteries (or modules).
8-
The core lightning implementation is Rust-Lightning.
910

10-
See the Rust-Lightning `README` for more overview: https://github.com/rust-bitcoin/rust-lightning
11+
## To jump into integrating LDK with your application, click [here](build_node.md)
12+
13+
## Introduction
14+
LDK/Rust-Lightning is a generic library which allows you to build a lightning
15+
node without needing to worry about getting all of the lightning state machine,
16+
routing, and on-chain punishment code (and other chain interactions) exactly
17+
correct. Note that Rust-Lightning isn't, in itself, a node. There are various
18+
working/in progress demos which could be used as a node today, but if you "just"
19+
want a generic lightning node, you're almost certainly better off with
20+
`c-lightning`/`lnd` - if, on the other hand, you want to integrate lightning
21+
with custom features such as your own chain sync, your own key management, your
22+
own data storage/backup logic, etc., LDK is likely your only option.
23+
24+
We are currently working on a demo node which fetches blockchain data and
25+
on-chain funds via Bitcoin Core RPC/REST. The individual pieces of that demo
26+
are/will be composable, so you can pick the off-the-shelf parts you want and
27+
replace the rest.
28+
29+
## LDK Batteries
30+
While LDK provides all the core lightning state machine logic, other
31+
batteries/modules are needed to run a node. LDK interacts with these modules
32+
through generic interfaces, meaning the user can choose the implementation that
33+
best suits their needs. LDK provides sample implementations for many of these
34+
batteries, which are enumerated below.
35+
36+
* On-disk storage
37+
* You can store the channel state any way you want - whether Google
38+
Drive/iCloud, a local disk, any key-value store/database/a remote server, or
39+
any combination of them - we provide a clean API that provides objects which
40+
can be serialized into simple binary blobs, and stored in any way you wish.
41+
* [**Sample module in Rust**](https://github.com/rust-bitcoin/rust-lightning/tree/main/lightning-persister)
42+
* Blockchain data
43+
* We provide a simple `block_connected`/`block_disconnected`
44+
API which you provide block headers and transaction information to. We also
45+
provide an API for getting information about transactions we wish to be
46+
informed of, which is compatible with Electrum server requests/neutrino
47+
filtering/etc.
48+
* [**WIP sample module in Rust**](https://github.com/rust-bitcoin/rust-lightning/pull/791)
49+
* On-chain funds wallet/UTXO management
50+
* Rust-Lightning/LDK owns on-chain funds as long as they are claimable as
51+
a part of a lightning output which can be contested - once a channel is closed
52+
and all on-chain outputs are spendable only by the user, we provide users
53+
notifications that a UTXO is "theirs" again and it is up to them to spend it
54+
as they wish. Additionally, channel funding is accomplished with a generic API
55+
which notifies users of the output which needs to appear on-chain, which they
56+
can then create a transaction for. Once a transaction is created, we handle
57+
the rest. This is a large part of our API's goals - making it easier to
58+
integrate lightning into existing on-chain wallets which have their own
59+
on-chain logic - without needing to move funds in and out of a separate
60+
lightning wallet with on-chain transactions and a separate private key system.
61+
* LDK does not currently provide a sample wallet module, but its sample node
62+
implementation uses Bitcoin Core's wallet for UTXO management e.g. [here](https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/blob/139a653eeba313284c6d9d2eb2776d30dbb0ca3d/src/main.rs#L219)
63+
* Networking
64+
* To enable a user to run a full lightning node on an embedded
65+
machine, we don't specify exactly how to connect to another node at all! We
66+
provide a default implementation which uses TCP sockets, but, e.g., if you
67+
wanted to run your full lightning node on a hardware wallet, you could, by
68+
piping the lightning network messages over USB/serial and then sending them in
69+
a TCP socket from another machine.
70+
* [**Sample module in Rust**](https://github.com/rust-bitcoin/rust-lightning/tree/main/lightning-net-tokio)
71+
* [**Sample module in Java**](https://github.com/lightningdevkit/ldk-garbagecollected/tree/main/src/main/java/org/ldk/batteries)
72+
* Private keys
73+
* LDK has "default implementations", but users can choose to provide private
74+
keys to RL/LDK in any way they wish following a simple API. We even support a
75+
generic API for signing transactions, allowing users to run RL/LDK without any
76+
private keys in memory and/or putting private keys only on hardware wallets.
77+
* [LDK's `KeyManager` docs](https://docs.rs/lightning/0.0.12/lightning/chain/keysinterface/struct.KeysManager.html). While LDK's default implementation is currently within Rust-Lightning, it still is considered a "sample module."
78+
* Transaction filtering
79+
* Clients running a light client may wish to filter for transactions on a separate server, in which case LDK will tell them about transactions to filter for. More information is available in the [Blockchain Data guide](blockdata.md).
80+
* Fee estimation
81+
* LDK's sample node implementation uses Bitcoin Core's fee estimation API [here](https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/blob/139a653eeba313284c6d9d2eb2776d30dbb0ca3d/src/chain_monitor.rs#L31).
82+
* Transaction broadcasting
83+
* LDK's sample node implementation uses Bitcoin Core's transaction broadcasting API [here](https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/blob/139a653eeba313284c6d9d2eb2776d30dbb0ca3d/src/chain_monitor.rs#L132).
84+
* Random number generation
85+
* Because Rust-Lightning aims to make no system calls, it is restricted from generating its own randomness.
86+
* LDK's sample node implementation uses Rust's `rand` crate [here](https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc/blob/139a653eeba313284c6d9d2eb2776d30dbb0ca3d/src/main.rs#L512) and elsewhere.
87+
88+
89+
## LDK Architecture
90+
![LDK Architecture](assets/ldk-architecture.svg)
91+
92+
LDK's core components are shown in the center box labeled `lightning`. Boxes
93+
with dotted borders are LDK's batteries — these must be configured with either
94+
off-the-shelf or custom implementations that you provide.
95+
96+
EventHandler in the diagram is not so much a necessary LDK battery, but instead
97+
refers to the fact that LDK generates events that the user should handle (e.g.
98+
the `PaymentReceived` event).
99+
100+
## References
101+
102+
### [Rust Documentation](https://docs.rs/lightning)
103+
104+
These provide the most searchable and comprehensive documentation on LDK.
105+
If you're using Java and want more information on any method/struct/etc., searching
106+
the Rust docs for the Rust version of that struct/method is your best bet.
107+
108+
### [Rust Sample Node](https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc)
109+
110+
While this node is a little outdated, it's still a very useful reference for how to construct
111+
a lightning node using LDK.
112+
113+
### [Swift LDK Documentation](https://github.com/arik-so/SwiftLightning/tree/master/Documentation)
114+
115+
These docs are mainly geared towards how Swift could call LDK C bindings directly, but still may
116+
provide a useful overview of Rust Lightning in the context of language bindings.
117+
118+
### [LDK Architecture](https://docs.google.com/drawings/d/1Ql-q5gyrPnJhi7z_D39jayG0HEEVh6UEY1eULXb03Eg/edit?usp=sharing)
119+
120+
Gives a high-level organization of LDK and how the pieces fit together. Variations of this diagram
121+
are used throughout the site. This is the primary source and is still a work in progress.

docs/use_cases.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,41 @@ id: use_cases
33
title: Use Cases for LDK
44
---
55

6-
LDK is designed to provide incredible flexibility in integrating a lightning node into your application. It is not designed to be a stand-alone application and those seeking a full lightning node to run may wish to look elsewhere. LDK focuses on ensuring tight integration with existing on-chain wallets is easy, allowing reuse of existing blockchain download, key management, UTXO management, and on-disk/cloud storage. See the Getting Started page for more details on the interfaces LDK provides for integration.
6+
The standard lightning use case is running a standalone node on one's laptop.
7+
Here's some other use cases that LDK supports.
8+
9+
## Mobile Devices
10+
Mobile devices with lightning have unique requirements often not well served by
11+
today's lightning ecosystem. Not only do they need to operate with minimal
12+
footprint, they also have intermittent data access and cannot shutdown safely.
13+
More importantly, many existing wallets already have business logic to handle
14+
blockchain data, keys, and storage, and do not wish to duplicate much of that
15+
logic to integrate lightning (at worst fetching the blockchain twice). LDK
16+
offers a flexible API to allow users to integrate lightning with their own keys,
17+
blockchain data, and storage. To allow full flexibility in footprint, the API
18+
supports routing data being fetched via the Lightning P2P protocol, an external
19+
service, or routes can be calculated off-device. It also provides cross-platform
20+
compatibility for free, allowing synchronization of lightning state across
21+
devices and, as long as there is protection from simultaneous-updates, users to
22+
access their wallet on any device. See the [Overview](overview.md) page for more
23+
details on the interfaces LDK provides for integration.
24+
25+
## HSMs (Hardware Security Modules)
26+
27+
LDK Supports various HSM configurations. In conjunction with the [Lightning
28+
Signer project](https://github.com/lightning-signer/) , an external HSM can be
29+
used to verify most protocol details about states before signing, ensuring host
30+
compromise cannot steal funds by broadcasting revoked states. For nodes seeking
31+
a higher level of assurance, the entire Rust-Lightning channel state machine can
32+
be run on an offline device, communicating with the outside world via a proxy
33+
host which maintains TCP connections with peers. Such a configuration ensures
34+
all details of the lightning protocol are enforced without consideration of host
35+
compromise.
36+
37+
## Production Lightning Nodes
38+
Many large Bitcoin transactors have large amounts of custom-built infrastructure
39+
for interacting with the Bitcoin blockchain. Such tight integration with
40+
business logic may be difficult with existing lightning implementations focusing
41+
on standalone operation. For such transactors, LDK offers the possibility of
42+
integrating a library in their native runtime, storing and handling lightning
43+
data and events in the same way they do blockchain events.

docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
organizationName: 'lightningdevkit', // Usually your GitHub org/user name.
1010
projectName: 'lightningdevkit.org', // Usually your repo name.
1111
themeConfig: {
12+
sidebarCollapsible: false,
1213
navbar: {
1314
title: 'LDK',
1415
logo: {

sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
someSidebar: {
3-
'Lightning Development Kit': ['overview', 'getting_started', 'use_cases', 'references'],
3+
'Lightning Development Kit': ['overview', 'use_cases'],
44
Guides: ['build_node', 'open_channel', 'key_mgmt', 'blockdata'],
55
},
66
};

0 commit comments

Comments
 (0)