Skip to content

Commit 88e1609

Browse files
author
Conor Okus
committed
Adds handling events page
1 parent 0f484cf commit 88e1609

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

docs/.vuepress/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ const tutorialSidebar = [
132132
"/tutorials/building-a-node-with-ldk/setting-up-a-channel-manager",
133133
"Setting up a Channel Manager",
134134
],
135+
[
136+
"/tutorials/building-a-node-with-ldk/handling-events",
137+
"Handling Events",
138+
],
135139
[
136140
"/tutorials/building-a-node-with-ldk/setting-up-a-peer-manager",
137141
"Setting up a Peer Manager",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Handling Events
2+
3+
LDK requires that you handle many different events throughout your app's life cycle. You can learn more by reading about our event-driven [architecture](/overview/architecture.md).
4+
5+
To start handling events in your application, run:
6+
7+
<CodeSwitcher :languages="{rust:'Rust', java:'Java', kotlin:'Kotlin'}">
8+
<template v-slot:rust>
9+
10+
```rust
11+
use lightning::util::events::{Event};
12+
13+
// In the event handler passed to BackgroundProcessor::start
14+
match event {
15+
Event::PaymentSent { payment_preimage } => {
16+
// Handle successful payment
17+
}
18+
Event::PaymentFailed { payment_hash, rejected_by_dest } => {
19+
// Handle failed payment
20+
}
21+
Event::FundingGenerationReady { .. } =>
22+
}
23+
```
24+
</template>
25+
<template v-slot:java>
26+
27+
```java
28+
import org.ldk.batteries.ChannelManagerConstructor
29+
30+
ChannelManagerConstructor channelManagerConstructor = new ChannelManagerConstructor(
31+
Network.LDKNetwork_Bitcoin,
32+
UserConfig.default(),
33+
latestBlockHash,
34+
latestBlockHeight,
35+
keysManager.as_KeysInterface(),
36+
feeEstimator,
37+
chainMonitor,
38+
router,
39+
txBroadcaster,
40+
logger
41+
);
42+
```
43+
44+
</template>
45+
46+
<template v-slot:kotlin>
47+
48+
```kotlin
49+
import org.ldk.batteries.ChannelManagerConstructor
50+
51+
val channelManagerConstructor = ChannelManagerConstructor(
52+
Network.LDKNetwork_Regtest,
53+
userConfig,
54+
latestBlockHash,
55+
latestBlockHeight,
56+
keysManager.as_KeysInterface(),
57+
feeEstimator,
58+
chainMonitor,
59+
router,
60+
txBroadcaster,
61+
logger
62+
);
63+
```
64+
65+
</template>
66+
</CodeSwitcher>
67+

0 commit comments

Comments
 (0)