@@ -164,7 +164,19 @@ public ChannelDetails[] list_usable_channels() {
164164 * will be accepted on the given channel, and after additional timeout/the closing of all
165165 * pending HTLCs, the channel will be closed on chain.
166166 *
167+ * If we are the channel initiator, we will pay between our [`Background`] and
168+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
169+ * estimate.
170+ * If our counterparty is the channel initiator, we will require a channel closing
171+ * transaction feerate of at least our [`Background`] feerate or the feerate which
172+ * would appear on a force-closure transaction, whichever is lower. We will allow our
173+ * counterparty to pay as much fee as they'd like, however.
174+ *
167175 * May generate a SendShutdown message event on success, which should be relayed.
176+ *
177+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
178+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
179+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
168180 */
169181 public Result_NoneAPIErrorZ close_channel (byte [] channel_id ) {
170182 long ret = bindings .ChannelManager_close_channel (this .ptr , channel_id );
@@ -173,6 +185,34 @@ public Result_NoneAPIErrorZ close_channel(byte[] channel_id) {
173185 return ret_hu_conv ;
174186 }
175187
188+ /**
189+ * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
190+ * will be accepted on the given channel, and after additional timeout/the closing of all
191+ * pending HTLCs, the channel will be closed on chain.
192+ *
193+ * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
194+ * the channel being closed or not:
195+ * If we are the channel initiator, we will pay at least this feerate on the closing
196+ * transaction. The upper-bound is set by
197+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
198+ * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
199+ * If our counterparty is the channel initiator, we will refuse to accept a channel closure
200+ * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
201+ * will appear on a force-closure transaction, whichever is lower).
202+ *
203+ * May generate a SendShutdown message event on success, which should be relayed.
204+ *
205+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
206+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
207+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
208+ */
209+ public Result_NoneAPIErrorZ close_channel_with_target_feerate (byte [] channel_id , int target_feerate_sats_per_1000_weight ) {
210+ long ret = bindings .ChannelManager_close_channel_with_target_feerate (this .ptr , channel_id , target_feerate_sats_per_1000_weight );
211+ if (ret < 1024 ) { return null ; }
212+ Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ .constr_from_ptr (ret );
213+ return ret_hu_conv ;
214+ }
215+
176216 /**
177217 * Force closes a channel, immediately broadcasting the latest local commitment transaction to
178218 * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
@@ -243,6 +283,32 @@ public Result_NonePaymentSendFailureZ send_payment(Route route, byte[] payment_h
243283 return ret_hu_conv ;
244284 }
245285
286+ /**
287+ * Send a spontaneous payment, which is a payment that does not require the recipient to have
288+ * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
289+ * the preimage, it must be a cryptographically secure random value that no intermediate node
290+ * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
291+ * never reach the recipient.
292+ *
293+ * See [`send_payment`] documentation for more details on the return value of this function.
294+ *
295+ * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
296+ * [`send_payment`] for more information about the risks of duplicate preimage usage.
297+ *
298+ * Note that `route` must have exactly one path.
299+ *
300+ * [`send_payment`]: Self::send_payment
301+ *
302+ * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
303+ */
304+ public Result_PaymentHashPaymentSendFailureZ send_spontaneous_payment (Route route , @ Nullable byte [] payment_preimage ) {
305+ long ret = bindings .ChannelManager_send_spontaneous_payment (this .ptr , route == null ? 0 : route .ptr & ~1 , payment_preimage );
306+ if (ret < 1024 ) { return null ; }
307+ Result_PaymentHashPaymentSendFailureZ ret_hu_conv = Result_PaymentHashPaymentSendFailureZ .constr_from_ptr (ret );
308+ this .ptrs_to .add (route );
309+ return ret_hu_conv ;
310+ }
311+
246312 /**
247313 * Call this upon creation of a funding transaction for the given channel.
248314 *
@@ -308,13 +374,16 @@ public void process_pending_htlc_forwards() {
308374 }
309375
310376 /**
311- * If a peer is disconnected we mark any channels with that peer as 'disabled'.
312- * After some time, if channels are still disabled we need to broadcast a ChannelUpdate
313- * to inform the network about the uselessness of these channels.
377+ * Performs actions which should happen on startup and roughly once per minute thereafter.
314378 *
315- * This method handles all the details, and must be called roughly once per minute.
379+ * This currently includes:
380+ * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
381+ * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
382+ * than a minute, informing the network that they should no longer attempt to route over
383+ * the channel.
316384 *
317- * Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
385+ * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
386+ * estimate fetches.
318387 */
319388 public void timer_tick_occurred () {
320389 bindings .ChannelManager_timer_tick_occurred (this .ptr );
@@ -427,7 +496,7 @@ public TwoTuple<byte[], byte[]> create_inbound_payment(Option_u64Z min_value_msa
427496 * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
428497 * method may return an Err if another payment with the same payment_hash is still pending.
429498 *
430- * `user_payment_id` will be provided back in [`PaymentReceived ::user_payment_id`] events to
499+ * `user_payment_id` will be provided back in [`PaymentPurpose::InvoicePayment ::user_payment_id`] events to
431500 * allow tracking of which events correspond with which calls to this and
432501 * [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
433502 * copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
@@ -461,7 +530,7 @@ public TwoTuple<byte[], byte[]> create_inbound_payment(Option_u64Z min_value_msa
461530 *
462531 * [`create_inbound_payment`]: Self::create_inbound_payment
463532 * [`PaymentReceived`]: events::Event::PaymentReceived
464- * [`PaymentReceived:: user_payment_id`]: events::Event::PaymentReceived ::user_payment_id
533+ * [`PaymentPurpose::InvoicePayment:: user_payment_id`]: events::PaymentPurpose::InvoicePayment ::user_payment_id
465534 */
466535 public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash (byte [] payment_hash , Option_u64Z min_value_msat , int invoice_expiry_delta_secs , long user_payment_id ) {
467536 long ret = bindings .ChannelManager_create_inbound_payment_for_hash (this .ptr , payment_hash , min_value_msat .ptr , invoice_expiry_delta_secs , user_payment_id );
0 commit comments