import org.ldk.util.*;
import java.util.Arrays;
+
+/**
+ * An Event which you should probably take some action in response to.
+ *
+ * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
+ * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
+ * written as it makes no sense to respond to it after reconnecting to peers).
+ */
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
public class Event extends CommonBase {
private Event(Object _dummy, long ptr) { super(ptr); }
if (raw_val.getClass() == bindings.LDKEvent.FundingGenerationReady.class) {
return new FundingGenerationReady(ptr, (bindings.LDKEvent.FundingGenerationReady)raw_val);
}
- if (raw_val.getClass() == bindings.LDKEvent.FundingBroadcastSafe.class) {
- return new FundingBroadcastSafe(ptr, (bindings.LDKEvent.FundingBroadcastSafe)raw_val);
- }
if (raw_val.getClass() == bindings.LDKEvent.PaymentReceived.class) {
return new PaymentReceived(ptr, (bindings.LDKEvent.PaymentReceived)raw_val);
}
this.user_channel_id = obj.user_channel_id;
}
}
- public final static class FundingBroadcastSafe extends Event {
- public final OutPoint funding_txo;
- public final long user_channel_id;
- private FundingBroadcastSafe(long ptr, bindings.LDKEvent.FundingBroadcastSafe obj) {
- super(null, ptr);
- long funding_txo = obj.funding_txo;
- OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo);
- this.funding_txo = funding_txo_hu_conv;
- this.user_channel_id = obj.user_channel_id;
- }
- }
public final static class PaymentReceived extends Event {
public final byte[] payment_hash;
public final byte[] payment_secret;
private SpendableOutputs(long ptr, bindings.LDKEvent.SpendableOutputs obj) {
super(null, ptr);
long[] outputs = obj.outputs;
- SpendableOutputDescriptor[] arr_conv_27_arr = new SpendableOutputDescriptor[outputs.length];
+ SpendableOutputDescriptor[] outputs_conv_27_arr = new SpendableOutputDescriptor[outputs.length];
for (int b = 0; b < outputs.length; b++) {
- long arr_conv_27 = outputs[b];
- SpendableOutputDescriptor arr_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(arr_conv_27);
- arr_conv_27_hu_conv.ptrs_to.add(this);
- arr_conv_27_arr[b] = arr_conv_27_hu_conv;
+ long outputs_conv_27 = outputs[b];
+ SpendableOutputDescriptor outputs_conv_27_hu_conv = SpendableOutputDescriptor.constr_from_ptr(outputs_conv_27);
+ outputs_conv_27_hu_conv.ptrs_to.add(this);
+ outputs_conv_27_arr[b] = outputs_conv_27_hu_conv;
}
- this.outputs = arr_conv_27_arr;
+ this.outputs = outputs_conv_27_arr;
}
}
+ /**
+ * Creates a copy of the Event
+ */
+ public Event clone() {
+ long ret = bindings.Event_clone(this.ptr);
+ Event ret_hu_conv = Event.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Serialize the Event object into a byte array which can be read by Event_read
+ */
+ public byte[] write() {
+ byte[] ret = bindings.Event_write(this.ptr);
+ return ret;
+ }
+
}