Update auto-generated bindings
[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
9 /**
10  * An Event which you should probably take some action in response to.
11  * 
12  * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
13  * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
14  * written as it makes no sense to respond to it after reconnecting to peers).
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Event extends CommonBase {
18         private Event(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.Event_free(ptr); }
23         }
24         static Event constr_from_ptr(long ptr) {
25                 bindings.LDKEvent raw_val = bindings.LDKEvent_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) {
27                         return new FundingGenerationReady(ptr, (bindings.LDKEvent.FundingGenerationReady)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
30                         return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
33                         return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
36                         return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
39                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
40                 }
41                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
42                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
43                 }
44                 assert false; return null; // Unreachable without extending the (internal) bindings interface
45         }
46
47         public final static class FundingGenerationReady extends Event {
48                 public final byte[] temporary_channel_id;
49                 public final long channel_value_satoshis;
50                 public final byte[] output_script;
51                 public final long user_channel_id;
52                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
53                         super(null, ptr);
54                         this.temporary_channel_id = obj.temporary_channel_id;
55                         this.channel_value_satoshis = obj.channel_value_satoshis;
56                         this.output_script = obj.output_script;
57                         this.user_channel_id = obj.user_channel_id;
58                 }
59         }
60         public final static class PaymentReceived extends Event {
61                 public final byte[] payment_hash;
62                 public final byte[] payment_secret;
63                 public final long amt;
64                 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
65                         super(null, ptr);
66                         this.payment_hash = obj.payment_hash;
67                         this.payment_secret = obj.payment_secret;
68                         this.amt = obj.amt;
69                 }
70         }
71         public final static class PaymentSent extends Event {
72                 public final byte[] payment_preimage;
73                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
74                         super(null, ptr);
75                         this.payment_preimage = obj.payment_preimage;
76                 }
77         }
78         public final static class PaymentFailed extends Event {
79                 public final byte[] payment_hash;
80                 public final boolean rejected_by_dest;
81                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
82                         super(null, ptr);
83                         this.payment_hash = obj.payment_hash;
84                         this.rejected_by_dest = obj.rejected_by_dest;
85                 }
86         }
87         public final static class PendingHTLCsForwardable extends Event {
88                 public final long time_forwardable;
89                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
90                         super(null, ptr);
91                         this.time_forwardable = obj.time_forwardable;
92                 }
93         }
94         public final static class SpendableOutputs extends Event {
95                 public final SpendableOutputDescriptor[] outputs;
96                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
97                         super(null, ptr);
98                         long[] outputs = obj.outputs;
99                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs.length];
100                         for (int b = 0; b < outputs.length; b++) {
101                                 long outputs_conv_27 = outputs[b];
102                                 SpendableOutputDescriptor outputs_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
103                                 outputs_conv_27_hu_conv.ptrs_to.add(this);
104                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
105                         }
106                         this.outputs = outputs_conv_27_arr;
107                 }
108         }
109         /**
110          * Creates a copy of the Event
111          */
112         public Event clone() {
113                 long ret = bindings.Event_clone(this.ptr);
114                 Event ret_hu_conv = Event.constr_from_ptr(ret);
115                 ret_hu_conv.ptrs_to.add(this);
116                 return ret_hu_conv;
117         }
118
119         /**
120          * Serialize the Event object into a byte array which can be read by Event_read
121          */
122         public byte[] write() {
123                 byte[] ret = bindings.Event_write(this.ptr);
124                 return ret;
125         }
126
127 }