7 namespace org { namespace ldk { namespace util {
8 public class UtilMethods {
10 * Gets the 128-bit integer, as 16 little-endian bytes
12 public static byte[] U128_le_bytes(org.ldk.util.UInt128 val) {
13 long ret = bindings.U128_le_bytes(InternalUtils.encodeUint8Array(val.getLEBytes()));
15 if (ret >= 0 && ret <= 4096) { return null; }
16 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
21 * Constructs a new U128 from 16 little-endian bytes
23 public static UInt128 U128_new(byte[] le_bytes) {
24 long ret = bindings.U128_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(le_bytes, 16)));
25 GC.KeepAlive(le_bytes);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
32 * Constructs a new COption_NoneZ containing a
34 public static COption_NoneZ COption_NoneZ_some() {
35 COption_NoneZ ret = bindings.COption_NoneZ_some();
40 * Constructs a new COption_NoneZ containing nothing
42 public static COption_NoneZ COption_NoneZ_none() {
43 COption_NoneZ ret = bindings.COption_NoneZ_none();
48 * Read a APIError from a byte array, created by APIError_write
50 public static Result_COption_APIErrorZDecodeErrorZ APIError_read(byte[] ser) {
51 long ret = bindings.APIError_read(InternalUtils.encodeUint8Array(ser));
53 if (ret >= 0 && ret <= 4096) { return null; }
54 Result_COption_APIErrorZDecodeErrorZ ret_hu_conv = Result_COption_APIErrorZDecodeErrorZ.constr_from_ptr(ret);
59 * Creates a digital signature of a message given a SecretKey, like the node's secret.
60 * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
61 * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
63 public static Result_StrSecp256k1ErrorZ sign(byte[] msg, byte[] sk) {
64 long ret = bindings.sign(InternalUtils.encodeUint8Array(msg), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(sk, 32)));
67 if (ret >= 0 && ret <= 4096) { return null; }
68 Result_StrSecp256k1ErrorZ ret_hu_conv = Result_StrSecp256k1ErrorZ.constr_from_ptr(ret);
73 * Recovers the PublicKey of the signer of the message given the message and the signature.
75 public static Result_PublicKeySecp256k1ErrorZ recover_pk(byte[] msg, string sig) {
76 long ret = bindings.recover_pk(InternalUtils.encodeUint8Array(msg), InternalUtils.encodeString(sig));
79 if (ret >= 0 && ret <= 4096) { return null; }
80 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
85 * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
88 public static bool verify(byte[] msg, string sig, byte[] pk) {
89 bool ret = bindings.verify(InternalUtils.encodeUint8Array(msg), InternalUtils.encodeString(sig), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pk, 33)));
97 * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
99 public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
100 long ret = bindings.construct_invoice_preimage(InternalUtils.encodeUint8Array(hrp_bytes), InternalUtils.encodeUint8Array(InternalUtils.convUInt5Array(data_without_signature)));
101 GC.KeepAlive(hrp_bytes);
102 GC.KeepAlive(data_without_signature);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
109 * Read previously persisted [`ChannelMonitor`]s from the store.
111 public static Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ read_channel_monitors(org.ldk.structs.KVStore kv_store, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.SignerProvider signer_provider) {
112 long ret = bindings.read_channel_monitors(kv_store.ptr, entropy_source.ptr, signer_provider.ptr);
113 GC.KeepAlive(kv_store);
114 GC.KeepAlive(entropy_source);
115 GC.KeepAlive(signer_provider);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.constr_from_ptr(ret);
118 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(kv_store); };
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(signer_provider); };
125 * Read a MonitorEvent from a byte array, created by MonitorEvent_write
127 public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
128 long ret = bindings.MonitorEvent_read(InternalUtils.encodeUint8Array(ser));
130 if (ret >= 0 && ret <= 4096) { return null; }
131 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
136 * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write
138 public static Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
139 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(InternalUtils.encodeUint8Array(ser), arg_a.ptr, arg_b.ptr);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_a); };
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_b); };
151 * Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information
152 * about the intended next-hop for the HTLC.
154 * This does all the relevant context-free checks that LDK requires for payment relay or
155 * acceptance. If the payment is to be received, and the amount matches the expected amount for
156 * a given invoice, this indicates the [`msgs::UpdateAddHTLC`], once fully committed in the
157 * channel, will generate an [`Event::PaymentClaimable`].
159 * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
161 public static Result_PendingHTLCInfoInboundHTLCErrZ peel_payment_onion(org.ldk.structs.UpdateAddHTLC msg, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, int cur_height, bool accept_mpp_keysend, bool allow_skimmed_fees) {
162 long ret = bindings.peel_payment_onion(msg == null ? 0 : msg.ptr, node_signer.ptr, logger.ptr, cur_height, accept_mpp_keysend, allow_skimmed_fees);
164 GC.KeepAlive(node_signer);
165 GC.KeepAlive(logger);
166 GC.KeepAlive(cur_height);
167 GC.KeepAlive(accept_mpp_keysend);
168 GC.KeepAlive(allow_skimmed_fees);
169 if (ret >= 0 && ret <= 4096) { return null; }
170 Result_PendingHTLCInfoInboundHTLCErrZ ret_hu_conv = Result_PendingHTLCInfoInboundHTLCErrZ.constr_from_ptr(ret);
171 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
172 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
173 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
178 * Fetches the set of [`InitFeatures`] flags that are provided by or required by
179 * [`ChannelManager`].
181 public static InitFeatures provided_init_features(org.ldk.structs.UserConfig config) {
182 long ret = bindings.provided_init_features(config == null ? 0 : config.ptr);
183 GC.KeepAlive(config);
184 if (ret >= 0 && ret <= 4096) { return null; }
185 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
187 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(config); };
192 * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write
194 public static Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelManagerZ_read(byte[] ser, EntropySource arg_entropy_source, NodeSigner arg_node_signer, SignerProvider arg_signer_provider, FeeEstimator arg_fee_estimator, Watch arg_chain_monitor, BroadcasterInterface arg_tx_broadcaster, Router arg_router, Logger arg_logger, UserConfig arg_default_config, ChannelMonitor[] arg_channel_monitors) {
195 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelManagerZ_read(InternalUtils.encodeUint8Array(ser), bindings.ChannelManagerReadArgs_new(arg_entropy_source.ptr, arg_node_signer.ptr, arg_signer_provider.ptr, arg_fee_estimator.ptr, arg_chain_monitor.ptr, arg_tx_broadcaster.ptr, arg_router.ptr, arg_logger.ptr, arg_default_config == null ? 0 : arg_default_config.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(arg_channel_monitors, arg_channel_monitors_conv_16 => arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr))));
197 GC.KeepAlive(arg_entropy_source);
198 GC.KeepAlive(arg_node_signer);
199 GC.KeepAlive(arg_signer_provider);
200 GC.KeepAlive(arg_fee_estimator);
201 GC.KeepAlive(arg_chain_monitor);
202 GC.KeepAlive(arg_tx_broadcaster);
203 GC.KeepAlive(arg_router);
204 GC.KeepAlive(arg_logger);
205 GC.KeepAlive(arg_default_config);
206 GC.KeepAlive(arg_channel_monitors);
207 if (ret >= 0 && ret <= 4096) { return null; }
208 Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_entropy_source); };
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_node_signer); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_signer_provider); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_fee_estimator); };
213 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_chain_monitor); };
214 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_tx_broadcaster); };
215 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_router); };
216 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_logger); };
217 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_default_config); };
218 foreach (ChannelMonitor arg_channel_monitors_conv_16 in arg_channel_monitors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_channel_monitors_conv_16); }; };
223 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
224 * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
225 * a `ChannelManager`.
227 * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
228 * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
229 * regenerate it for each new inbound payment.
231 * `current_time` is a Unix timestamp representing the current time.
233 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
234 * on versions of LDK prior to 0.0.114.
236 * [phantom node payments]: crate::sign::PhantomKeysManager
237 * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material
239 public static Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create(org.ldk.structs.ExpandedKey keys, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs, org.ldk.structs.EntropySource entropy_source, long current_time, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
240 long ret = bindings.create(keys == null ? 0 : keys.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, entropy_source.ptr, current_time, min_final_cltv_expiry_delta.ptr);
242 GC.KeepAlive(min_value_msat);
243 GC.KeepAlive(invoice_expiry_delta_secs);
244 GC.KeepAlive(entropy_source);
245 GC.KeepAlive(current_time);
246 GC.KeepAlive(min_final_cltv_expiry_delta);
247 if (ret >= 0 && ret <= 4096) { return null; }
248 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
249 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
250 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
251 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
252 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
257 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
258 * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
259 * without a `ChannelManager`.
261 * See [`create`] for information on the `keys` and `current_time` parameters.
263 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
264 * on versions of LDK prior to 0.0.114.
266 * [phantom node payments]: crate::sign::PhantomKeysManager
268 public static Result_ThirtyTwoBytesNoneZ create_from_hash(org.ldk.structs.ExpandedKey keys, org.ldk.structs.Option_u64Z min_value_msat, byte[] payment_hash, int invoice_expiry_delta_secs, long current_time, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
269 long ret = bindings.create_from_hash(keys == null ? 0 : keys.ptr, min_value_msat.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), invoice_expiry_delta_secs, current_time, min_final_cltv_expiry_delta.ptr);
271 GC.KeepAlive(min_value_msat);
272 GC.KeepAlive(payment_hash);
273 GC.KeepAlive(invoice_expiry_delta_secs);
274 GC.KeepAlive(current_time);
275 GC.KeepAlive(min_final_cltv_expiry_delta);
276 if (ret >= 0 && ret <= 4096) { return null; }
277 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
278 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
279 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
280 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
285 * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
287 * The host part must end with \".onion\".
289 public static Result_SocketAddressSocketAddressParseErrorZ parse_onion_address(string host, short port) {
290 long ret = bindings.parse_onion_address(InternalUtils.encodeString(host), port);
293 if (ret >= 0 && ret <= 4096) { return null; }
294 Result_SocketAddressSocketAddressParseErrorZ ret_hu_conv = Result_SocketAddressSocketAddressParseErrorZ.constr_from_ptr(ret);
299 * Gets the weight for an HTLC-Success transaction.
301 public static long htlc_success_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
302 long ret = bindings.htlc_success_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
303 GC.KeepAlive(channel_type_features);
308 * Gets the weight for an HTLC-Timeout transaction.
310 public static long htlc_timeout_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
311 long ret = bindings.htlc_timeout_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
312 GC.KeepAlive(channel_type_features);
317 * Check if a given input witness attempts to claim a HTLC.
319 public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
320 long ret = bindings.HTLCClaim_from_witness(InternalUtils.encodeUint8Array(witness));
321 GC.KeepAlive(witness);
322 if (ret >= 0 && ret <= 4096) { return null; }
323 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
324 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
329 * Build the commitment secret from the seed and the commitment number
331 public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
332 long ret = bindings.build_commitment_secret(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_seed, 32)), idx);
333 GC.KeepAlive(commitment_seed);
335 if (ret >= 0 && ret <= 4096) { return null; }
336 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
341 * Build a closing transaction
343 public static byte[] build_closing_transaction(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, org.ldk.structs.OutPoint funding_outpoint) {
344 long ret = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, InternalUtils.encodeUint8Array(to_holder_script), InternalUtils.encodeUint8Array(to_counterparty_script), funding_outpoint == null ? 0 : funding_outpoint.ptr);
345 GC.KeepAlive(to_holder_value_sat);
346 GC.KeepAlive(to_counterparty_value_sat);
347 GC.KeepAlive(to_holder_script);
348 GC.KeepAlive(to_counterparty_script);
349 GC.KeepAlive(funding_outpoint);
350 if (ret >= 0 && ret <= 4096) { return null; }
351 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
356 * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
357 * from the base secret and the per_commitment_point.
359 public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
360 long ret = bindings.derive_private_key(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(base_secret, 32)));
361 GC.KeepAlive(per_commitment_point);
362 GC.KeepAlive(base_secret);
363 if (ret >= 0 && ret <= 4096) { return null; }
364 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
369 * Derives a per-commitment-transaction revocation key from its constituent parts.
371 * Only the cheating participant owns a valid witness to propagate a revoked
372 * commitment transaction, thus per_commitment_secret always come from cheater
373 * and revocation_base_secret always come from punisher, which is the broadcaster
374 * of the transaction spending with this key knowledge.
376 public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
377 long ret = bindings.derive_private_revocation_key(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_secret, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32)));
378 GC.KeepAlive(per_commitment_secret);
379 GC.KeepAlive(countersignatory_revocation_base_secret);
380 if (ret >= 0 && ret <= 4096) { return null; }
381 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
386 * A script either spendable by the revocation
387 * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
388 * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
390 public static byte[] get_revokeable_redeemscript(org.ldk.structs.RevocationKey revocation_key, short contest_delay, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key) {
391 long ret = bindings.get_revokeable_redeemscript(revocation_key == null ? 0 : revocation_key.ptr, contest_delay, broadcaster_delayed_payment_key == null ? 0 : broadcaster_delayed_payment_key.ptr);
392 GC.KeepAlive(revocation_key);
393 GC.KeepAlive(contest_delay);
394 GC.KeepAlive(broadcaster_delayed_payment_key);
395 if (ret >= 0 && ret <= 4096) { return null; }
396 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
401 * Returns the script for the counterparty's output on a holder's commitment transaction based on
404 public static byte[] get_counterparty_payment_script(org.ldk.structs.ChannelTypeFeatures channel_type_features, byte[] payment_key) {
405 long ret = bindings.get_counterparty_payment_script(channel_type_features == null ? 0 : channel_type_features.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_key, 33)));
406 GC.KeepAlive(channel_type_features);
407 GC.KeepAlive(payment_key);
408 if (ret >= 0 && ret <= 4096) { return null; }
409 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
414 * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
415 * does not need to have its previous_output_index filled.
417 public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.TxCreationKeys keys) {
418 long ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr, channel_type_features == null ? 0 : channel_type_features.ptr, keys == null ? 0 : keys.ptr);
420 GC.KeepAlive(channel_type_features);
422 if (ret >= 0 && ret <= 4096) { return null; }
423 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
428 * Gets the redeemscript for a funding output from the two funding public keys.
429 * Note that the order of funding public keys does not matter.
431 public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
432 long ret = bindings.make_funding_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory, 33)));
433 GC.KeepAlive(broadcaster);
434 GC.KeepAlive(countersignatory);
435 if (ret >= 0 && ret <= 4096) { return null; }
436 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
441 * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
442 * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
443 * transaction which needs signing, and can be used to construct an HTLC transaction which is
444 * broadcastable given a counterparty HTLC signature.
446 * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
447 * commitment transaction).
449 public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key, org.ldk.structs.RevocationKey revocation_key) {
450 long ret = bindings.build_htlc_transaction(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_txid, 32)), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr, channel_type_features == null ? 0 : channel_type_features.ptr, broadcaster_delayed_payment_key == null ? 0 : broadcaster_delayed_payment_key.ptr, revocation_key == null ? 0 : revocation_key.ptr);
451 GC.KeepAlive(commitment_txid);
452 GC.KeepAlive(feerate_per_kw);
453 GC.KeepAlive(contest_delay);
455 GC.KeepAlive(channel_type_features);
456 GC.KeepAlive(broadcaster_delayed_payment_key);
457 GC.KeepAlive(revocation_key);
458 if (ret >= 0 && ret <= 4096) { return null; }
459 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
464 * Returns the witness required to satisfy and spend a HTLC input.
466 public static byte[] build_htlc_input_witness(byte[] local_sig, byte[] remote_sig, org.ldk.structs.Option_ThirtyTwoBytesZ preimage, byte[] redeem_script, org.ldk.structs.ChannelTypeFeatures channel_type_features) {
467 long ret = bindings.build_htlc_input_witness(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(local_sig, 64)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(remote_sig, 64)), preimage.ptr, InternalUtils.encodeUint8Array(redeem_script), channel_type_features == null ? 0 : channel_type_features.ptr);
468 GC.KeepAlive(local_sig);
469 GC.KeepAlive(remote_sig);
470 GC.KeepAlive(preimage);
471 GC.KeepAlive(redeem_script);
472 GC.KeepAlive(channel_type_features);
473 if (ret >= 0 && ret <= 4096) { return null; }
474 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
479 * Gets the witnessScript for the to_remote output when anchors are enabled.
481 public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
482 long ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point, 33)));
483 GC.KeepAlive(payment_point);
484 if (ret >= 0 && ret <= 4096) { return null; }
485 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
490 * Gets the witnessScript for an anchor output from the funding public key.
491 * The witness in the spending input must be:
492 * <BIP 143 funding_signature>
493 * After 16 blocks of confirmation, an alternative satisfying witness could be:
495 * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
497 public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
498 long ret = bindings.get_anchor_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey, 33)));
499 GC.KeepAlive(funding_pubkey);
500 if (ret >= 0 && ret <= 4096) { return null; }
501 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
506 * Returns the witness required to satisfy and spend an anchor input.
508 public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
509 long ret = bindings.build_anchor_input_witness(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_sig, 64)));
510 GC.KeepAlive(funding_key);
511 GC.KeepAlive(funding_sig);
512 if (ret >= 0 && ret <= 4096) { return null; }
513 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
518 * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
519 * shared secret first. This prevents on-chain observers from discovering how many commitment
520 * transactions occurred in a channel before it was closed.
522 * This function gets the shared secret from relevant channel public keys and can be used to
523 * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
525 public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, bool outbound_from_broadcaster) {
526 long ret = bindings.get_commitment_transaction_number_obscure_factor(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster_payment_basepoint, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory_payment_basepoint, 33)), outbound_from_broadcaster);
527 GC.KeepAlive(broadcaster_payment_basepoint);
528 GC.KeepAlive(countersignatory_payment_basepoint);
529 GC.KeepAlive(outbound_from_broadcaster);
534 * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
536 public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
537 long ret = bindings.NetworkUpdate_read(InternalUtils.encodeUint8Array(ser));
539 if (ret >= 0 && ret <= 4096) { return null; }
540 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
545 * Verifies the signature of a [`NodeAnnouncement`].
547 * Returns an error if it is invalid.
549 public static Result_NoneLightningErrorZ verify_node_announcement(org.ldk.structs.NodeAnnouncement msg) {
550 long ret = bindings.verify_node_announcement(msg == null ? 0 : msg.ptr);
552 if (ret >= 0 && ret <= 4096) { return null; }
553 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
554 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
559 * Verifies all signatures included in a [`ChannelAnnouncement`].
561 * Returns an error if one of the signatures is invalid.
563 public static Result_NoneLightningErrorZ verify_channel_announcement(org.ldk.structs.ChannelAnnouncement msg) {
564 long ret = bindings.verify_channel_announcement(msg == null ? 0 : msg.ptr);
566 if (ret >= 0 && ret <= 4096) { return null; }
567 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
568 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
573 * Finds a route from us (payer) to the given target node (payee).
575 * If the payee provided features in their invoice, they should be provided via the `payee` field
576 * in the given [`RouteParameters::payment_params`].
577 * Without this, MPP will only be used if the payee's features are available in the network graph.
579 * Private routing paths between a public node and the target may be included in the `payee` field
580 * of [`RouteParameters::payment_params`].
582 * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
583 * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
584 * from `network_graph` will be ignored, and only those in `first_hops` will be used.
586 * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
587 * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
588 * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
592 * Panics if first_hops contains channels without `short_channel_id`s;
593 * [`ChannelManager::list_usable_channels`] will never include such channels.
595 * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
596 * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
597 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
599 * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
601 public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.ScoreLookUp scorer, org.ldk.structs.ProbabilisticScoringFeeParameters score_params, byte[] random_seed_bytes) {
602 long ret = bindings.find_route(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(our_node_pubkey, 33)), route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(first_hops, first_hops_conv_16 => first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr)), logger.ptr, scorer.ptr, score_params == null ? 0 : score_params.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(random_seed_bytes, 32)));
603 GC.KeepAlive(our_node_pubkey);
604 GC.KeepAlive(route_params);
605 GC.KeepAlive(network_graph);
606 GC.KeepAlive(first_hops);
607 GC.KeepAlive(logger);
608 GC.KeepAlive(scorer);
609 GC.KeepAlive(score_params);
610 GC.KeepAlive(random_seed_bytes);
611 if (ret >= 0 && ret <= 4096) { return null; }
612 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
613 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
614 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
615 if (first_hops != null) { foreach (ChannelDetails first_hops_conv_16 in first_hops) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(first_hops_conv_16); }; } };
616 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
617 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(scorer); };
618 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(score_params); };
623 * Construct a route from us (payer) to the target node (payee) via the given hops (which should
624 * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
626 * Re-uses logic from `find_route`, so the restrictions described there also apply here.
628 public static Result_RouteLightningErrorZ build_route_from_hops(byte[] our_node_pubkey, byte[][] hops, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Logger logger, byte[] random_seed_bytes) {
629 long ret = bindings.build_route_from_hops(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(our_node_pubkey, 33)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(hops, hops_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(hops_conv_8, 33)))), route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, logger.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(random_seed_bytes, 32)));
630 GC.KeepAlive(our_node_pubkey);
632 GC.KeepAlive(route_params);
633 GC.KeepAlive(network_graph);
634 GC.KeepAlive(logger);
635 GC.KeepAlive(random_seed_bytes);
636 if (ret >= 0 && ret <= 4096) { return null; }
637 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
638 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
639 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
640 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
645 * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
646 * the given outputs, plus an output to the given change destination (if sufficient
647 * change value remains). The PSBT will have a feerate, at least, of the given value.
649 * The `locktime` argument is used to set the transaction's locktime. If `None`, the
650 * transaction will have a locktime of 0. It it recommended to set this to the current block
651 * height to avoid fee sniping, unless you have some specific reason to use a different
654 * Returns the PSBT and expected max transaction weight.
656 * Returns `Err(())` if the output value is greater than the input value minus required fee,
657 * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
658 * does not match the one we can spend.
660 * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
662 public static Result_C2Tuple_CVec_u8Zu64ZNoneZ 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) {
663 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);
664 GC.KeepAlive(descriptors);
665 GC.KeepAlive(outputs);
666 GC.KeepAlive(change_destination_script);
667 GC.KeepAlive(feerate_sat_per_1000_weight);
668 GC.KeepAlive(locktime);
669 if (ret >= 0 && ret <= 4096) { return null; }
670 Result_C2Tuple_CVec_u8Zu64ZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8Zu64ZNoneZ.constr_from_ptr(ret);
671 foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(descriptors_conv_27); }; };
672 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(locktime); };
677 * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
680 * Returns the node id of the peer to send the message to, the message itself, and any addresses
681 * need to connect to the first node.
683 * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
685 public static Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ 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) {
686 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);
687 GC.KeepAlive(entropy_source);
688 GC.KeepAlive(node_signer);
690 GC.KeepAlive(contents);
691 GC.KeepAlive(reply_path);
692 if (ret >= 0 && ret <= 4096) { return null; }
693 Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
694 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
695 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
696 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
697 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents); };
698 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reply_path); };
703 * Decode one layer of an incoming [`OnionMessage`].
705 * Returns either the next layer of the onion for forwarding or the decrypted content for the
708 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) {
709 long ret = bindings.peel_onion_message(msg == null ? 0 : msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
711 GC.KeepAlive(node_signer);
712 GC.KeepAlive(logger);
713 GC.KeepAlive(custom_handler);
714 if (ret >= 0 && ret <= 4096) { return null; }
715 Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
716 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
717 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
718 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
719 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(custom_handler); };
724 * Returns whether `tlv_type` corresponds to a TLV record for Offers.
726 public static bool OffersMessage_is_known_type(long tlv_type) {
727 bool ret = bindings.OffersMessage_is_known_type(tlv_type);
728 GC.KeepAlive(tlv_type);
733 * Create a one-hop blinded path for a payment.
735 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) {
736 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);
737 GC.KeepAlive(payee_node_id);
738 GC.KeepAlive(payee_tlvs);
739 GC.KeepAlive(entropy_source);
740 if (ret >= 0 && ret <= 4096) { return null; }
741 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
742 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_tlvs); };
743 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
748 * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
751 * a provided node id is invalid
752 * [`BlindedPayInfo`] calculation results in an integer overflow
753 * any unknown features are required in the provided [`ForwardTlvs`]
755 * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
757 public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_new_for_payment(ForwardNode[] intermediate_nodes, byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, long htlc_maximum_msat, org.ldk.structs.EntropySource entropy_source) {
758 long ret = bindings.BlindedPath_new_for_payment(InternalUtils.encodeUint64Array(InternalUtils.mapArray(intermediate_nodes, intermediate_nodes_conv_13 => intermediate_nodes_conv_13 == null ? 0 : intermediate_nodes_conv_13.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_node_id, 33)), payee_tlvs == null ? 0 : payee_tlvs.ptr, htlc_maximum_msat, entropy_source.ptr);
759 GC.KeepAlive(intermediate_nodes);
760 GC.KeepAlive(payee_node_id);
761 GC.KeepAlive(payee_tlvs);
762 GC.KeepAlive(htlc_maximum_msat);
763 GC.KeepAlive(entropy_source);
764 if (ret >= 0 && ret <= 4096) { return null; }
765 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
766 foreach (ForwardNode intermediate_nodes_conv_13 in intermediate_nodes) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(intermediate_nodes_conv_13); }; };
767 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_tlvs); };
768 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
773 * Read a PathFailure from a byte array, created by PathFailure_write
775 public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
776 long ret = bindings.PathFailure_read(InternalUtils.encodeUint8Array(ser));
778 if (ret >= 0 && ret <= 4096) { return null; }
779 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
784 * Read a ClosureReason from a byte array, created by ClosureReason_write
786 public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
787 long ret = bindings.ClosureReason_read(InternalUtils.encodeUint8Array(ser));
789 if (ret >= 0 && ret <= 4096) { return null; }
790 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
795 * Read a HTLCDestination from a byte array, created by HTLCDestination_write
797 public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
798 long ret = bindings.HTLCDestination_read(InternalUtils.encodeUint8Array(ser));
800 if (ret >= 0 && ret <= 4096) { return null; }
801 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
806 * Read a Event from a byte array, created by Event_write
808 public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
809 long ret = bindings.Event_read(InternalUtils.encodeUint8Array(ser));
811 if (ret >= 0 && ret <= 4096) { return null; }
812 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
817 * Builds the necessary parameters to pay or pre-flight probe the given zero-amount
818 * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
819 * [`ChannelManager::send_preflight_probes`].
821 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
822 * same [`PaymentHash`] has never been paid before.
824 * Will always succeed unless the invoice has an amount specified, in which case
825 * [`payment_parameters_from_invoice`] should be used.
827 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
828 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
830 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat) {
831 long ret = bindings.payment_parameters_from_zero_amount_invoice(invoice == null ? 0 : invoice.ptr, amount_msat);
832 GC.KeepAlive(invoice);
833 GC.KeepAlive(amount_msat);
834 if (ret >= 0 && ret <= 4096) { return null; }
835 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
836 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
841 * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using
842 * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`].
844 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
845 * same [`PaymentHash`] has never been paid before.
847 * Will always succeed unless the invoice has no amount specified, in which case
848 * [`payment_parameters_from_zero_amount_invoice`] should be used.
850 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
851 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
853 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(org.ldk.structs.Bolt11Invoice invoice) {
854 long ret = bindings.payment_parameters_from_invoice(invoice == null ? 0 : invoice.ptr);
855 GC.KeepAlive(invoice);
856 if (ret >= 0 && ret <= 4096) { return null; }
857 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
858 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
863 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
864 * See [`PhantomKeysManager`] for more information on phantom node payments.
866 * `phantom_route_hints` parameter:
867 * Contains channel info for all nodes participating in the phantom invoice
868 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
870 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
871 * updated when a channel becomes disabled or closes
872 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
873 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
876 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
877 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
878 * If `None` is provided for `payment_hash`, then one will be created.
880 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
881 * in excess of the current time.
883 * `duration_since_epoch` is the current time since epoch in seconds.
885 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
886 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
887 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
888 * confirmations during routing.
890 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
891 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
894 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
895 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
896 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
897 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
898 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
899 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
901 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
902 * available and the current time is supplied by the caller.
904 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, string description, int invoice_expiry_delta_secs, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
905 long ret = bindings.create_phantom_invoice(amt_msat.ptr, payment_hash.ptr, InternalUtils.encodeString(description), invoice_expiry_delta_secs, InternalUtils.encodeUint64Array(InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr)), entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
906 GC.KeepAlive(amt_msat);
907 GC.KeepAlive(payment_hash);
908 GC.KeepAlive(description);
909 GC.KeepAlive(invoice_expiry_delta_secs);
910 GC.KeepAlive(phantom_route_hints);
911 GC.KeepAlive(entropy_source);
912 GC.KeepAlive(node_signer);
913 GC.KeepAlive(logger);
914 GC.KeepAlive(network);
915 GC.KeepAlive(min_final_cltv_expiry_delta);
916 GC.KeepAlive(duration_since_epoch);
917 if (ret >= 0 && ret <= 4096) { return null; }
918 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
919 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
920 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
921 foreach (PhantomRouteHints phantom_route_hints_conv_19 in phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(phantom_route_hints_conv_19); }; };
922 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
923 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
924 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
925 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
930 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
931 * See [`PhantomKeysManager`] for more information on phantom node payments.
933 * `phantom_route_hints` parameter:
934 * Contains channel info for all nodes participating in the phantom invoice
935 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
937 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
938 * updated when a channel becomes disabled or closes
939 * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
940 * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
941 * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
942 * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
943 * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
945 * `description_hash` is a SHA-256 hash of the description text
947 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
948 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
949 * If `None` is provided for `payment_hash`, then one will be created.
951 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
952 * in excess of the current time.
954 * `duration_since_epoch` is the current time since epoch in seconds.
956 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
957 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
960 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
961 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
962 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
963 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
964 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
966 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
967 * available and the current time is supplied by the caller.
969 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, int invoice_expiry_delta_secs, org.ldk.structs.Sha256 description_hash, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
970 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, payment_hash.ptr, invoice_expiry_delta_secs, description_hash == null ? 0 : description_hash.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr)), entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
971 GC.KeepAlive(amt_msat);
972 GC.KeepAlive(payment_hash);
973 GC.KeepAlive(invoice_expiry_delta_secs);
974 GC.KeepAlive(description_hash);
975 GC.KeepAlive(phantom_route_hints);
976 GC.KeepAlive(entropy_source);
977 GC.KeepAlive(node_signer);
978 GC.KeepAlive(logger);
979 GC.KeepAlive(network);
980 GC.KeepAlive(min_final_cltv_expiry_delta);
981 GC.KeepAlive(duration_since_epoch);
982 if (ret >= 0 && ret <= 4096) { return null; }
983 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
984 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
985 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
986 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
987 foreach (PhantomRouteHints phantom_route_hints_conv_19 in phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(phantom_route_hints_conv_19); }; };
988 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
989 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
990 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
991 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
996 * Utility to construct an invoice. Generally, unless you want to do something like a custom
997 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
998 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
999 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1000 * that the payment secret is valid when the invoice is paid.
1002 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1003 * in excess of the current time.
1005 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1006 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1007 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1008 * confirmations during routing.
1010 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1012 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1013 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, InternalUtils.encodeString(description), invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1014 GC.KeepAlive(channelmanager);
1015 GC.KeepAlive(node_signer);
1016 GC.KeepAlive(logger);
1017 GC.KeepAlive(network);
1018 GC.KeepAlive(amt_msat);
1019 GC.KeepAlive(description);
1020 GC.KeepAlive(invoice_expiry_delta_secs);
1021 GC.KeepAlive(min_final_cltv_expiry_delta);
1022 if (ret >= 0 && ret <= 4096) { return null; }
1023 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1024 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1025 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1026 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1027 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1028 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1033 * Utility to construct an invoice. Generally, unless you want to do something like a custom
1034 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1035 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1036 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1037 * that the payment secret is valid when the invoice is paid.
1038 * Use this variant if you want to pass the `description_hash` to the invoice.
1040 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1041 * in excess of the current time.
1043 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1044 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1045 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1046 * confirmations during routing.
1048 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1050 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Sha256 description_hash, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1051 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1052 GC.KeepAlive(channelmanager);
1053 GC.KeepAlive(node_signer);
1054 GC.KeepAlive(logger);
1055 GC.KeepAlive(network);
1056 GC.KeepAlive(amt_msat);
1057 GC.KeepAlive(description_hash);
1058 GC.KeepAlive(invoice_expiry_delta_secs);
1059 GC.KeepAlive(min_final_cltv_expiry_delta);
1060 if (ret >= 0 && ret <= 4096) { return null; }
1061 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1062 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1063 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1064 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1065 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1066 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
1067 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1072 * See [`create_invoice_from_channelmanager_with_description_hash`]
1073 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1074 * available and the current time is supplied by the caller.
1076 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Sha256 description_hash, long duration_since_epoch, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1077 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1078 GC.KeepAlive(channelmanager);
1079 GC.KeepAlive(node_signer);
1080 GC.KeepAlive(logger);
1081 GC.KeepAlive(network);
1082 GC.KeepAlive(amt_msat);
1083 GC.KeepAlive(description_hash);
1084 GC.KeepAlive(duration_since_epoch);
1085 GC.KeepAlive(invoice_expiry_delta_secs);
1086 GC.KeepAlive(min_final_cltv_expiry_delta);
1087 if (ret >= 0 && ret <= 4096) { return null; }
1088 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1089 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1090 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1091 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1092 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1093 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
1094 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1099 * See [`create_invoice_from_channelmanager`]
1100 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1101 * available and the current time is supplied by the caller.
1103 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, long duration_since_epoch, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1104 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, InternalUtils.encodeString(description), duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1105 GC.KeepAlive(channelmanager);
1106 GC.KeepAlive(node_signer);
1107 GC.KeepAlive(logger);
1108 GC.KeepAlive(network);
1109 GC.KeepAlive(amt_msat);
1110 GC.KeepAlive(description);
1111 GC.KeepAlive(duration_since_epoch);
1112 GC.KeepAlive(invoice_expiry_delta_secs);
1113 GC.KeepAlive(min_final_cltv_expiry_delta);
1114 if (ret >= 0 && ret <= 4096) { return null; }
1115 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1118 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1125 * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1126 * This version allows for providing a custom [`PaymentHash`] for the invoice.
1127 * This may be useful if you're building an on-chain swap or involving another protocol where
1128 * the payment hash is also involved outside the scope of lightning.
1130 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, long duration_since_epoch, int invoice_expiry_delta_secs, byte[] payment_hash, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1131 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, InternalUtils.encodeString(description), duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), min_final_cltv_expiry_delta.ptr);
1132 GC.KeepAlive(channelmanager);
1133 GC.KeepAlive(node_signer);
1134 GC.KeepAlive(logger);
1135 GC.KeepAlive(network);
1136 GC.KeepAlive(amt_msat);
1137 GC.KeepAlive(description);
1138 GC.KeepAlive(duration_since_epoch);
1139 GC.KeepAlive(invoice_expiry_delta_secs);
1140 GC.KeepAlive(payment_hash);
1141 GC.KeepAlive(min_final_cltv_expiry_delta);
1142 if (ret >= 0 && ret <= 4096) { return null; }
1143 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1144 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };