X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FClosingSigned.java;h=a67baf21b158a3f0e371d6a17d95a15060d97cbd;hb=f3e670e9341decac613d33fc52febf19cea32f20;hp=4fe37bd1a1d0ad5f9175eaf81590d8377300cd50;hpb=17113550a5fefab21f39f27fbfe02646b8db53ae;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ClosingSigned.java b/src/main/java/org/ldk/structs/ClosingSigned.java index 4fe37bd1..a67baf21 100644 --- a/src/main/java/org/ldk/structs/ClosingSigned.java +++ b/src/main/java/org/ldk/structs/ClosingSigned.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; /** @@ -30,7 +31,7 @@ public class ClosingSigned extends CommonBase { * The channel ID */ public void set_channel_id(byte[] val) { - bindings.ClosingSigned_set_channel_id(this.ptr, val); + bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32)); } /** @@ -60,25 +61,57 @@ public class ClosingSigned extends CommonBase { * A signature on the closing transaction */ public void set_signature(byte[] val) { - bindings.ClosingSigned_set_signature(this.ptr, val); + bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64)); + } + + /** + * 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; + } + + /** + * 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); } /** * Constructs a new ClosingSigned given each field */ - public static ClosingSigned constructor_new(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg) { - long ret = bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg); - ClosingSigned ret_hu_conv = new ClosingSigned(null, ret); + public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, ClosingSignedFeeRange fee_range_arg) { + long ret = bindings.ClosingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), 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; } + long clone_ptr() { + long ret = bindings.ClosingSigned_clone_ptr(this.ptr); + return ret; + } + /** * Creates a copy of the ClosingSigned */ public ClosingSigned clone() { long ret = bindings.ClosingSigned_clone(this.ptr); - ClosingSigned ret_hu_conv = new ClosingSigned(null, ret); + 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; } @@ -94,8 +127,9 @@ public class ClosingSigned extends CommonBase { /** * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ - public static Result_ClosingSignedDecodeErrorZ constructor_read(byte[] ser) { + 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; }