Skip to content

Commit

Permalink
Removes steps that only work in Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Conor Okus committed Feb 16, 2024
1 parent a0f1002 commit c91ff23
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/building-a-node-with-ldk/setting-up-a-channel-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -1014,18 +1014,13 @@ chain_tip = Some(

</CodeSwitcher>

**Implementation notes:**
::: tip Full block syncing in mobile environments

If you are connecting full blocks or using BIP 157/158, then it is recommended to use
LDK's [`lightning_block_sync`](https://docs.rs/lightning-block-sync/*/lightning_block_sync/) crate as in the example above: the high-level steps that must be done for both `ChannelManager` and each `ChannelMonitor` are as follows:
Block syncing for mobile clients tends to present several challenges due to resource contraints and network limitiations typically associated with mobile devices. It requires a full node and usually fetches blocks over RPC.

1. Get the last blockhash that each object saw.
- Receive the latest block hash when through [deserializtion](https://docs.rs/lightning/*/lightning/ln/channelmanager/struct.ChannelManagerReadArgs.html) of the `ChannelManager` via `read()`
- Each `ChannelMonitor`'s is in `channel_manager.channel_monitors`, as the 2nd element in each tuple
2. For each object, if its latest known blockhash has been reorged out of the chain, then disconnect blocks using `channel_manager.as_Listen().block_disconnected(..)` or `channel_monitor.block_disconnected(..)` until you reach the last common ancestor with the main chain.
3. For each object, reconnect blocks starting from the common ancestor until it gets to your best known chain tip using `channel_manager.as_Listen().block_connected(..)` and/or `channel_monitor.block_connected(..)`.
4. Call `channel_manager.chain_sync_completed(..)` to complete the initial sync process.
Compact block filters (CBFs) are an alternative approach to syncing the blockchain that addresses some of the challenges associated with mobile clients. Please start a [discussion](https://github.com/orgs/lightningdevkit/discussions) if you would like us to expose `lightning-block-sync` in our bindings.

:::

#### Electrum or Esplora

Expand Down Expand Up @@ -1076,6 +1071,9 @@ tx_sync.sync(confirmables).unwrap();
<template v-slot:kotlin>

```java
// Note: This example calls the Confirm interface directly. The lightning-transaction-sync crate will
// be available in the next bindings release.

// Retrieve transaction IDs to check the chain for un-confirmation.
val relevantTxIdsFromChannelManager: Array<ByteArray> = channelManager .as_Confirm().get_relevant_txids()
val relevantTxIdsFromChannelManager: Array<ByteArray> = chainMonitor.as_Confirm().get_relevant_txids()
Expand Down Expand Up @@ -1121,6 +1119,9 @@ channelManagerConstructor.chain_sync_completed(customEventHandler);
<template v-slot:swift>

```Swift
// Note: This example calls the Confirm interface directly. The lightning-transaction-sync crate will
// be available in the next bindings release.

// Retrieve transaction IDs to check the chain for un-confirmation.
let relevantTxIds1 = channelManager?.asConfirm().getRelevantTxids() ?? []
let relevantTxIds2 = chainMonitor?.asConfirm().getRelevantTxids() ?? []
Expand Down

0 comments on commit c91ff23

Please sign in to comment.