Skip to content

Commit d793163

Browse files
author
Conor Okus
committed
Adds handling events page
1 parent f5277c4 commit d793163

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const tutorialSidebar = [
9898
children: [
9999
['/tutorials/building-a-node-with-ldk/introduction', 'Introduction'],
100100
['/tutorials/building-a-node-with-ldk/setting-up-a-channel-manager', 'Setting up a Channel Manager'],
101+
['/tutorials/building-a-node-with-ldk/handling-events', 'Handling Events'],
101102
['/tutorials/building-a-node-with-ldk/setting-up-a-peer-manager', 'Setting up a Peer Manager'],
102103
['/tutorials/building-a-node-with-ldk/connect-to-peers', 'Connect to Peers'],
103104
['/tutorials/building-a-node-with-ldk/opening-a-channel', 'Opening a Channel']
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)