]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/Event.java
Fix race in tests
[ldk-java] / src / main / java / org / ldk / structs / Event.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Event extends CommonBase {
10         private Event(Object _dummy, long ptr) { super(ptr); }
11         @Override @SuppressWarnings("deprecation")
12         protected void finalize() throws Throwable {
13                 super.finalize();
14                 if (ptr != 0) { bindings.Event_free(ptr); }
15         }
16         static Event constr_from_ptr(long ptr) {
17                 bindings.LDKEvent raw_val = bindings.LDKEvent_ref_from_ptr(ptr);
18                 if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) {
19                         return new FundingGenerationReady(ptr, (bindings.LDKEvent.FundingGenerationReady)raw_val);
20                 }
21                 if (raw_val.getClass() == bindings.LDKEvent.FundingBroadcastSafe.class) {
22                         return new FundingBroadcastSafe(ptr, (bindings.LDKEvent.FundingBroadcastSafe)raw_val);
23                 }
24                 if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
25                         return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
28                         return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
31                         return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
32                 }
33                 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
34                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
35                 }
36                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
37                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
38                 }
39                 assert false; return null; // Unreachable without extending the (internal) bindings interface
40         }
41
42         public final static class FundingGenerationReady extends Event {
43                 public final byte[] temporary_channel_id;
44                 public final long channel_value_satoshis;
45                 public final byte[] output_script;
46                 public final long user_channel_id;
47                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
48                         super(null, ptr);
49                         this.temporary_channel_id = obj.temporary_channel_id;
50                         this.channel_value_satoshis = obj.channel_value_satoshis;
51                         this.output_script = obj.output_script;
52                         this.user_channel_id = obj.user_channel_id;
53                 }
54         }
55         public final static class FundingBroadcastSafe extends Event {
56                 public final OutPoint funding_txo;
57                 public final long user_channel_id;
58                 private FundingBroadcastSafe(long ptr, bindings.LDKEvent.FundingBroadcastSafe obj) {
59                         super(null, ptr);
60                         long funding_txo = obj.funding_txo;
61                         OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo);
62                         this.funding_txo = funding_txo_hu_conv;
63                         this.user_channel_id = obj.user_channel_id;
64                 }
65         }
66         public final static class PaymentReceived extends Event {
67                 public final byte[] payment_hash;
68                 public final byte[] payment_secret;
69                 public final long amt;
70                 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
71                         super(null, ptr);
72                         this.payment_hash = obj.payment_hash;
73                         this.payment_secret = obj.payment_secret;
74                         this.amt = obj.amt;
75                 }
76         }
77         public final static class PaymentSent extends Event {
78                 public final byte[] payment_preimage;
79                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
80                         super(null, ptr);
81                         this.payment_preimage = obj.payment_preimage;
82                 }
83         }
84         public final static class PaymentFailed extends Event {
85                 public final byte[] payment_hash;
86                 public final boolean rejected_by_dest;
87                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
88                         super(null, ptr);
89                         this.payment_hash = obj.payment_hash;
90                         this.rejected_by_dest = obj.rejected_by_dest;
91                 }
92         }
93         public final static class PendingHTLCsForwardable extends Event {
94                 public final long time_forwardable;
95                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
96                         super(null, ptr);
97                         this.time_forwardable = obj.time_forwardable;
98                 }
99         }
100         public final static class SpendableOutputs extends Event {
101                 public final SpendableOutputDescriptor[] outputs;
102                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
103                         super(null, ptr);
104                         long[] outputs = obj.outputs;
105                         SpendableOutputDescriptor[] arr_conv_27_arr = new SpendableOutputDescriptor[outputs.length];
106                         for (int b = 0; b < outputs.length; b++) {
107                                 long arr_conv_27 = outputs[b];
108                                 SpendableOutputDescriptor arr_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(arr_conv_27);
109                                 arr_conv_27_hu_conv.ptrs_to.add(this);
110                                 arr_conv_27_arr[b] = arr_conv_27_hu_conv;
111                         }
112                         this.outputs = arr_conv_27_arr;
113                 }
114         }
115 }