X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FDirectionalChannelInfo.java;h=55da78714859010785cdbbe555e387c82ab8ec4f;hb=f3e670e9341decac613d33fc52febf19cea32f20;hp=a1845552c9807b9dd0786b906a23803ccbc8e665;hpb=ad15b3a4dbf3fbc7f08ef22d656bae79e8182008;p=ldk-java diff --git a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java index a1845552..55da7871 100644 --- a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java +++ b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java @@ -2,74 +2,194 @@ 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; + +/** + * Details about one direction of a channel. Received + * within a channel update. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class DirectionalChannelInfo extends CommonBase { DirectionalChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); - bindings.DirectionalChannelInfo_free(ptr); + if (ptr != 0) { bindings.DirectionalChannelInfo_free(ptr); } } - public int get_last_update(DirectionalChannelInfo this_ptr) { - int ret = bindings.DirectionalChannelInfo_get_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. + */ + public int get_last_update() { + int ret = bindings.DirectionalChannelInfo_get_last_update(this.ptr); return ret; } - public void set_last_update(DirectionalChannelInfo this_ptr, int val) { - bindings.DirectionalChannelInfo_set_last_update(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. + */ + public void set_last_update(int val) { + bindings.DirectionalChannelInfo_set_last_update(this.ptr, val); } - public boolean get_enabled(DirectionalChannelInfo this_ptr) { - boolean ret = bindings.DirectionalChannelInfo_get_enabled(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * Whether the channel can be currently used for payments (in this one direction). + */ + public boolean get_enabled() { + boolean ret = bindings.DirectionalChannelInfo_get_enabled(this.ptr); return ret; } - public void set_enabled(DirectionalChannelInfo this_ptr, boolean val) { - bindings.DirectionalChannelInfo_set_enabled(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * Whether the channel can be currently used for payments (in this one direction). + */ + public void set_enabled(boolean val) { + bindings.DirectionalChannelInfo_set_enabled(this.ptr, val); } - public short get_cltv_expiry_delta(DirectionalChannelInfo this_ptr) { - short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The difference in CLTV values that you must have when routing through this channel. + */ + public short get_cltv_expiry_delta() { + short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this.ptr); return ret; } - public void set_cltv_expiry_delta(DirectionalChannelInfo this_ptr, short val) { - bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The difference in CLTV values that you must have when routing through this channel. + */ + public void set_cltv_expiry_delta(short val) { + bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this.ptr, val); } - public long get_htlc_minimum_msat(DirectionalChannelInfo this_ptr) { - long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The minimum value, which must be relayed to the next hop via the channel + */ + public long get_htlc_minimum_msat() { + long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this.ptr); return ret; } - public void set_htlc_minimum_msat(DirectionalChannelInfo this_ptr, long val) { - bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The minimum value, which must be relayed to the next hop via the channel + */ + public void set_htlc_minimum_msat(long val) { + bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this.ptr, val); + } + + /** + * The maximum value which may be relayed to the next hop via the channel. + */ + public Option_u64Z get_htlc_maximum_msat() { + long ret = bindings.DirectionalChannelInfo_get_htlc_maximum_msat(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The maximum value which may be relayed to the next hop via the channel. + */ + public void set_htlc_maximum_msat(Option_u64Z val) { + bindings.DirectionalChannelInfo_set_htlc_maximum_msat(this.ptr, val.ptr); + } + + /** + * Fees charged when the channel is used for routing + */ + public RoutingFees get_fees() { + long ret = bindings.DirectionalChannelInfo_get_fees(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Fees charged when the channel is used for routing + */ + public void set_fees(RoutingFees val) { + bindings.DirectionalChannelInfo_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1); } - public ChannelUpdate get_last_update_message(DirectionalChannelInfo this_ptr) { - ChannelUpdate ret = new ChannelUpdate(null, bindings.DirectionalChannelInfo_get_last_update_message(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); + /** + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public ChannelUpdate get_last_update_message() { + long ret = bindings.DirectionalChannelInfo_get_last_update_message(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void set_last_update_message(@Nullable ChannelUpdate val) { + bindings.DirectionalChannelInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr & ~1); + } + + /** + * Constructs a new DirectionalChannelInfo given each field + */ + public static DirectionalChannelInfo of(int last_update_arg, boolean enabled_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg, RoutingFees fees_arg, ChannelUpdate last_update_message_arg) { + long ret = bindings.DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg.ptr, fees_arg == null ? 0 : fees_arg.ptr & ~1, last_update_message_arg == null ? 0 : last_update_message_arg.ptr & ~1); + if (ret >= 0 && ret <= 4096) { return null; } + DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + long clone_ptr() { + long ret = bindings.DirectionalChannelInfo_clone_ptr(this.ptr); return ret; } - public void set_last_update_message(DirectionalChannelInfo this_ptr, ChannelUpdate val) { - bindings.DirectionalChannelInfo_set_last_update_message(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); - this.ptrs_to.add(val); + /** + * Creates a copy of the DirectionalChannelInfo + */ + public DirectionalChannelInfo clone() { + long ret = bindings.DirectionalChannelInfo_clone(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } + DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read + */ + public byte[] write() { + byte[] ret = bindings.DirectionalChannelInfo_write(this.ptr); + return ret; } - // Skipped DirectionalChannelInfo_write - public DirectionalChannelInfo(byte[] ser) { - super(bindings.DirectionalChannelInfo_read(ser)); + /** + * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write + */ + public static Result_DirectionalChannelInfoDecodeErrorZ read(byte[] ser) { + long ret = bindings.DirectionalChannelInfo_read(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; } }