X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FInit.java;h=fd91adc0b9a19823c8bdab978b6b469d8f2c744f;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=cadc4f31331372ce79ba138ae202d5ae9afda0b8;hpb=fed2245c60159f6c074c9ed5c0f3ce273ad9841b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Init.java b/src/main/java/org/ldk/structs/Init.java index cadc4f31..fd91adc0 100644 --- a/src/main/java/org/ldk/structs/Init.java +++ b/src/main/java/org/ldk/structs/Init.java @@ -4,7 +4,13 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + +/** + * An init message to be sent or received from a peer + */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Init extends CommonBase { Init(Object _dummy, long ptr) { super(ptr); } @@ -14,20 +20,73 @@ public class Init extends CommonBase { if (ptr != 0) { bindings.Init_free(ptr); } } + /** + * The relevant features which the sender supports + */ + public InitFeatures get_features() { + long ret = bindings.Init_get_features(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The relevant features which the sender supports + */ + public void set_features(InitFeatures val) { + bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr & ~1); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new Init given each field + */ + public static Init of(InitFeatures features_arg) { + long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr & ~1); + Reference.reachabilityFence(features_arg); + if (ret >= 0 && ret <= 4096) { return null; } + Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + long clone_ptr() { + long ret = bindings.Init_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Creates a copy of the Init + */ public Init clone() { long ret = bindings.Init_clone(this.ptr); - Init ret_hu_conv = new Init(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } + /** + * Serialize the Init object into a byte array which can be read by Init_read + */ public byte[] write() { byte[] ret = bindings.Init_write(this.ptr); + Reference.reachabilityFence(this); return ret; } - public static Result_InitDecodeErrorZ constructor_read(byte[] ser) { + /** + * Read a Init from a byte array, created by Init_write + */ + public static Result_InitDecodeErrorZ read(byte[] ser) { long ret = bindings.Init_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }