File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
tutorials/building-a-node-with-ldk Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ const tutorialSidebar = [
98
98
children : [
99
99
[ '/tutorials/building-a-node-with-ldk/introduction' , 'Introduction' ] ,
100
100
[ '/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' ] ,
101
102
[ '/tutorials/building-a-node-with-ldk/setting-up-a-peer-manager' , 'Setting up a Peer Manager' ] ,
102
103
[ '/tutorials/building-a-node-with-ldk/connect-to-peers' , 'Connect to Peers' ] ,
103
104
[ '/tutorials/building-a-node-with-ldk/opening-a-channel' , 'Opening a Channel' ]
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments