X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FEvent.java;h=b519a856c60ff092d818774107a56d11604c846c;hb=b6cc0960eaee5a5bbc7fde79a56152d6dcd649d8;hp=abc24cecb67d30afd7de75a275f0ebed81e4fa28;hpb=276893d3b8bd3fcb2bb10e3cab73a69d34831909;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Event.java b/src/main/java/org/ldk/structs/Event.java index abc24cec..b519a856 100644 --- a/src/main/java/org/ldk/structs/Event.java +++ b/src/main/java/org/ldk/structs/Event.java @@ -5,6 +5,14 @@ import org.ldk.enums.*; 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); } @@ -18,9 +26,6 @@ public class Event extends CommonBase { 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); } @@ -52,27 +57,19 @@ public class Event extends CommonBase { 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); - funding_txo_hu_conv.ptrs_to.add(this); - 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_preimage; public final byte[] payment_secret; public final long amt; + public final long user_payment_id; private PaymentReceived(long ptr, bindings.LDKEvent.PaymentReceived obj) { super(null, ptr); this.payment_hash = obj.payment_hash; + this.payment_preimage = obj.payment_preimage; this.payment_secret = obj.payment_secret; this.amt = obj.amt; + this.user_payment_id = obj.user_payment_id; } } public final static class PaymentSent extends Event { @@ -113,4 +110,22 @@ public class Event extends CommonBase { 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; + } + }