X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FCommitmentSigned.java;h=85266a6e5943ce6c55edd71590ee8849edaa0d7f;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=a29b4623976ced2947cb848dd9ee69a122cb1404;hpb=aa0e2aade37133339f4113a0cd7465b111f0a0d0;p=ldk-java diff --git a/src/main/java/org/ldk/structs/CommitmentSigned.java b/src/main/java/org/ldk/structs/CommitmentSigned.java index a29b4623..85266a6e 100644 --- a/src/main/java/org/ldk/structs/CommitmentSigned.java +++ b/src/main/java/org/ldk/structs/CommitmentSigned.java @@ -4,7 +4,12 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * A commitment_signed message to be sent or received from a peer + */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class CommitmentSigned extends CommonBase { CommitmentSigned(Object _dummy, long ptr) { super(ptr); } @@ -14,50 +19,80 @@ public class CommitmentSigned extends CommonBase { if (ptr != 0) { bindings.CommitmentSigned_free(ptr); } } - public static CommitmentSigned constructor_clone(CommitmentSigned orig) { - long ret = bindings.CommitmentSigned_clone(orig == null ? 0 : orig.ptr & ~1); - CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); - ret_hu_conv.ptrs_to.add(orig); - return ret_hu_conv; - } - + /** + * The channel ID + */ public byte[] get_channel_id() { byte[] ret = bindings.CommitmentSigned_get_channel_id(this.ptr); return ret; } + /** + * The channel ID + */ public void set_channel_id(byte[] val) { bindings.CommitmentSigned_set_channel_id(this.ptr, val); } + /** + * A signature on the commitment transaction + */ public byte[] get_signature() { byte[] ret = bindings.CommitmentSigned_get_signature(this.ptr); return ret; } + /** + * A signature on the commitment transaction + */ public void set_signature(byte[] val) { bindings.CommitmentSigned_set_signature(this.ptr, val); } + /** + * Signatures on the HTLC transactions + */ public void set_htlc_signatures(byte[][] val) { bindings.CommitmentSigned_set_htlc_signatures(this.ptr, val); } - public static CommitmentSigned constructor_new(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) { + /** + * Constructs a new CommitmentSigned given each field + */ + public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) { long ret = bindings.CommitmentSigned_new(channel_id_arg, signature_arg, htlc_signatures_arg); - CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a copy of the CommitmentSigned + */ + public CommitmentSigned clone() { + long ret = bindings.CommitmentSigned_clone(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); } + ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } - public byte[] write(CommitmentSigned obj) { - byte[] ret = bindings.CommitmentSigned_write(obj == null ? 0 : obj.ptr & ~1); - this.ptrs_to.add(obj); + /** + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + */ + public byte[] write() { + byte[] ret = bindings.CommitmentSigned_write(this.ptr); return ret; } - public static CommitmentSigned constructor_read(byte[] ser) { + /** + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + */ + public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) { long ret = bindings.CommitmentSigned_read(ser); - CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }