X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FClosingSigned.java;h=a7fb48ba6a0e87dd0b6ab963efa6a6edb6c7cf6d;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=4d30d0b20795b21faa7a0c4e4ba547e21b588d6a;hpb=2ed9081562d00a8645604b07629e963231d49e0f;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ClosingSigned.java b/src/main/java/org/ldk/structs/ClosingSigned.java index 4d30d0b2..a7fb48ba 100644 --- a/src/main/java/org/ldk/structs/ClosingSigned.java +++ b/src/main/java/org/ldk/structs/ClosingSigned.java @@ -2,59 +2,131 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * A closing_signed message to be sent or received from a peer + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ClosingSigned extends CommonBase { ClosingSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ClosingSigned_free(ptr); super.finalize(); + super.finalize(); + if (ptr != 0) { bindings.ClosingSigned_free(ptr); } } - public ClosingSigned(ClosingSigned orig) { - super(bindings.ClosingSigned_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + /** + * The channel ID + */ + public byte[] get_channel_id() { + byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr); + return ret; } - public byte[] get_channel_id(ClosingSigned this_ptr) { - byte[] ret = bindings.ClosingSigned_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The channel ID + */ + public void set_channel_id(byte[] val) { + bindings.ClosingSigned_set_channel_id(this.ptr, val); + } + + /** + * The proposed total fee for the closing transaction + */ + public long get_fee_satoshis() { + long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr); return ret; } - public void set_channel_id(ClosingSigned this_ptr, byte[] val) { - bindings.ClosingSigned_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The proposed total fee for the closing transaction + */ + public void set_fee_satoshis(long val) { + bindings.ClosingSigned_set_fee_satoshis(this.ptr, val); } - public long get_fee_satoshis(ClosingSigned this_ptr) { - long ret = bindings.ClosingSigned_get_fee_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * A signature on the closing transaction + */ + public byte[] get_signature() { + byte[] ret = bindings.ClosingSigned_get_signature(this.ptr); return ret; } - public void set_fee_satoshis(ClosingSigned this_ptr, long val) { - bindings.ClosingSigned_set_fee_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * A signature on the closing transaction + */ + public void set_signature(byte[] val) { + bindings.ClosingSigned_set_signature(this.ptr, val); } - public byte[] get_signature(ClosingSigned this_ptr) { - byte[] ret = bindings.ClosingSigned_get_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); - return ret; + /** + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public ClosingSignedFeeRange get_fee_range() { + long ret = bindings.ClosingSigned_get_fee_range(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSignedFeeRange(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_signature(ClosingSigned this_ptr, byte[] val) { - bindings.ClosingSigned_set_signature(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void set_fee_range(@Nullable ClosingSignedFeeRange val) { + bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr & ~1); } - public ClosingSigned(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg) { - super(bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg)); + /** + * Constructs a new ClosingSigned given each field + */ + public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, ClosingSignedFeeRange fee_range_arg) { + long ret = bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg, fee_range_arg == null ? 0 : fee_range_arg.ptr & ~1); + if (ret >= 0 && ret <= 4096) { return null; } + ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a copy of the ClosingSigned + */ + public ClosingSigned clone() { + long ret = bindings.ClosingSigned_clone(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + */ + public byte[] write() { + byte[] ret = bindings.ClosingSigned_write(this.ptr); + return ret; } - // Skipped ClosingSigned_write - public ClosingSigned(byte[] ser) { - super(bindings.ClosingSigned_read(ser)); + /** + * Read a ClosingSigned from a byte array, created by ClosingSigned_write + */ + public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) { + long ret = bindings.ClosingSigned_read(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; } }