1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
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 {
14 if (ptr != 0) { bindings.Event_free(ptr); }
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);
21 if (raw_val.getClass() == bindings.LDKEvent.FundingBroadcastSafe.class) {
22 return new FundingBroadcastSafe(ptr, (bindings.LDKEvent.FundingBroadcastSafe)raw_val);
24 if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
25 return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
27 if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) {
28 return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val);
30 if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) {
31 return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val);
33 if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) {
34 return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val);
36 if (raw_val.getClass() == bindings.LDKEvent.SpendableOutputs.class) {
37 return new SpendableOutputs(ptr, (bindings.LDKEvent.SpendableOutputs)raw_val);
39 assert false; return null; // Unreachable without extending the (internal) bindings interface
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) {
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;
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) {
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;
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) {
72 this.payment_hash = obj.payment_hash;
73 this.payment_secret = obj.payment_secret;
77 public final static class PaymentSent extends Event {
78 public final byte[] payment_preimage;
79 private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
81 this.payment_preimage = obj.payment_preimage;
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) {
89 this.payment_hash = obj.payment_hash;
90 this.rejected_by_dest = obj.rejected_by_dest;
93 public final static class PendingHTLCsForwardable extends Event {
94 public final long time_forwardable;
95 private PendingHTLCsForwardable(long ptr, bindings.LDKEvent.PendingHTLCsForwardable obj) {
97 this.time_forwardable = obj.time_forwardable;
100 public final static class SpendableOutputs extends Event {
101 public final SpendableOutputDescriptor[] outputs;
102 private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
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;
112 this.outputs = arr_conv_27_arr;