Skip to content

Commit 0a6a604

Browse files
committed
update serialization documentation
1 parent 0870244 commit 0a6a604

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/setup.md

+18
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,24 @@ Finally, we can proceed by instantiating the ChannelManager.
243243
let channelManager = ChannelManager.init(fee_est: feeEstimator, chain_monitor: chainMonitor.as_Watch(), tx_broadcaster: broadcaster, logger: logger, keys_manager: keysInterface, config: userConfig, params: chainParameters)
244244
```
245245

246+
#### Serializing and restoring a ChannelManager
247+
248+
If you need to serialize a channel manager, you can simply call its write method on itself:
249+
250+
```swift
251+
let serializedChannelManager: [UInt8] = channelManager.write(obj: channelManager)
252+
```
253+
254+
If you have a channel manager you previously serialized, you can restore it like this:
255+
256+
```swift
257+
let serialized_channel_manager: [UInt8] = [2, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247, 79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 0, 10, 174, 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 238, 87, 135, 110, 67, 215, 108, 228, 66, 226, 192, 37, 6, 193, 120, 186, 5, 214, 209, 16, 169, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] // <insert bytes you would have written in following the later step "Persist channel manager">
258+
let serializedChannelMonitors: [[UInt8]] = []
259+
let channel_manager_constructor = try ChannelManagerConstructor(channel_manager_serialized: serialized_channel_manager, channel_monitors_serialized: serializedChannelMonitors, keys_interface: keysInterface, fee_estimator: feeEstimator, chain_monitor: chainMonitor, filter: filter, tx_broadcaster: broadcaster, logger: logger)
260+
261+
let channel_manager = channel_manager_constructor.channelManager;
262+
```
263+
246264
### NetGraphMsgHandler
247265

248266
If you intend to use the LDK's built-in routing algorithm, you will need to instantiate

0 commit comments

Comments
 (0)