+ /**
+ * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
+ * the given outputs, plus an output to the given change destination (if sufficient
+ * change value remains). The PSBT will have a feerate, at least, of the given value.
+ *
+ * The `locktime` argument is used to set the transaction's locktime. If `None`, the
+ * transaction will have a locktime of 0. It it recommended to set this to the current block
+ * height to avoid fee sniping, unless you have some specific reason to use a different
+ * locktime.
+ *
+ * Returns the PSBT and expected max transaction weight.
+ *
+ * Returns `Err(())` if the output value is greater than the input value minus required fee,
+ * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
+ * does not match the one we can spend.
+ *
+ * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
+ */
+ public static Result_C2Tuple_CVec_u8ZusizeZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_u32Z locktime) {
+ long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(InternalUtils.encodeUint64Array(InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr)), InternalUtils.encodeUint8Array(change_destination_script), feerate_sat_per_1000_weight, locktime.ptr);
+ GC.KeepAlive(descriptors);
+ GC.KeepAlive(outputs);
+ GC.KeepAlive(change_destination_script);
+ GC.KeepAlive(feerate_sat_per_1000_weight);
+ GC.KeepAlive(locktime);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_CVec_u8ZusizeZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8ZusizeZNoneZ.constr_from_ptr(ret);
+ foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(descriptors_conv_27); }; };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(locktime); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
+ * `path`.
+ *
+ * Returns both the node id of the peer to send the message to and the message itself.
+ *
+ * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ public static Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ create_onion_message(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, org.ldk.structs.BlindedPath reply_path) {
+ long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, path == null ? 0 : path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
+ GC.KeepAlive(entropy_source);
+ GC.KeepAlive(node_signer);
+ GC.KeepAlive(path);
+ GC.KeepAlive(contents);
+ GC.KeepAlive(reply_path);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ ret_hu_conv = Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reply_path); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Decode one layer of an incoming [`OnionMessage`].
+ *
+ * Returns either the next layer of the onion for forwarding or the decrypted content for the
+ * receiver.
+ */
+ public static Result_PeeledOnionNoneZ peel_onion_message(org.ldk.structs.OnionMessage msg, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.structs.CustomOnionMessageHandler custom_handler) {
+ long ret = bindings.peel_onion_message(msg == null ? 0 : msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
+ GC.KeepAlive(msg);
+ GC.KeepAlive(node_signer);
+ GC.KeepAlive(logger);
+ GC.KeepAlive(custom_handler);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(custom_handler); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Returns whether `tlv_type` corresponds to a TLV record for Offers.
+ */
+ public static bool OffersMessage_is_known_type(long tlv_type) {
+ bool ret = bindings.OffersMessage_is_known_type(tlv_type);
+ GC.KeepAlive(tlv_type);
+ return ret;
+ }
+
+ /**
+ * Create a one-hop blinded path for a payment.
+ */
+ public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, org.ldk.structs.EntropySource entropy_source) {
+ long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_node_id, 33)), payee_tlvs == null ? 0 : payee_tlvs.ptr, entropy_source.ptr);
+ GC.KeepAlive(payee_node_id);
+ GC.KeepAlive(payee_tlvs);
+ GC.KeepAlive(entropy_source);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_tlvs); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a PathFailure from a byte array, created by PathFailure_write
+ */
+ public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
+ long ret = bindings.PathFailure_read(InternalUtils.encodeUint8Array(ser));
+ GC.KeepAlive(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a ClosureReason from a byte array, created by ClosureReason_write
+ */
+ public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
+ long ret = bindings.ClosureReason_read(InternalUtils.encodeUint8Array(ser));
+ GC.KeepAlive(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a HTLCDestination from a byte array, created by HTLCDestination_write
+ */
+ public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
+ long ret = bindings.HTLCDestination_read(InternalUtils.encodeUint8Array(ser));
+ GC.KeepAlive(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Read a Event from a byte array, created by Event_write
+ */
+ public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
+ long ret = bindings.Event_read(InternalUtils.encodeUint8Array(ser));
+ GC.KeepAlive(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`].
+ *
+ * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
+ * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
+ * with the same [`PaymentHash`] is never sent.
+ *
+ * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
+ */
+ public static Result_ThirtyTwoBytesPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(retry_strategy);
+ GC.KeepAlive(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on
+ * [`Retry`].
+ *
+ * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
+ * payment completes or fails, no idempotency guarantees are made.
+ *
+ * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
+ * [`PaymentHash`] has never been paid before.
+ *
+ * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
+ */
+ public static Result_NonePaymentErrorZ pay_invoice_with_id(org.ldk.structs.Bolt11Invoice invoice, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_invoice_with_id(invoice == null ? 0 : invoice.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(payment_id);
+ GC.KeepAlive(retry_strategy);
+ GC.KeepAlive(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on
+ * [`Retry`].
+ *
+ * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
+ * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
+ * with the same [`PaymentHash`] is never sent.
+ *
+ * If you wish to use a different payment idempotency token, see
+ * [`pay_zero_value_invoice_with_id`].
+ */
+ public static Result_ThirtyTwoBytesPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(amount_msats);
+ GC.KeepAlive(retry_strategy);
+ GC.KeepAlive(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key,
+ * retrying if needed based on [`Retry`].
+ *
+ * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
+ * payment completes or fails, no idempotency guarantees are made.
+ *
+ * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
+ * [`PaymentHash`] has never been paid before.
+ *
+ * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
+ * idempotency token.
+ */
+ public static Result_NonePaymentErrorZ pay_zero_value_invoice_with_id(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
+ long ret = bindings.pay_zero_value_invoice_with_id(invoice == null ? 0 : invoice.ptr, amount_msats, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(amount_msats);
+ GC.KeepAlive(payment_id);
+ GC.KeepAlive(retry_strategy);
+ GC.KeepAlive(channelmanager);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Sends payment probes over all paths of a route that would be used to pay the given invoice.
+ *
+ * See [`ChannelManager::send_preflight_probes`] for more information.
+ */
+ public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
+ long ret = bindings.preflight_probe_invoice(invoice == null ? 0 : invoice.ptr, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(channelmanager);
+ GC.KeepAlive(liquidity_limit_multiplier);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(liquidity_limit_multiplier); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Sends payment probes over all paths of a route that would be used to pay the given zero-value
+ * invoice using the given amount.
+ *
+ * See [`ChannelManager::send_preflight_probes`] for more information.
+ */
+ public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
+ long ret = bindings.preflight_probe_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msat, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
+ GC.KeepAlive(invoice);
+ GC.KeepAlive(amount_msat);
+ GC.KeepAlive(channelmanager);
+ GC.KeepAlive(liquidity_limit_multiplier);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(liquidity_limit_multiplier); };
+ return ret_hu_conv;
+ }
+