X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelManager.java;h=ea569eb0f3c0a3c479d4335bfeb608abc5c61b2c;hb=ff3dacec3be60f870d81f6df11bd9fff92aa6047;hp=ab642c44f31f5f6c0821b8eff6d7acd5a2a89120;hpb=1854b5cebef22ace9e9e4dd191f609818df9ce08;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index ab642c44..ea569eb0 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -151,8 +151,9 @@ public class ChannelManager extends CommonBase { public ChannelDetails[] list_channels() { long[] ret = bindings.ChannelManager_list_channels(this.ptr); Reference.reachabilityFence(this); - ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length]; - for (int q = 0; q < ret.length; q++) { + int ret_conv_16_len = ret.length; + ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len]; + for (int q = 0; q < ret_conv_16_len; q++) { long ret_conv_16 = ret[q]; ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16); } ret_conv_16_hu_conv.ptrs_to.add(this); @@ -172,8 +173,9 @@ public class ChannelManager extends CommonBase { public ChannelDetails[] list_usable_channels() { long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr); Reference.reachabilityFence(this); - ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length]; - for (int q = 0; q < ret.length; q++) { + int ret_conv_16_len = ret.length; + ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len]; + for (int q = 0; q < ret_conv_16_len; q++) { long ret_conv_16 = ret[q]; ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16); } ret_conv_16_hu_conv.ptrs_to.add(this); @@ -529,6 +531,29 @@ public class ChannelManager extends CommonBase { return ret; } + /** + * Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been + * triggered. + * + * The `temporary_channel_id` parameter indicates which inbound channel should be accepted. + * + * For inbound channels, the `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel` call. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + */ + public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, long user_channel_id) { + long ret = bindings.ChannelManager_accept_inbound_channel(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), user_channel_id); + Reference.reachabilityFence(this); + Reference.reachabilityFence(temporary_channel_id); + Reference.reachabilityFence(user_channel_id); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Gets a payment secret and payment hash for use in an invoice given to a third party wishing * to pay us. @@ -571,6 +596,8 @@ public class ChannelManager extends CommonBase { * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share * serialized state with LDK node(s) running 0.0.103 and earlier. * + * May panic if `invoice_expiry_delta_secs` is greater than one year. + * * # Note * This method is deprecated and will be removed soon. * @@ -615,8 +642,6 @@ public class ChannelManager extends CommonBase { * If you need exact expiry semantics, you should enforce them upon receipt of * [`PaymentReceived`]. * - * May panic if `invoice_expiry_delta_secs` is greater than one year. - * * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry` * set to at least [`MIN_FINAL_CLTV_EXPIRY`]. * @@ -648,6 +673,8 @@ public class ChannelManager extends CommonBase { * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share * serialized state with LDK node(s) running 0.0.103 and earlier. * + * May panic if `invoice_expiry_delta_secs` is greater than one year. + * * # Note * This method is deprecated and will be removed soon. * @@ -680,6 +707,32 @@ public class ChannelManager extends CommonBase { return ret_hu_conv; } + /** + * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids + * are used when constructing the phantom invoice's route hints. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + */ + public long get_phantom_scid() { + long ret = bindings.ChannelManager_get_phantom_scid(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Gets route hints for use in receiving [phantom node payments]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + */ + public PhantomRouteHints get_phantom_route_hints() { + long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PhantomRouteHints(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + /** * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is