@@ -12,17 +12,18 @@ import org.ldk.structs.Event.BumpTransaction
1212import org.ldk.structs.Option_ThirtyTwoBytesZ
1313import org.ldk.structs.Option_u64Z
1414import org.ldk.structs.PaymentPurpose
15+ import org.ldk.structs.Result_NoneReplayEventZ
1516import java.io.File
1617
1718class LdkChannelManagerPersister : ChannelManagerConstructor .EventHandler {
18- override fun handle_event (event : Event ) {
19+ override fun handle_event (event : Event ): Result_NoneReplayEventZ {
1920 (event as ? Event .FundingGenerationReady )?.let { fundingGenerationReady ->
2021 val body = Arguments .createMap()
2122 body.putHexString(" temp_channel_id" , fundingGenerationReady.temporary_channel_id._a )
2223 body.putHexString(" output_script" , fundingGenerationReady.output_script)
2324 body.putHexString(" user_channel_id" , fundingGenerationReady.user_channel_id.leBytes)
2425 body.putInt(" value_satoshis" , fundingGenerationReady.channel_value_satoshis.toInt())
25- return LdkEventEmitter .send(EventTypes .channel_manager_funding_generation_ready, body)
26+ LdkEventEmitter .send(EventTypes .channel_manager_funding_generation_ready, body)
2627 }
2728
2829 (event as ? Event .PaymentClaimable )?.let { paymentClaimable ->
@@ -40,7 +41,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
4041 body.putString(" state" , " pending" )
4142
4243 persistPaymentClaimed(body)
43- return LdkEventEmitter .send(EventTypes .channel_manager_payment_claimable, body)
44+ LdkEventEmitter .send(EventTypes .channel_manager_payment_claimable, body)
4445 }
4546
4647 (event as ? Event .PaymentSent )?.let { paymentSent ->
@@ -54,7 +55,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
5455
5556 persistPaymentSent(body.toHashMap())
5657
57- return LdkEventEmitter .send(EventTypes .channel_manager_payment_sent, body)
58+ LdkEventEmitter .send(EventTypes .channel_manager_payment_sent, body)
5859 }
5960
6061 (event as ? Event .OpenChannelRequest )?.let { openChannelRequest ->
@@ -67,7 +68,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
6768 body.putBoolean(" requires_zero_conf" , openChannelRequest.channel_type.requires_zero_conf())
6869 body.putBoolean(" supports_zero_conf" , openChannelRequest.channel_type.supports_zero_conf())
6970 body.putBoolean(" requires_anchors_zero_fee_htlc_tx" , openChannelRequest.channel_type.requires_anchors_zero_fee_htlc_tx())
70- return LdkEventEmitter .send(EventTypes .channel_manager_open_channel_request, body)
71+ LdkEventEmitter .send(EventTypes .channel_manager_open_channel_request, body)
7172 }
7273
7374 (event as ? Event .PaymentPathSuccessful )?.let { paymentPathSuccessful ->
@@ -80,7 +81,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
8081 event.path._hops .forEach { pathHops.pushMap(it.asJson) }
8182 body.putArray(" path_hops" , pathHops)
8283
83- return LdkEventEmitter .send(EventTypes .channel_manager_payment_path_successful, body)
84+ LdkEventEmitter .send(EventTypes .channel_manager_payment_path_successful, body)
8485 }
8586
8687 (event as ? Event .PaymentPathFailed )?.let { paymentPathFailed ->
@@ -102,22 +103,22 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
102103 ))
103104 }
104105
105- return LdkEventEmitter .send(EventTypes .channel_manager_payment_path_failed, body)
106+ LdkEventEmitter .send(EventTypes .channel_manager_payment_path_failed, body)
106107 }
107108
108109 (event as ? Event .PaymentFailed )?.let { paymentFailed ->
109110 val body = Arguments .createMap()
110111 body.putHexString(" payment_id" , paymentFailed.payment_id)
111- body.putHexString(" payment_hash" , paymentFailed.payment_hash)
112+ body.putHexString(" payment_hash" , ( paymentFailed.payment_hash as Option_ThirtyTwoBytesZ . Some ).some )
112113
113114 persistPaymentSent(hashMapOf(
114115 " payment_id" to paymentFailed.payment_id!! .hexEncodedString(),
115- " payment_hash" to paymentFailed.payment_hash.hexEncodedString(),
116+ " payment_hash" to ( paymentFailed.payment_hash as Option_ThirtyTwoBytesZ . Some ).some .hexEncodedString(),
116117 " unix_timestamp" to (System .currentTimeMillis() / 1000 ).toInt(),
117118 " state" to " failed"
118119 ))
119120
120- return LdkEventEmitter .send(EventTypes .channel_manager_payment_failed, body)
121+ LdkEventEmitter .send(EventTypes .channel_manager_payment_failed, body)
121122 }
122123
123124 (event as ? Event .PaymentForwarded )?.let { paymentForwarded ->
@@ -127,7 +128,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
127128 (event as ? Event .PendingHTLCsForwardable )?.let { pendingHTLCsForwardable ->
128129 val body = Arguments .createMap()
129130 body.putInt(" time_forwardable" , pendingHTLCsForwardable.time_forwardable.toInt())
130- return LdkEventEmitter .send(EventTypes .channel_manager_pending_htlcs_forwardable, body)
131+ LdkEventEmitter .send(EventTypes .channel_manager_pending_htlcs_forwardable, body)
131132 }
132133
133134 (event as ? Event .SpendableOutputs )?.let { spendableOutputs ->
@@ -137,7 +138,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
137138 outputs.pushHexString(it.write())
138139 }
139140 body.putArray(" outputsSerialized" , outputs)
140- return LdkEventEmitter .send(EventTypes .channel_manager_spendable_outputs, body)
141+ LdkEventEmitter .send(EventTypes .channel_manager_spendable_outputs, body)
141142 }
142143
143144 (event as ? Event .ChannelClosed )?.let { channelClosed ->
@@ -170,14 +171,14 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
170171
171172 println (" Channel closed: ${channelClosed.channel_id._a .hexEncodedString()} " )
172173
173- return LdkEventEmitter .send(EventTypes .channel_manager_channel_closed, body)
174+ LdkEventEmitter .send(EventTypes .channel_manager_channel_closed, body)
174175 }
175176
176177 (event as ? Event .DiscardFunding )?.let { discardFunding ->
177178 val body = Arguments .createMap()
178179 body.putHexString(" channel_id" , discardFunding.channel_id._a )
179- body.putHexString(" tx" , discardFunding.transaction )
180- return LdkEventEmitter .send(EventTypes .channel_manager_discard_funding, body)
180+ body.putHexString(" tx" , discardFunding.channel_id. _a )
181+ LdkEventEmitter .send(EventTypes .channel_manager_discard_funding, body)
181182 }
182183
183184 (event as ? Event .PaymentClaimed )?.let { paymentClaimed ->
@@ -195,7 +196,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
195196 body.putString(" state" , " successful" )
196197
197198 persistPaymentClaimed(body)
198- return LdkEventEmitter .send(EventTypes .channel_manager_payment_claimed, body)
199+ LdkEventEmitter .send(EventTypes .channel_manager_payment_claimed, body)
199200 }
200201
201202 (event as ? Event .ChannelReady )?.let { channelReady ->
@@ -212,9 +213,11 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
212213 body.putString(" commitment_tx" , channelClose.commitment_tx.hexEncodedString())
213214 body.putInt(" commitment_tx_fee" , channelClose.commitment_tx_fee_satoshis.toInt())
214215 body.putInt(" pending_htlcs_count" , channelClose.pending_htlcs.size)
215- return LdkEventEmitter .send(EventTypes .lsp_log, body)
216+ LdkEventEmitter .send(EventTypes .lsp_log, body)
216217 }
217218 }
219+
220+ return Result_NoneReplayEventZ .ok()
218221 }
219222
220223 override fun persist_manager (channel_manager_bytes : ByteArray? ) {
0 commit comments