+ /**
+ * 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_PartiallySignedTransactionusizeZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_PackedLockTimeZ locktime) {
+ long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors != null ? InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr) : null, outputs != null ? InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr) : null, 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_PartiallySignedTransactionusizeZNoneZ ret_hu_conv = Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ.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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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(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(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(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(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_PaymentIdPaymentErrorZ 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_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.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.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_PaymentIdPaymentErrorZ 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_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.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.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;
+ }
+