+ Reference.reachabilityFence(this);
+ }
+
+ /**
+ * Sends a payment along a given route.
+ *
+ * Value parameters are provided via the last hop in route, see documentation for RouteHop
+ * fields for more info.
+ *
+ * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
+ * payment), we don't do anything to stop you! We always try to ensure that if the provided
+ * next hop knows the preimage to payment_hash they can claim an additional amount as
+ * specified in the last hop in the route! Thus, you should probably do your own
+ * payment_preimage tracking (which you should already be doing as they represent \"proof of
+ * payment\") and prevent double-sends yourself.
+ *
+ * May generate SendHTLCs message(s) event on success, which should be relayed.
+ *
+ * Each path may have a different return value, and PaymentSendValue may return a Vec with
+ * each entry matching the corresponding-index entry in the route paths, see
+ * PaymentSendFailure for more info.
+ *
+ * In general, a path may raise:
+ * 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
+ * (including due to previous monitor update failure or new permanent monitor update
+ * failure).
+ * APIError::MonitorUpdateFailed 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
+ * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
+ * different route unless you intend to pay twice!
+ *
+ * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
+ * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
+ * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
+ * must not contain multiple paths as multi-path payments require a recipient-provided
+ * payment_secret.
+ * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
+ * bit set (either as required or as available). If multiple paths are present in the Route,
+ * we assume the invoice had the basic_mpp feature set.
+ *
+ * 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));
+ 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);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Retries a payment along the given [`Route`].
+ *
+ * Errors returned are a superset of those returned from [`send_payment`], so see
+ * [`send_payment`] documentation for more details on errors. This method will also error if the
+ * retry amount puts the payment more than 10% over the payment's total amount, if the payment
+ * for the given `payment_id` cannot be found (likely due to timeout or success), or if
+ * further retries have been disabled with [`abandon_payment`].
+ *
+ * [`send_payment`]: [`ChannelManager::send_payment`]
+ * [`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));
+ 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);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Signals that no further retries for the given payment will occur.
+ *
+ * After this method returns, any future calls to [`retry_payment`] for the given `payment_id`
+ * will fail with [`PaymentSendFailure::ParameterError`]. If no such event has been generated,
+ * an [`Event::PaymentFailed`] event will be generated as soon as there are no remaining
+ * pending HTLCs for this payment.
+ *
+ * Note that calling this method does *not* prevent a payment from succeeding. You must still
+ * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
+ * determine the ultimate status of a payment.
+ *
+ * [`retry_payment`]: Self::retry_payment
+ * [`Event::PaymentFailed`]: events::Event::PaymentFailed
+ * [`Event::PaymentSent`]: events::Event::PaymentSent
+ */
+ public void abandon_payment(byte[] payment_id) {
+ bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(payment_id);
+ }
+
+ /**
+ * Send a spontaneous payment, which is a payment that does not require the recipient to have
+ * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
+ * the preimage, it must be a cryptographically secure random value that no intermediate node
+ * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
+ * never reach the recipient.
+ *
+ * See [`send_payment`] documentation for more details on the return value of this function.
+ *
+ * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
+ * [`send_payment`] for more information about the risks of duplicate preimage usage.
+ *
+ * Note that `route` must have exactly one path.
+ *
+ * [`send_payment`]: Self::send_payment
+ *
+ * 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));
+ 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);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Call this upon creation of a funding transaction for the given channel.
+ *
+ * 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::ChannelUnavailable`] if a funding transaction has already been provided
+ * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
+ *
+ * May panic if the output found in the funding transaction is duplicative with some other
+ * channel (note that this should be trivially prevented by using unique funding transaction
+ * keys per-channel).
+ *
+ * Do NOT broadcast the funding transaction yourself. When we have safely received our
+ * counterparty's signature the funding transaction will automatically be broadcast via the
+ * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
+ *
+ * Note that this includes RBF or similar transaction replacement strategies - lightning does
+ * not currently support replacing a funding transaction on an existing channel. Instead,
+ * create a new channel with a conflicting funding transaction.
+ *
+ * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
+ * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
+ */
+ public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] funding_transaction) {
+ long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), funding_transaction);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(temporary_channel_id);
+ Reference.reachabilityFence(funding_transaction);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;