Skip to content

Commit 95ca4ce

Browse files
author
Conor Okus
committed
Improve fee estimator code examples
1 parent 526a189 commit 95ca4ce

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

docs/tutorials/building-a-node-with-ldk/setting-up-a-channel-manager.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ To add a `ChannelManager` to your application, run:
2828
```java
2929
import org.ldk.batteries.ChannelManagerConstructor
3030

31-
ChannelManagerConstructor channel_manager_constructor = new ChannelManagerConstructor(
31+
ChannelManagerConstructor channelManagerConstructor = new ChannelManagerConstructor(
3232
Network.LDKNetwork_Bitcoin,
3333
UserConfig.default(),
34-
best_block_hash,
35-
block_height,
36-
keys_manager.as_KeysInterface(),
37-
fee_estimator,
38-
chain_monitor,
34+
latestBlockHash,
35+
latestBlockHeight,
36+
keysManager.as_KeysInterface(),
37+
feeEstimator,
38+
chainMonitor,
3939
router,
40-
tx_broadcaster,
40+
txBroadcaster,
4141
logger
4242
);
4343
```
@@ -54,10 +54,10 @@ To add a `ChannelManager` to your application, run:
5454
userConfig,
5555
latestBlockHash,
5656
latestBlockHeight,
57-
Global.keysManager?.as_KeysInterface(),
57+
keysManager.as_KeysInterface(),
5858
feeEstimator,
59-
Global.chainMonitor,
60-
Global.router,
59+
chainMonitor,
60+
router,
6161
txBroadcaster,
6262
logger
6363
);
@@ -68,7 +68,7 @@ To add a `ChannelManager` to your application, run:
6868

6969
There are a few dependencies needed to get this working. Let's walk through setting up each one so we can plug them into our `ChannelManager`.
7070

71-
### Step 1. Initialize the `FeeEstimator`
71+
### Initialize the `FeeEstimator`
7272

7373
**What it's used for:** estimating fees for on-chain transactions that LDK wants broadcasted.
7474

@@ -114,20 +114,33 @@ There are a few dependencies needed to get this working. Let's walk through sett
114114
}
115115
}
116116

117-
FeeEstimator fee_estimator = FeeEstimator.new_impl(new YourFeeEstimator());
117+
FeeEstimator feeEstimator = FeeEstimator.new_impl(new YourFeeEstimator());
118118
```
119119

120120
</template>
121121

122122
<template v-slot:kotlin>
123123

124124
```kotlin
125-
object LDKFeeEstimator: FeeEstimatorInterface {
126-
override fun get_est_sat_per_1000_weight(conf_target: ConfirmationTarget?): Int {
127-
// insert code to retieve a fee rate
125+
object YourFeeEstimator : FeeEstimatorInterface {
126+
override fun get_est_sat_per_1000_weight(confirmationTarget: ConfirmationTarget?): Int {
127+
if (confirmationTarget == ConfirmationTarget.LDKConfirmationTarget_Background) {
128+
// <insert code to retrieve a background feerate>
129+
}
130+
131+
if (confirmationTarget == ConfirmationTarget.LDKConfirmationTarget_Normal) {
132+
// <insert code to retrieve a normal (i.e. within ~6 blocks) feerate>
133+
}
134+
135+
if (confirmationTarget == ConfirmationTarget.LDKConfirmationTarget_HighPriority) {
136+
// <insert code to retrieve a high-priority feerate>
137+
}
138+
// return default fee rate
128139
}
129-
}
130-
```
140+
}
141+
142+
val feeEstimator: FeeEstimator = FeeEstimator.new_impl(YourFeeEstimator)
143+
```
131144

132145
</template>
133146
</CodeSwitcher>

0 commit comments

Comments
 (0)