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 * Extracts the block height (most significant 3-bytes) from the `short_channel_id`
127 public static int block_from_scid(long short_channel_id) {
128 int ret = bindings.block_from_scid(short_channel_id);
129 GC.KeepAlive(short_channel_id);
134 * Extracts the tx index (bytes [2..4]) from the `short_channel_id`
136 public static int tx_index_from_scid(long short_channel_id) {
137 int ret = bindings.tx_index_from_scid(short_channel_id);
138 GC.KeepAlive(short_channel_id);
143 * Extracts the vout (bytes [0..2]) from the `short_channel_id`
145 public static short vout_from_scid(long short_channel_id) {
146 short ret = bindings.vout_from_scid(short_channel_id);
147 GC.KeepAlive(short_channel_id);
152 * Constructs a `short_channel_id` using the components pieces. Results in an error
153 * if the block height, tx index, or vout index overflow the maximum sizes.
155 public static Result_u64ShortChannelIdErrorZ scid_from_parts(long block, long tx_index, long vout_index) {
156 long ret = bindings.scid_from_parts(block, tx_index, vout_index);
158 GC.KeepAlive(tx_index);
159 GC.KeepAlive(vout_index);
160 if (ret >= 0 && ret <= 4096) { return null; }
161 Result_u64ShortChannelIdErrorZ ret_hu_conv = Result_u64ShortChannelIdErrorZ.constr_from_ptr(ret);
166 * Read a C2Tuple_BestBlockOutputSweeperZ from a byte array, created by C2Tuple_BestBlockOutputSweeperZ_write
168 public static Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ C2Tuple_BestBlockOutputSweeperZ_read(byte[] ser, org.ldk.structs.BroadcasterInterface arg_a, org.ldk.structs.FeeEstimator arg_b, org.ldk.structs.Option_FilterZ arg_c, org.ldk.structs.OutputSpender arg_d, org.ldk.structs.ChangeDestinationSource arg_e, org.ldk.structs.KVStore arg_f, org.ldk.structs.Logger arg_g) {
169 long ret = bindings.C2Tuple_BestBlockOutputSweeperZ_read(InternalUtils.encodeUint8Array(ser), arg_a.ptr, arg_b.ptr, arg_c.ptr, arg_d.ptr, arg_e.ptr, arg_f.ptr, arg_g.ptr);
178 if (ret >= 0 && ret <= 4096) { return null; }
179 Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ.constr_from_ptr(ret);
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_a); };
181 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_b); };
182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_c); };
183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_d); };
184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_e); };
185 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_f); };
186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_g); };
191 * Read a MonitorEvent from a byte array, created by MonitorEvent_write
193 public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
194 long ret = bindings.MonitorEvent_read(InternalUtils.encodeUint8Array(ser));
196 if (ret >= 0 && ret <= 4096) { return null; }
197 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
202 * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write
204 public static Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
205 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(InternalUtils.encodeUint8Array(ser), arg_a.ptr, arg_b.ptr);
209 if (ret >= 0 && ret <= 4096) { return null; }
210 Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_a); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_b); };
217 * Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information
218 * about the intended next-hop for the HTLC.
220 * This does all the relevant context-free checks that LDK requires for payment relay or
221 * acceptance. If the payment is to be received, and the amount matches the expected amount for
222 * a given invoice, this indicates the [`msgs::UpdateAddHTLC`], once fully committed in the
223 * channel, will generate an [`Event::PaymentClaimable`].
225 * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
227 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) {
228 long ret = bindings.peel_payment_onion(msg.ptr, node_signer.ptr, logger.ptr, cur_height, accept_mpp_keysend, allow_skimmed_fees);
230 GC.KeepAlive(node_signer);
231 GC.KeepAlive(logger);
232 GC.KeepAlive(cur_height);
233 GC.KeepAlive(accept_mpp_keysend);
234 GC.KeepAlive(allow_skimmed_fees);
235 if (ret >= 0 && ret <= 4096) { return null; }
236 Result_PendingHTLCInfoInboundHTLCErrZ ret_hu_conv = Result_PendingHTLCInfoInboundHTLCErrZ.constr_from_ptr(ret);
237 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
238 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
239 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
244 * Fetches the set of [`InitFeatures`] flags that are provided by or required by
245 * [`ChannelManager`].
247 public static InitFeatures provided_init_features(org.ldk.structs.UserConfig config) {
248 long ret = bindings.provided_init_features(config.ptr);
249 GC.KeepAlive(config);
250 if (ret >= 0 && ret <= 4096) { return null; }
251 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
252 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
253 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(config); };
258 * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write
260 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) {
261 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.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(arg_channel_monitors, arg_channel_monitors_conv_16 => arg_channel_monitors_conv_16.ptr))));
263 GC.KeepAlive(arg_entropy_source);
264 GC.KeepAlive(arg_node_signer);
265 GC.KeepAlive(arg_signer_provider);
266 GC.KeepAlive(arg_fee_estimator);
267 GC.KeepAlive(arg_chain_monitor);
268 GC.KeepAlive(arg_tx_broadcaster);
269 GC.KeepAlive(arg_router);
270 GC.KeepAlive(arg_logger);
271 GC.KeepAlive(arg_default_config);
272 GC.KeepAlive(arg_channel_monitors);
273 if (ret >= 0 && ret <= 4096) { return null; }
274 Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
275 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_entropy_source); };
276 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_node_signer); };
277 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_signer_provider); };
278 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_fee_estimator); };
279 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_chain_monitor); };
280 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_tx_broadcaster); };
281 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_router); };
282 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_logger); };
283 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_default_config); };
284 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); }; };
289 * Adds a tweak to a public key to derive a new public key.
291 * May panic if `tweak` is not the output of a SHA-256 hash.
293 public static byte[] add_public_key_tweak(byte[] base_point, byte[] tweak) {
294 long ret = bindings.add_public_key_tweak(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(base_point, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(tweak, 32)));
295 GC.KeepAlive(base_point);
297 if (ret >= 0 && ret <= 4096) { return null; }
298 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
303 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
304 * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
305 * a `ChannelManager`.
307 * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
308 * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
309 * regenerate it for each new inbound payment.
311 * `current_time` is a Unix timestamp representing the current time.
313 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
314 * on versions of LDK prior to 0.0.114.
316 * [phantom node payments]: crate::sign::PhantomKeysManager
317 * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material
319 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) {
320 long ret = bindings.create(keys.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, entropy_source.ptr, current_time, min_final_cltv_expiry_delta.ptr);
322 GC.KeepAlive(min_value_msat);
323 GC.KeepAlive(invoice_expiry_delta_secs);
324 GC.KeepAlive(entropy_source);
325 GC.KeepAlive(current_time);
326 GC.KeepAlive(min_final_cltv_expiry_delta);
327 if (ret >= 0 && ret <= 4096) { return null; }
328 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
329 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
330 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
331 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
332 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
337 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
338 * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
339 * without a `ChannelManager`.
341 * See [`create`] for information on the `keys` and `current_time` parameters.
343 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
344 * on versions of LDK prior to 0.0.114.
346 * [phantom node payments]: crate::sign::PhantomKeysManager
348 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) {
349 long ret = bindings.create_from_hash(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);
351 GC.KeepAlive(min_value_msat);
352 GC.KeepAlive(payment_hash);
353 GC.KeepAlive(invoice_expiry_delta_secs);
354 GC.KeepAlive(current_time);
355 GC.KeepAlive(min_final_cltv_expiry_delta);
356 if (ret >= 0 && ret <= 4096) { return null; }
357 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
358 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
359 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
360 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
365 * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
367 * The host part must end with \".onion\".
369 public static Result_SocketAddressSocketAddressParseErrorZ parse_onion_address(string host, short port) {
370 long ret = bindings.parse_onion_address(InternalUtils.encodeString(host), port);
373 if (ret >= 0 && ret <= 4096) { return null; }
374 Result_SocketAddressSocketAddressParseErrorZ ret_hu_conv = Result_SocketAddressSocketAddressParseErrorZ.constr_from_ptr(ret);
379 * Gets the weight for an HTLC-Success transaction.
381 public static long htlc_success_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
382 long ret = bindings.htlc_success_tx_weight(channel_type_features.ptr);
383 GC.KeepAlive(channel_type_features);
388 * Gets the weight for an HTLC-Timeout transaction.
390 public static long htlc_timeout_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
391 long ret = bindings.htlc_timeout_tx_weight(channel_type_features.ptr);
392 GC.KeepAlive(channel_type_features);
397 * Check if a given input witness attempts to claim a HTLC.
399 public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
400 long ret = bindings.HTLCClaim_from_witness(InternalUtils.encodeUint8Array(witness));
401 GC.KeepAlive(witness);
402 if (ret >= 0 && ret <= 4096) { return null; }
403 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
404 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
409 * Build the commitment secret from the seed and the commitment number
411 public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
412 long ret = bindings.build_commitment_secret(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_seed, 32)), idx);
413 GC.KeepAlive(commitment_seed);
415 if (ret >= 0 && ret <= 4096) { return null; }
416 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
421 * Build a closing transaction
423 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) {
424 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.ptr);
425 GC.KeepAlive(to_holder_value_sat);
426 GC.KeepAlive(to_counterparty_value_sat);
427 GC.KeepAlive(to_holder_script);
428 GC.KeepAlive(to_counterparty_script);
429 GC.KeepAlive(funding_outpoint);
430 if (ret >= 0 && ret <= 4096) { return null; }
431 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
436 * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
437 * from the base secret and the per_commitment_point.
439 public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
440 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)));
441 GC.KeepAlive(per_commitment_point);
442 GC.KeepAlive(base_secret);
443 if (ret >= 0 && ret <= 4096) { return null; }
444 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
449 * Derives a per-commitment-transaction revocation key from its constituent parts.
451 * Only the cheating participant owns a valid witness to propagate a revoked
452 * commitment transaction, thus per_commitment_secret always come from cheater
453 * and revocation_base_secret always come from punisher, which is the broadcaster
454 * of the transaction spending with this key knowledge.
456 public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
457 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)));
458 GC.KeepAlive(per_commitment_secret);
459 GC.KeepAlive(countersignatory_revocation_base_secret);
460 if (ret >= 0 && ret <= 4096) { return null; }
461 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
466 * A script either spendable by the revocation
467 * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
468 * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
470 public static byte[] get_revokeable_redeemscript(org.ldk.structs.RevocationKey revocation_key, short contest_delay, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key) {
471 long ret = bindings.get_revokeable_redeemscript(revocation_key.ptr, contest_delay, broadcaster_delayed_payment_key.ptr);
472 GC.KeepAlive(revocation_key);
473 GC.KeepAlive(contest_delay);
474 GC.KeepAlive(broadcaster_delayed_payment_key);
475 if (ret >= 0 && ret <= 4096) { return null; }
476 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
481 * Returns the script for the counterparty's output on a holder's commitment transaction based on
484 public static byte[] get_counterparty_payment_script(org.ldk.structs.ChannelTypeFeatures channel_type_features, byte[] payment_key) {
485 long ret = bindings.get_counterparty_payment_script(channel_type_features.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_key, 33)));
486 GC.KeepAlive(channel_type_features);
487 GC.KeepAlive(payment_key);
488 if (ret >= 0 && ret <= 4096) { return null; }
489 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
494 * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
495 * does not need to have its previous_output_index filled.
497 public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.TxCreationKeys keys) {
498 long ret = bindings.get_htlc_redeemscript(htlc.ptr, channel_type_features.ptr, keys.ptr);
500 GC.KeepAlive(channel_type_features);
502 if (ret >= 0 && ret <= 4096) { return null; }
503 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
508 * Gets the redeemscript for a funding output from the two funding public keys.
509 * Note that the order of funding public keys does not matter.
511 public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
512 long ret = bindings.make_funding_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory, 33)));
513 GC.KeepAlive(broadcaster);
514 GC.KeepAlive(countersignatory);
515 if (ret >= 0 && ret <= 4096) { return null; }
516 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
521 * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
522 * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
523 * transaction which needs signing, and can be used to construct an HTLC transaction which is
524 * broadcastable given a counterparty HTLC signature.
526 * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
527 * commitment transaction).
529 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) {
530 long ret = bindings.build_htlc_transaction(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_txid, 32)), feerate_per_kw, contest_delay, htlc.ptr, channel_type_features.ptr, broadcaster_delayed_payment_key.ptr, revocation_key.ptr);
531 GC.KeepAlive(commitment_txid);
532 GC.KeepAlive(feerate_per_kw);
533 GC.KeepAlive(contest_delay);
535 GC.KeepAlive(channel_type_features);
536 GC.KeepAlive(broadcaster_delayed_payment_key);
537 GC.KeepAlive(revocation_key);
538 if (ret >= 0 && ret <= 4096) { return null; }
539 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
544 * Returns the witness required to satisfy and spend a HTLC input.
546 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) {
547 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.ptr);
548 GC.KeepAlive(local_sig);
549 GC.KeepAlive(remote_sig);
550 GC.KeepAlive(preimage);
551 GC.KeepAlive(redeem_script);
552 GC.KeepAlive(channel_type_features);
553 if (ret >= 0 && ret <= 4096) { return null; }
554 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
559 * Gets the witnessScript for the to_remote output when anchors are enabled.
561 public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
562 long ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point, 33)));
563 GC.KeepAlive(payment_point);
564 if (ret >= 0 && ret <= 4096) { return null; }
565 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
570 * Gets the witnessScript for an anchor output from the funding public key.
571 * The witness in the spending input must be:
572 * <BIP 143 funding_signature>
573 * After 16 blocks of confirmation, an alternative satisfying witness could be:
575 * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
577 public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
578 long ret = bindings.get_anchor_redeemscript(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey, 33)));
579 GC.KeepAlive(funding_pubkey);
580 if (ret >= 0 && ret <= 4096) { return null; }
581 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
586 * Returns the witness required to satisfy and spend an anchor input.
588 public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
589 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)));
590 GC.KeepAlive(funding_key);
591 GC.KeepAlive(funding_sig);
592 if (ret >= 0 && ret <= 4096) { return null; }
593 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
598 * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
599 * shared secret first. This prevents on-chain observers from discovering how many commitment
600 * transactions occurred in a channel before it was closed.
602 * This function gets the shared secret from relevant channel public keys and can be used to
603 * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
605 public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, bool outbound_from_broadcaster) {
606 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);
607 GC.KeepAlive(broadcaster_payment_basepoint);
608 GC.KeepAlive(countersignatory_payment_basepoint);
609 GC.KeepAlive(outbound_from_broadcaster);
614 * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
616 public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
617 long ret = bindings.NetworkUpdate_read(InternalUtils.encodeUint8Array(ser));
619 if (ret >= 0 && ret <= 4096) { return null; }
620 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
625 * Verifies the signature of a [`NodeAnnouncement`].
627 * Returns an error if it is invalid.
629 public static Result_NoneLightningErrorZ verify_node_announcement(org.ldk.structs.NodeAnnouncement msg) {
630 long ret = bindings.verify_node_announcement(msg.ptr);
632 if (ret >= 0 && ret <= 4096) { return null; }
633 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
634 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
639 * Verifies all signatures included in a [`ChannelAnnouncement`].
641 * Returns an error if one of the signatures is invalid.
643 public static Result_NoneLightningErrorZ verify_channel_announcement(org.ldk.structs.ChannelAnnouncement msg) {
644 long ret = bindings.verify_channel_announcement(msg.ptr);
646 if (ret >= 0 && ret <= 4096) { return null; }
647 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
648 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
653 * Finds a route from us (payer) to the given target node (payee).
655 * If the payee provided features in their invoice, they should be provided via the `payee` field
656 * in the given [`RouteParameters::payment_params`].
657 * Without this, MPP will only be used if the payee's features are available in the network graph.
659 * Private routing paths between a public node and the target may be included in the `payee` field
660 * of [`RouteParameters::payment_params`].
662 * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
663 * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
664 * from `network_graph` will be ignored, and only those in `first_hops` will be used.
666 * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
667 * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
668 * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
672 * Panics if first_hops contains channels without `short_channel_id`s;
673 * [`ChannelManager::list_usable_channels`] will never include such channels.
675 * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
676 * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
677 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
679 * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
681 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) {
682 long ret = bindings.find_route(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(our_node_pubkey, 33)), route_params.ptr, network_graph.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(first_hops, first_hops_conv_16 => first_hops_conv_16.ptr)), logger.ptr, scorer.ptr, score_params.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(random_seed_bytes, 32)));
683 GC.KeepAlive(our_node_pubkey);
684 GC.KeepAlive(route_params);
685 GC.KeepAlive(network_graph);
686 GC.KeepAlive(first_hops);
687 GC.KeepAlive(logger);
688 GC.KeepAlive(scorer);
689 GC.KeepAlive(score_params);
690 GC.KeepAlive(random_seed_bytes);
691 if (ret >= 0 && ret <= 4096) { return null; }
692 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
693 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
694 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
695 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); }; } };
696 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
697 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(scorer); };
698 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(score_params); };
703 * Construct a route from us (payer) to the target node (payee) via the given hops (which should
704 * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
706 * Re-uses logic from `find_route`, so the restrictions described there also apply here.
708 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) {
709 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.ptr, network_graph.ptr, logger.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(random_seed_bytes, 32)));
710 GC.KeepAlive(our_node_pubkey);
712 GC.KeepAlive(route_params);
713 GC.KeepAlive(network_graph);
714 GC.KeepAlive(logger);
715 GC.KeepAlive(random_seed_bytes);
716 if (ret >= 0 && ret <= 4096) { return null; }
717 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
718 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
719 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
720 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
725 * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
726 * the given outputs, plus an output to the given change destination (if sufficient
727 * change value remains). The PSBT will have a feerate, at least, of the given value.
729 * The `locktime` argument is used to set the transaction's locktime. If `None`, the
730 * transaction will have a locktime of 0. It it recommended to set this to the current block
731 * height to avoid fee sniping, unless you have some specific reason to use a different
734 * Returns the PSBT and expected max transaction weight.
736 * Returns `Err(())` if the output value is greater than the input value minus required fee,
737 * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
738 * does not match the one we can spend.
740 * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
742 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) {
743 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);
744 GC.KeepAlive(descriptors);
745 GC.KeepAlive(outputs);
746 GC.KeepAlive(change_destination_script);
747 GC.KeepAlive(feerate_sat_per_1000_weight);
748 GC.KeepAlive(locktime);
749 if (ret >= 0 && ret <= 4096) { return null; }
750 Result_C2Tuple_CVec_u8Zu64ZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8Zu64ZNoneZ.constr_from_ptr(ret);
751 foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(descriptors_conv_27); }; };
752 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(locktime); };
757 * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
758 * `path`, first calling [`Destination::resolve`] on `path.destination` with the given
759 * [`ReadOnlyNetworkGraph`].
761 * Returns the node id of the peer to send the message to, the message itself, and any addresses
762 * needed to connect to the first node.
764 * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
766 public static Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.NodeIdLookUp node_id_lookup, org.ldk.structs.ReadOnlyNetworkGraph network_graph, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, org.ldk.structs.BlindedPath reply_path) {
767 long ret = bindings.create_onion_message_resolving_destination(entropy_source.ptr, node_signer.ptr, node_id_lookup.ptr, network_graph.ptr, path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
768 GC.KeepAlive(entropy_source);
769 GC.KeepAlive(node_signer);
770 GC.KeepAlive(node_id_lookup);
771 GC.KeepAlive(network_graph);
773 GC.KeepAlive(contents);
774 GC.KeepAlive(reply_path);
775 if (ret >= 0 && ret <= 4096) { return null; }
776 Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
777 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
778 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
779 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_id_lookup); };
780 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
781 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
782 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents); };
783 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reply_path); };
788 * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
791 * Returns the node id of the peer to send the message to, the message itself, and any addresses
792 * needed to connect to the first node.
794 * Returns [`SendError::UnresolvedIntroductionNode`] if:
795 * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`],
796 * - unless it can be resolved by [`NodeIdLookUp::next_node_id`].
797 * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node
798 * first with a [`ReadOnlyNetworkGraph`].
800 * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
802 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.NodeIdLookUp node_id_lookup, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, org.ldk.structs.BlindedPath reply_path) {
803 long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, node_id_lookup.ptr, path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
804 GC.KeepAlive(entropy_source);
805 GC.KeepAlive(node_signer);
806 GC.KeepAlive(node_id_lookup);
808 GC.KeepAlive(contents);
809 GC.KeepAlive(reply_path);
810 if (ret >= 0 && ret <= 4096) { return null; }
811 Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
812 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
813 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
814 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_id_lookup); };
815 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(path); };
816 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents); };
817 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(reply_path); };
822 * Decode one layer of an incoming [`OnionMessage`].
824 * Returns either the next layer of the onion for forwarding or the decrypted content for the
827 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) {
828 long ret = bindings.peel_onion_message(msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
830 GC.KeepAlive(node_signer);
831 GC.KeepAlive(logger);
832 GC.KeepAlive(custom_handler);
833 if (ret >= 0 && ret <= 4096) { return null; }
834 Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
835 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
836 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
837 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
838 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(custom_handler); };
843 * Returns whether `tlv_type` corresponds to a TLV record for Offers.
845 public static bool OffersMessage_is_known_type(long tlv_type) {
846 bool ret = bindings.OffersMessage_is_known_type(tlv_type);
847 GC.KeepAlive(tlv_type);
852 * Create a one-hop blinded path for a payment.
854 public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, short min_final_cltv_expiry_delta, org.ldk.structs.EntropySource entropy_source) {
855 long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_node_id, 33)), payee_tlvs.ptr, min_final_cltv_expiry_delta, entropy_source.ptr);
856 GC.KeepAlive(payee_node_id);
857 GC.KeepAlive(payee_tlvs);
858 GC.KeepAlive(min_final_cltv_expiry_delta);
859 GC.KeepAlive(entropy_source);
860 if (ret >= 0 && ret <= 4096) { return null; }
861 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
862 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_tlvs); };
863 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
868 * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
871 * a provided node id is invalid
872 * [`BlindedPayInfo`] calculation results in an integer overflow
873 * any unknown features are required in the provided [`ForwardTlvs`]
875 * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
877 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, short min_final_cltv_expiry_delta, org.ldk.structs.EntropySource entropy_source) {
878 long ret = bindings.BlindedPath_new_for_payment(InternalUtils.encodeUint64Array(InternalUtils.mapArray(intermediate_nodes, intermediate_nodes_conv_13 => intermediate_nodes_conv_13.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payee_node_id, 33)), payee_tlvs.ptr, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source.ptr);
879 GC.KeepAlive(intermediate_nodes);
880 GC.KeepAlive(payee_node_id);
881 GC.KeepAlive(payee_tlvs);
882 GC.KeepAlive(htlc_maximum_msat);
883 GC.KeepAlive(min_final_cltv_expiry_delta);
884 GC.KeepAlive(entropy_source);
885 if (ret >= 0 && ret <= 4096) { return null; }
886 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
887 foreach (ForwardNode intermediate_nodes_conv_13 in intermediate_nodes) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(intermediate_nodes_conv_13); }; };
888 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payee_tlvs); };
889 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
894 * Read a PathFailure from a byte array, created by PathFailure_write
896 public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
897 long ret = bindings.PathFailure_read(InternalUtils.encodeUint8Array(ser));
899 if (ret >= 0 && ret <= 4096) { return null; }
900 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
905 * Read a ClosureReason from a byte array, created by ClosureReason_write
907 public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
908 long ret = bindings.ClosureReason_read(InternalUtils.encodeUint8Array(ser));
910 if (ret >= 0 && ret <= 4096) { return null; }
911 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
916 * Read a HTLCDestination from a byte array, created by HTLCDestination_write
918 public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
919 long ret = bindings.HTLCDestination_read(InternalUtils.encodeUint8Array(ser));
921 if (ret >= 0 && ret <= 4096) { return null; }
922 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
927 * Read a Event from a byte array, created by Event_write
929 public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
930 long ret = bindings.Event_read(InternalUtils.encodeUint8Array(ser));
932 if (ret >= 0 && ret <= 4096) { return null; }
933 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
938 * Builds the necessary parameters to pay or pre-flight probe the given zero-amount
939 * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
940 * [`ChannelManager::send_preflight_probes`].
942 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
943 * same [`PaymentHash`] has never been paid before.
945 * Will always succeed unless the invoice has an amount specified, in which case
946 * [`payment_parameters_from_invoice`] should be used.
948 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
949 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
951 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat) {
952 long ret = bindings.payment_parameters_from_zero_amount_invoice(invoice.ptr, amount_msat);
953 GC.KeepAlive(invoice);
954 GC.KeepAlive(amount_msat);
955 if (ret >= 0 && ret <= 4096) { return null; }
956 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
957 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
962 * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using
963 * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`].
965 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
966 * same [`PaymentHash`] has never been paid before.
968 * Will always succeed unless the invoice has no amount specified, in which case
969 * [`payment_parameters_from_zero_amount_invoice`] should be used.
971 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
972 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
974 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(org.ldk.structs.Bolt11Invoice invoice) {
975 long ret = bindings.payment_parameters_from_invoice(invoice.ptr);
976 GC.KeepAlive(invoice);
977 if (ret >= 0 && ret <= 4096) { return null; }
978 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
979 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
984 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
985 * See [`PhantomKeysManager`] for more information on phantom node payments.
987 * `phantom_route_hints` parameter:
988 * Contains channel info for all nodes participating in the phantom invoice
989 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
991 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
992 * updated when a channel becomes disabled or closes
993 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
994 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
997 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
998 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
999 * If `None` is provided for `payment_hash`, then one will be created.
1001 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1002 * in excess of the current time.
1004 * `duration_since_epoch` is the current time since epoch in seconds.
1006 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1007 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
1008 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1009 * confirmations during routing.
1011 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
1012 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
1015 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
1016 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
1017 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
1018 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
1019 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
1020 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1022 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1023 * available and the current time is supplied by the caller.
1025 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) {
1026 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.ptr)), entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
1027 GC.KeepAlive(amt_msat);
1028 GC.KeepAlive(payment_hash);
1029 GC.KeepAlive(description);
1030 GC.KeepAlive(invoice_expiry_delta_secs);
1031 GC.KeepAlive(phantom_route_hints);
1032 GC.KeepAlive(entropy_source);
1033 GC.KeepAlive(node_signer);
1034 GC.KeepAlive(logger);
1035 GC.KeepAlive(network);
1036 GC.KeepAlive(min_final_cltv_expiry_delta);
1037 GC.KeepAlive(duration_since_epoch);
1038 if (ret >= 0 && ret <= 4096) { return null; }
1039 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1040 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1041 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
1042 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); }; };
1043 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
1044 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1045 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1046 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1051 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
1052 * See [`PhantomKeysManager`] for more information on phantom node payments.
1054 * `phantom_route_hints` parameter:
1055 * Contains channel info for all nodes participating in the phantom invoice
1056 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
1057 * participating node
1058 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
1059 * updated when a channel becomes disabled or closes
1060 * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
1061 * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
1062 * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
1063 * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
1064 * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
1066 * `description_hash` is a SHA-256 hash of the description text
1068 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
1069 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
1070 * If `None` is provided for `payment_hash`, then one will be created.
1072 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1073 * in excess of the current time.
1075 * `duration_since_epoch` is the current time since epoch in seconds.
1077 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
1078 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
1081 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
1082 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
1083 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
1084 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
1085 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
1087 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1088 * available and the current time is supplied by the caller.
1090 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) {
1091 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, payment_hash.ptr, invoice_expiry_delta_secs, description_hash.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19.ptr)), entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
1092 GC.KeepAlive(amt_msat);
1093 GC.KeepAlive(payment_hash);
1094 GC.KeepAlive(invoice_expiry_delta_secs);
1095 GC.KeepAlive(description_hash);
1096 GC.KeepAlive(phantom_route_hints);
1097 GC.KeepAlive(entropy_source);
1098 GC.KeepAlive(node_signer);
1099 GC.KeepAlive(logger);
1100 GC.KeepAlive(network);
1101 GC.KeepAlive(min_final_cltv_expiry_delta);
1102 GC.KeepAlive(duration_since_epoch);
1103 if (ret >= 0 && ret <= 4096) { return null; }
1104 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
1107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
1108 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); }; };
1109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
1110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1111 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1117 * Utility to construct an invoice. Generally, unless you want to do something like a custom
1118 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1119 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1120 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1121 * that the payment secret is valid when the invoice is paid.
1123 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1124 * in excess of the current time.
1126 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1127 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1128 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1129 * confirmations during routing.
1131 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1133 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) {
1134 long ret = bindings.create_invoice_from_channelmanager(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, InternalUtils.encodeString(description), invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1135 GC.KeepAlive(channelmanager);
1136 GC.KeepAlive(node_signer);
1137 GC.KeepAlive(logger);
1138 GC.KeepAlive(network);
1139 GC.KeepAlive(amt_msat);
1140 GC.KeepAlive(description);
1141 GC.KeepAlive(invoice_expiry_delta_secs);
1142 GC.KeepAlive(min_final_cltv_expiry_delta);
1143 if (ret >= 0 && ret <= 4096) { return null; }
1144 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1149 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1154 * Utility to construct an invoice. Generally, unless you want to do something like a custom
1155 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1156 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1157 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1158 * that the payment secret is valid when the invoice is paid.
1159 * Use this variant if you want to pass the `description_hash` to the invoice.
1161 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1162 * in excess of the current time.
1164 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1165 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1166 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1167 * confirmations during routing.
1169 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1171 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) {
1172 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1173 GC.KeepAlive(channelmanager);
1174 GC.KeepAlive(node_signer);
1175 GC.KeepAlive(logger);
1176 GC.KeepAlive(network);
1177 GC.KeepAlive(amt_msat);
1178 GC.KeepAlive(description_hash);
1179 GC.KeepAlive(invoice_expiry_delta_secs);
1180 GC.KeepAlive(min_final_cltv_expiry_delta);
1181 if (ret >= 0 && ret <= 4096) { return null; }
1182 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1185 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1187 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
1188 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1193 * See [`create_invoice_from_channelmanager_with_description_hash`]
1194 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1195 * available and the current time is supplied by the caller.
1197 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) {
1198 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash.ptr, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1199 GC.KeepAlive(channelmanager);
1200 GC.KeepAlive(node_signer);
1201 GC.KeepAlive(logger);
1202 GC.KeepAlive(network);
1203 GC.KeepAlive(amt_msat);
1204 GC.KeepAlive(description_hash);
1205 GC.KeepAlive(duration_since_epoch);
1206 GC.KeepAlive(invoice_expiry_delta_secs);
1207 GC.KeepAlive(min_final_cltv_expiry_delta);
1208 if (ret >= 0 && ret <= 4096) { return null; }
1209 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1213 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1214 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
1215 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1220 * See [`create_invoice_from_channelmanager`]
1221 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1222 * available and the current time is supplied by the caller.
1224 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) {
1225 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(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);
1226 GC.KeepAlive(channelmanager);
1227 GC.KeepAlive(node_signer);
1228 GC.KeepAlive(logger);
1229 GC.KeepAlive(network);
1230 GC.KeepAlive(amt_msat);
1231 GC.KeepAlive(description);
1232 GC.KeepAlive(duration_since_epoch);
1233 GC.KeepAlive(invoice_expiry_delta_secs);
1234 GC.KeepAlive(min_final_cltv_expiry_delta);
1235 if (ret >= 0 && ret <= 4096) { return null; }
1236 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1237 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1238 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1239 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1240 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1241 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1246 * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1247 * This version allows for providing a custom [`PaymentHash`] for the invoice.
1248 * This may be useful if you're building an on-chain swap or involving another protocol where
1249 * the payment hash is also involved outside the scope of lightning.
1251 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) {
1252 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(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);
1253 GC.KeepAlive(channelmanager);
1254 GC.KeepAlive(node_signer);
1255 GC.KeepAlive(logger);
1256 GC.KeepAlive(network);
1257 GC.KeepAlive(amt_msat);
1258 GC.KeepAlive(description);
1259 GC.KeepAlive(duration_since_epoch);
1260 GC.KeepAlive(invoice_expiry_delta_secs);
1261 GC.KeepAlive(payment_hash);
1262 GC.KeepAlive(min_final_cltv_expiry_delta);
1263 if (ret >= 0 && ret <= 4096) { return null; }
1264 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1265 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1266 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1267 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1268 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1269 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };