Skip to content

Commit c9af937

Browse files
Merge pull request #19 from valentinewallace/update-node-guide
Update "Build Node" guide
2 parents 4e831f9 + dffc2a7 commit c9af937

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

docs/build_node.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ final chain_monitor = ChainMonitor.constructor_new(null, tx_broadcaster, logger,
128128
**Example:**
129129
```java
130130
byte[] key_seed = new byte[32];
131-
<insert code to fill key_seed with random bytes>
131+
// <insert code to fill key_seed with random bytes OR if restarting, reload the
132+
// seed from disk>
132133
// Notes about this `KeysManager`:
133134
// * it is parameterized by the mainnet bitcoin network, but this should be
134135
// swapped out for testnet or regtest as needed.
@@ -139,7 +140,12 @@ KeysManager keys = KeysManager.constructor_new(key_seed,
139140
LDKNetwork.LDKNetwork_Bitcoin, System.currentTimeMillis() / 1000,
140141
(int) (System.currentTimeMillis() * 1000));
141142
```
142-
**Implementation notes:** See the Key Management guide for more information.
143+
**Implementation notes:**
144+
* See the Key Management guide for more information.
145+
* Note that you must write the `key_seed` you give to the `KeysManager` on
146+
startup to disk, and keep using it to initialize the `KeysManager` every time
147+
you restart. This `key_seed` is your node's private key, that corresponds to
148+
its node pubkey.
143149

144150
**Dependencies:** random bytes, the current bitcoin network
145151

@@ -185,13 +191,6 @@ channel_monitors.put(channel_monitor_funding_txo_str, channel_monitor);
185191
```
186192
**Dependencies:** `KeysManager`
187193

188-
### Sync `ChannelMonitor`s to chain tip
189-
**What it's used for:** ensuring the channel data state is up-to-date with the bitcoin blockchain
190-
191-
**Example:** in Rust, of bringing a `ChannelMonitor` up to chain tip: https://github.com/rust-bitcoin/rust-lightning/pull/763/files#diff-f457bab978fc8b89ad308d5195f99d7b65a4a6ba1673c5f164104b2dda9a0db6R251. The `ChannelMonitor` is the `chain_listener` parameter. See the linked function and the `find_fork` function within it.
192-
193-
**Implementation notes:** when you read each `ChannelMonitor` off of disk, it comes with a blockhash which was the last block the `ChannelMonitor` saw. If the blockhash is on a fork of the main chain, then first you need to disconnect blocks until the `ChannelMonitor` gets to a common ancestor with the main chain. Then after this disconnection happens if it needs to, you then need to connect recent blocks until the `ChannelMonitor` is at the current chain tip.
194-
195194
### Initialize the `ChannelManager`
196195
**What it's used for:** managing channel state
197196

@@ -227,6 +226,19 @@ final channel_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ
227226

228227
**References:** [Rust `ChannelManager` docs](https://docs.rs/lightning/0.0.12/lightning/ln/channelmanager/struct.ChannelManager.html), [Java `ChannelManager` bindings](https://github.com/lightningdevkit/ldk-garbagecollected/blob/main/src/main/java/org/ldk/structs/ChannelManager.java)
229228

229+
### Sync `ChannelMonitor`s and `ChannelManager` to chain tip
230+
**What it's used for:** ensuring the channel data state is up-to-date with the bitcoin blockchain
231+
232+
**Example:** in Rust, of bringing a `ChannelMonitor` up to chain tip: https://github.com/rust-bitcoin/rust-lightning/pull/763/files#diff-f457bab978fc8b89ad308d5195f99d7b65a4a6ba1673c5f164104b2dda9a0db6R251. The `ChannelMonitor` is the `chain_listener` parameter. See the linked function and the `find_fork` function within it.
233+
234+
**Implementation notes:** when you read each `ChannelMonitor` off of disk, it
235+
comes with a blockhash which was the last block the `ChannelMonitor` saw. The
236+
same is true for the `ChannelManager`. If the blockhash is on a fork of the main
237+
chain, then first you need to disconnect blocks until the `ChannelMonitor` or
238+
`ChannelManager` gets to a common ancestor with the main chain. Then after this
239+
disconnection happens if it needs to, you then need to connect recent blocks
240+
until the `ChannelMonitor` or `ChannelManager` is at the current chain tip.
241+
230242
### Give `ChannelMonitor`s to `ChainMonitor`
231243
** What it's used for:** `ChainMonitor` is responsible for updating the `ChannelMonitor`s during LDK node operation.
232244

0 commit comments

Comments
 (0)