X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelDetails.java;h=e56f706c552b0941bc1390877c6d3a4c5b7369a4;hp=be5614798effa6857f0204bbf7f74f7d6aef79bc;hb=ff3dacec3be60f870d81f6df11bd9fff92aa6047;hpb=1ef2dc8b8a3e0e244ad82ac08e286df489eca4b7 diff --git a/src/main/java/org/ldk/structs/ChannelDetails.java b/src/main/java/org/ldk/structs/ChannelDetails.java index be561479..e56f706c 100644 --- a/src/main/java/org/ldk/structs/ChannelDetails.java +++ b/src/main/java/org/ldk/structs/ChannelDetails.java @@ -99,15 +99,51 @@ public class ChannelDetails extends CommonBase { Reference.reachabilityFence(val); } + /** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public ChannelTypeFeatures get_channel_type() { + long ret = bindings.ChannelDetails_get_channel_type(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTypeFeatures(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void set_channel_type(@Nullable ChannelTypeFeatures val) { + bindings.ChannelDetails_set_channel_type(this.ptr, val == null ? 0 : val.ptr & ~1); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + /** * The position of the funding transaction in the chain. None if the funding transaction has * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid */ public Option_u64Z get_short_channel_id() { long ret = bindings.ChannelDetails_get_short_channel_id(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -115,6 +151,12 @@ public class ChannelDetails extends CommonBase { /** * The position of the funding transaction in the chain. None if the funding transaction has * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid */ public void set_short_channel_id(Option_u64Z val) { bindings.ChannelDetails_set_short_channel_id(this.ptr, val.ptr); @@ -122,6 +164,43 @@ public class ChannelDetails extends CommonBase { Reference.reachabilityFence(val); } + /** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ + public Option_u64Z get_inbound_scid_alias() { + long ret = bindings.ChannelDetails_get_inbound_scid_alias(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ + public void set_inbound_scid_alias(Option_u64Z val) { + bindings.ChannelDetails_set_inbound_scid_alias(this.ptr, val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + /** * The value, in satoshis, of this channel as appears in the funding output */ @@ -155,7 +234,7 @@ public class ChannelDetails extends CommonBase { long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -318,7 +397,7 @@ public class ChannelDetails extends CommonBase { long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret); + org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -355,7 +434,7 @@ public class ChannelDetails extends CommonBase { long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -468,12 +547,14 @@ public class ChannelDetails extends CommonBase { /** * Constructs a new ChannelDetails given each field */ - public static ChannelDetails of(byte[] channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, Option_u64Z short_channel_id_arg, long channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, long user_channel_id_arg, long balance_msat_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) { - long ret = bindings.ChannelDetails_new(InternalUtils.check_arr_len(channel_id_arg, 32), counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, short_channel_id_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); + public static ChannelDetails of(byte[] channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, ChannelTypeFeatures channel_type_arg, Option_u64Z short_channel_id_arg, Option_u64Z inbound_scid_alias_arg, long channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, long user_channel_id_arg, long balance_msat_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) { + long ret = bindings.ChannelDetails_new(InternalUtils.check_arr_len(channel_id_arg, 32), counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, channel_type_arg == null ? 0 : channel_type_arg.ptr & ~1, short_channel_id_arg.ptr, inbound_scid_alias_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); Reference.reachabilityFence(channel_id_arg); Reference.reachabilityFence(counterparty_arg); Reference.reachabilityFence(funding_txo_arg); + Reference.reachabilityFence(channel_type_arg); Reference.reachabilityFence(short_channel_id_arg); + Reference.reachabilityFence(inbound_scid_alias_arg); Reference.reachabilityFence(channel_value_satoshis_arg); Reference.reachabilityFence(unspendable_punishment_reserve_arg); Reference.reachabilityFence(user_channel_id_arg); @@ -510,6 +591,23 @@ public class ChannelDetails extends CommonBase { return ret_hu_conv; } + /** + * Gets the current SCID which should be used to identify this channel for inbound payments. + * This should be used for providing invoice hints or in any other context where our + * counterparty will forward a payment to us. + * + * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the + * [`ChannelDetails::short_channel_id`]. See those for more information. + */ + public Option_u64Z get_inbound_payment_scid() { + long ret = bindings.ChannelDetails_get_inbound_payment_scid(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + /** * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read */