Merge pull request #120 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / ChannelManager.java
index fe4311f1c388a6037381a8dd79f7c351fed3b677..75a26751229229be7d9e47a91a9c70a8fa79755e 100644 (file)
@@ -78,26 +78,26 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(params);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
-               ret_hu_conv.ptrs_to.add(fee_est);
-               ret_hu_conv.ptrs_to.add(chain_monitor);
-               ret_hu_conv.ptrs_to.add(tx_broadcaster);
-               ret_hu_conv.ptrs_to.add(logger);
-               ret_hu_conv.ptrs_to.add(keys_manager);
-               ret_hu_conv.ptrs_to.add(config);
-               ret_hu_conv.ptrs_to.add(params);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_est); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(chain_monitor); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(tx_broadcaster); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys_manager); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(config); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(params); };
                return ret_hu_conv;
        }
 
        /**
-        * Gets the current configuration applied to all new channels,  as
+        * Gets the current configuration applied to all new channels.
         */
        public UserConfig get_current_default_configuration() {
                long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -141,7 +141,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(override_config);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
-               this.ptrs_to.add(override_config);
+               if (this != null) { this.ptrs_to.add(override_config); };
                return ret_hu_conv;
        }
 
@@ -157,7 +157,7 @@ public class ChannelManager extends CommonBase {
                for (int q = 0; q < ret_conv_16_len; q++) {
                        long ret_conv_16 = ret[q];
                        org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
-                       ret_conv_16_hu_conv.ptrs_to.add(this);
+                       if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
                return ret_conv_16_arr;
@@ -181,7 +181,7 @@ public class ChannelManager extends CommonBase {
                for (int q = 0; q < ret_conv_16_len; q++) {
                        long ret_conv_16 = ret[q];
                        org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
-                       ret_conv_16_hu_conv.ptrs_to.add(this);
+                       if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
                return ret_conv_16_arr;
@@ -320,12 +320,12 @@ public class ChannelManager extends CommonBase {
         * PaymentSendFailure for more info.
         * 
         * In general, a path may raise:
-        * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
+        * [`APIError::RouteError`] when an invalid route or forwarding parameter (cltv_delta, fee,
         * node public key) is specified.
-        * APIError::ChannelUnavailable if the next-hop channel is not available for updates
+        * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
         * (including due to previous monitor update failure or new permanent monitor update
         * failure).
-        * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
+        * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
         * relevant updates.
         * 
         * Note that depending on the type of the PaymentSendFailure the HTLC may have been
@@ -351,7 +351,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(payment_secret);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
-               this.ptrs_to.add(route);
+               if (this != null) { this.ptrs_to.add(route); };
                return ret_hu_conv;
        }
 
@@ -374,7 +374,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(payment_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
-               this.ptrs_to.add(route);
+               if (this != null) { this.ptrs_to.add(route); };
                return ret_hu_conv;
        }
 
@@ -425,7 +425,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(payment_preimage);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
-               this.ptrs_to.add(route);
+               if (this != null) { this.ptrs_to.add(route); };
                return ret_hu_conv;
        }
 
@@ -440,7 +440,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(hops);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
-               for (RouteHop hops_conv_10: hops) { this.ptrs_to.add(hops_conv_10); };
+               for (RouteHop hops_conv_10: hops) { if (this != null) { this.ptrs_to.add(hops_conv_10); }; };
                return ret_hu_conv;
        }
 
@@ -487,34 +487,6 @@ public class ChannelManager extends CommonBase {
                return ret_hu_conv;
        }
 
-       /**
-        * Regenerates channel_announcements and generates a signed node_announcement from the given
-        * arguments, providing them in corresponding events via
-        * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
-        * on-chain. This effectively re-broadcasts all channel announcements and sends our node
-        * announcement to ensure that the lightning P2P network is aware of the channels we have and
-        * our network addresses.
-        * 
-        * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
-        * node to humans. They carry no in-protocol meaning.
-        * 
-        * `addresses` represent the set (possibly empty) of socket addresses on which this node
-        * accepts incoming connections. These will be included in the node_announcement, publicly
-        * tying these addresses together and to this node. If you wish to preserve user privacy,
-        * addresses should likely contain only Tor Onion addresses.
-        * 
-        * Panics if `addresses` is absurdly large (more than 100).
-        * 
-        * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
-        */
-       public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) {
-               bindings.ChannelManager_broadcast_node_announcement(this.ptr, InternalUtils.check_arr_len(rgb, 3), InternalUtils.check_arr_len(alias, 32), addresses != null ? Arrays.stream(addresses).mapToLong(addresses_conv_12 -> addresses_conv_12.ptr).toArray() : null);
-               Reference.reachabilityFence(this);
-               Reference.reachabilityFence(rgb);
-               Reference.reachabilityFence(alias);
-               Reference.reachabilityFence(addresses);
-       }
-
        /**
         * Atomically updates the [`ChannelConfig`] for the given channels.
         * 
@@ -547,7 +519,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(config);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
-               this.ptrs_to.add(config);
+               if (this != null) { this.ptrs_to.add(config); };
                return ret_hu_conv;
        }
 
@@ -872,7 +844,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -885,7 +857,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -898,7 +870,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                EventsProvider ret_hu_conv = new EventsProvider(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -911,7 +883,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                Listen ret_hu_conv = new Listen(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -924,7 +896,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                Confirm ret_hu_conv = new Confirm(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -953,6 +925,20 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
        }
 
+       /**
+        * Gets a [`Future`] that completes when a persistable update is available. Note that
+        * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
+        * should instead register actions to be taken later.
+        */
+       public Future get_persistable_update_future() {
+               long ret = bindings.ChannelManager_get_persistable_update_future(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
        /**
         * Gets the latest best block which was connected either via the [`chain::Listen`] or
         * [`chain::Confirm`] interfaces.
@@ -962,7 +948,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -975,7 +961,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -997,7 +983,7 @@ public class ChannelManager extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                Payer ret_hu_conv = new Payer(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }