+ super.finalize();
+ if (ptr != 0) { bindings.ChannelManager_free(ptr); }
+ }
+
+ /**
+ * Constructs a new ChannelManager to hold several channels and route between them.
+ *
+ * This is the main \"logic hub\" for all channel-related actions, and implements
+ * ChannelMessageHandler.
+ *
+ * Non-proportional fees are fixed according to our risk using the provided fee estimator.
+ *
+ * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
+ *
+ * Users need to notify the new ChannelManager when a new block is connected or
+ * disconnected using its `block_connected` and `block_disconnected` methods, starting
+ * from after `params.latest_hash`.
+ */
+ public static ChannelManager constructor_new(FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, LDKNetwork params_network_arg, byte[] params_latest_hash_arg, long params_latest_height_arg) {
+ 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, bindings.ChainParameters_new(params_network_arg, params_latest_hash_arg, params_latest_height_arg));
+ ChannelManager ret_hu_conv = new 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);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates a new outbound channel to the given remote node and with the given value.
+ *
+ * user_id will be provided back as user_channel_id in FundingGenerationReady and
+ * FundingBroadcastSafe events to allow tracking of which events correspond with which
+ * create_channel call. Note that user_channel_id defaults to 0 for inbound channels, so you
+ * may wish to avoid using 0 for user_id here.
+ *
+ * If successful, will generate a SendOpenChannel message event, so you should probably poll
+ * PeerManager::process_events afterwards.
+ *
+ * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
+ * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
+ */
+ public Result_NoneAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_id, UserConfig override_config) {
+ long ret = bindings.ChannelManager_create_channel(this.ptr, their_network_key, channel_value_satoshis, push_msat, user_id, override_config == null ? 0 : override_config.ptr & ~1);
+ Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(override_config);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Gets the list of open channels, in random order. See ChannelDetail field documentation for
+ * more information.
+ */
+ public ChannelDetails[] list_channels() {
+ long[] ret = bindings.ChannelManager_list_channels(this.ptr);
+ ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
+ for (int q = 0; q < ret.length; q++) {
+ long ret_conv_16 = ret[q];
+ ChannelDetails ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16);
+ ret_conv_16_hu_conv.ptrs_to.add(this);
+ ret_conv_16_arr[q] = ret_conv_16_hu_conv;
+ }
+ return ret_conv_16_arr;