[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / ChannelManager.java
index c385abf6cbddcdf746c6c8eda266fd112432b1df..75a26751229229be7d9e47a91a9c70a8fa79755e 100644 (file)
@@ -68,7 +68,7 @@ public class ChannelManager extends CommonBase {
         * from after `params.latest_hash`.
         */
        public static ChannelManager of(FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, ChainParameters params) {
-               long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr & ~1, params == null ? 0 : params.ptr & ~1);
+               long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr, params == null ? 0 : params.ptr);
                Reference.reachabilityFence(fee_est);
                Reference.reachabilityFence(chain_monitor);
                Reference.reachabilityFence(tx_broadcaster);
@@ -78,24 +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);
+               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;
        }
 
@@ -130,7 +132,7 @@ public class ChannelManager extends CommonBase {
         * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
        public Result__u832APIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_channel_id, @Nullable UserConfig override_config) {
-               long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id, override_config == null ? 0 : override_config.ptr & ~1);
+               long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id, override_config == null ? 0 : override_config.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(their_network_key);
                Reference.reachabilityFence(channel_value_satoshis);
@@ -139,6 +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);
+               if (this != null) { this.ptrs_to.add(override_config); };
                return ret_hu_conv;
        }
 
@@ -154,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;
@@ -178,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;
@@ -246,13 +249,31 @@ public class ChannelManager extends CommonBase {
        }
 
        /**
-        * Force closes a channel, immediately broadcasting the latest local commitment transaction to
-        * the chain and rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
+        * Force closes a channel, immediately broadcasting the latest local transaction(s) and
+        * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
         * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
         * channel.
         */
-       public Result_NoneAPIErrorZ force_close_channel(byte[] channel_id, byte[] counterparty_node_id) {
-               long ret = bindings.ChannelManager_force_close_channel(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
+       public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(channel_id);
+               Reference.reachabilityFence(counterparty_node_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
+        * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
+        * `counterparty_node_id` isn't the counterparty of the corresponding channel.
+        * 
+        * You can always get the latest local transaction(s) to broadcast from
+        * [`ChannelMonitor::get_latest_holder_commitment_txn`].
+        */
+       public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(channel_id);
                Reference.reachabilityFence(counterparty_node_id);
@@ -265,8 +286,17 @@ public class ChannelManager extends CommonBase {
         * Force close all channels, immediately broadcasting the latest local commitment transaction
         * for each to the chain and rejecting new HTLCs on each.
         */
-       public void force_close_all_channels() {
-               bindings.ChannelManager_force_close_all_channels(this.ptr);
+       public void force_close_all_channels_broadcasting_latest_txn() {
+               bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
+               Reference.reachabilityFence(this);
+       }
+
+       /**
+        * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
+        * local transaction(s).
+        */
+       public void force_close_all_channels_without_broadcasting_txn() {
+               bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
                Reference.reachabilityFence(this);
        }
 
@@ -290,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
@@ -314,14 +344,14 @@ public class ChannelManager extends CommonBase {
         * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
        public Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, @Nullable byte[] payment_secret) {
-               long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
+               long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
                Reference.reachabilityFence(payment_hash);
                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;
        }
 
@@ -338,13 +368,13 @@ public class ChannelManager extends CommonBase {
         * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
         */
        public Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id) {
-               long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_id, 32));
+               long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_id, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
                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;
        }
 
@@ -389,13 +419,28 @@ public class ChannelManager extends CommonBase {
         * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
        public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_spontaneous_payment(Route route, @Nullable byte[] payment_preimage) {
-               long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_preimage, 32));
+               long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(route);
                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;
+       }
+
+       /**
+        * Send a payment that is probing the given route for liquidity. We calculate the
+        * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
+        * us to easily discern them from real payments.
+        */
+       public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_probe(RouteHop[] hops) {
+               long ret = bindings.ChannelManager_send_probe(this.ptr, hops != null ? Arrays.stream(hops).mapToLong(hops_conv_10 -> hops_conv_10 == null ? 0 : hops_conv_10.ptr).toArray() : null);
+               Reference.reachabilityFence(this);
+               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) { if (this != null) { this.ptrs_to.add(hops_conv_10); }; };
                return ret_hu_conv;
        }
 
@@ -405,6 +450,9 @@ public class ChannelManager extends CommonBase {
         * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
         * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
         * 
+        * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
+        * across the p2p network.
+        * 
         * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
         * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
         * 
@@ -420,6 +468,11 @@ public class ChannelManager extends CommonBase {
         * not currently support replacing a funding transaction on an existing channel. Instead,
         * create a new channel with a conflicting funding transaction.
         * 
+        * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
+        * the wallet software generating the funding transaction to apply anti-fee sniping as
+        * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
+        * for more details.
+        * 
         * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
         * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
         */
@@ -435,31 +488,39 @@ public class ChannelManager extends CommonBase {
        }
 
        /**
-        * 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.
+        * Atomically updates the [`ChannelConfig`] for the given channels.
         * 
-        * `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.
+        * Once the updates are applied, each eligible channel (advertised with a known short channel
+        * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
+        * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
+        * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
         * 
-        * `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.
+        * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
+        * `counterparty_node_id` is provided.
         * 
-        * Panics if `addresses` is absurdly large (more than 500).
+        * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
+        * below [`MIN_CLTV_EXPIRY_DELTA`].
         * 
-        * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
+        * If an error is returned, none of the updates should be considered applied.
+        * 
+        * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+        * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
+        * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
+        * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
+        * [`ChannelUpdate`]: msgs::ChannelUpdate
+        * [`ChannelUnavailable`]: APIError::ChannelUnavailable
+        * [`APIMisuseError`]: APIError::APIMisuseError
         */
-       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);
+       public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, ChannelConfig config) {
+               long ret = bindings.ChannelManager_update_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? Arrays.stream(channel_ids).map(channel_ids_conv_8 -> InternalUtils.check_arr_len(channel_ids_conv_8, 32)).toArray(byte[][]::new) : null, config == null ? 0 : config.ptr);
                Reference.reachabilityFence(this);
-               Reference.reachabilityFence(rgb);
-               Reference.reachabilityFence(alias);
-               Reference.reachabilityFence(addresses);
+               Reference.reachabilityFence(counterparty_node_id);
+               Reference.reachabilityFence(channel_ids);
+               Reference.reachabilityFence(config);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.add(config); };
+               return ret_hu_conv;
        }
 
        /**
@@ -481,6 +542,8 @@ public class ChannelManager extends CommonBase {
         * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
         * than a minute, informing the network that they should no longer attempt to route over
         * the channel.
+        * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs
+        * with the current `ChannelConfig`.
         * 
         * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
         * estimate fetches.
@@ -781,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;
        }
 
@@ -794,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;
        }
 
@@ -807,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;
        }
 
@@ -820,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;
        }
 
@@ -833,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;
        }
 
@@ -862,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.
@@ -871,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;
        }
 
@@ -884,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;
        }
 
@@ -906,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;
        }