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.FundingBroadcastSafe.class) {
30                         return new FundingBroadcastSafe(ptr, (bindings.LDKEvent.FundingBroadcastSafe)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
33                         return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
34                 }
35                 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
36                         return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
37                 }
38                 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
39                         return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
40                 }
41                 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
42                         return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
43                 }
44                 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
45                         return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
46                 }
47                 assert false; return null; // Unreachable without extending the (internal) bindings interface
48         }
49
50         public final static class FundingGenerationReady extends Event {
51                 public final byte[] temporary_channel_id;
52                 public final long channel_value_satoshis;
53                 public final byte[] output_script;
54                 public final long user_channel_id;
55                 private FundingGenerationReady(long ptr, bindings.LDKEvent.FundingGenerationReady obj) {
56                         super(null, ptr);
57                         this.temporary_channel_id = obj.temporary_channel_id;
58                         this.channel_value_satoshis = obj.channel_value_satoshis;
59                         this.output_script = obj.output_script;
60                         this.user_channel_id = obj.user_channel_id;
61                 }
62         }
63         public final static class FundingBroadcastSafe extends Event {
64                 public final OutPoint funding_txo;
65                 public final long user_channel_id;
66                 private FundingBroadcastSafe(long ptr, bindings.LDKEvent.FundingBroadcastSafe obj) {
67                         super(null, ptr);
68                         long funding_txo = obj.funding_txo;
69                         OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo);
70                         funding_txo_hu_conv.ptrs_to.add(this);
71                         this.funding_txo = funding_txo_hu_conv;
72                         this.user_channel_id = obj.user_channel_id;
73                 }
74         }
75         public final static class PaymentReceived extends Event {
76                 public final byte[] payment_hash;
77                 public final byte[] payment_secret;
78                 public final long amt;
79                 private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) {
80                         super(null, ptr);
81                         this.payment_hash = obj.payment_hash;
82                         this.payment_secret = obj.payment_secret;
83                         this.amt = obj.amt;
84                 }
85         }
86         public final static class PaymentSent extends Event {
87                 public final byte[] payment_preimage;
88                 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
89                         super(null, ptr);
90                         this.payment_preimage = obj.payment_preimage;
91                 }
92         }
93         public final static class PaymentFailed extends Event {
94                 public final byte[] payment_hash;
95                 public final boolean rejected_by_dest;
96                 private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) {
97                         super(null, ptr);
98                         this.payment_hash = obj.payment_hash;
99                         this.rejected_by_dest = obj.rejected_by_dest;
100                 }
101         }
102         public final static class PendingHTLCsForwardable extends Event {
103                 public final long time_forwardable;
104                 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
105                         super(null, ptr);
106                         this.time_forwardable = obj.time_forwardable;
107                 }
108         }
109         public final static class SpendableOutputs extends Event {
110                 public final SpendableOutputDescriptor[] outputs;
111                 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
112                         super(null, ptr);
113                         long[] outputs = obj.outputs;
114                         SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs.length];
115                         for (int b = 0; b < outputs.length; b++) {
116                                 long outputs_conv_27 = outputs[b];
117                                 SpendableOutputDescriptor outputs_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
118                                 outputs_conv_27_hu_conv.ptrs_to.add(this);
119                                 outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
120                         }
121                         this.outputs = outputs_conv_27_arr;
122                 }
123         }
124         /**
125          * Creates a copy of the Event
126          */
127         public Event clone() {
128                 long ret = bindings.Event_clone(this.ptr);
129                 Event ret_hu_conv = Event.constr_from_ptr(ret);
130                 ret_hu_conv.ptrs_to.add(this);
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Serialize the Event object into a byte array which can be read by Event_read
136          */
137         public byte[] write() {
138                 byte[] ret = bindings.Event_write(this.ptr);
139                 return ret;
140         }
141
142 }