1 package org.ldk.structs;
2 import org.ldk.impl.bindings;
3 import org.ldk.enums.*;
5 import java.util.Arrays;
6 import java.lang.ref.Reference;
7 import javax.annotation.Nullable;
9 public class UtilMethods {
11 * Gets the 128-bit integer, as 16 little-endian bytes
13 public static byte[] U128_le_bytes(org.ldk.util.UInt128 val) {
14 byte[] ret = bindings.U128_le_bytes(val.getLEBytes());
15 Reference.reachabilityFence(val);
20 * Constructs a new U128 from 16 little-endian bytes
22 public static UInt128 U128_new(byte[] le_bytes) {
23 byte[] ret = bindings.U128_new(InternalUtils.check_arr_len(le_bytes, 16));
24 Reference.reachabilityFence(le_bytes);
25 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
30 * Constructs a new COption_NoneZ containing a
32 public static COption_NoneZ COption_NoneZ_some() {
33 COption_NoneZ ret = bindings.COption_NoneZ_some();
38 * Constructs a new COption_NoneZ containing nothing
40 public static COption_NoneZ COption_NoneZ_none() {
41 COption_NoneZ ret = bindings.COption_NoneZ_none();
46 * Read a PathFailure from a byte array, created by PathFailure_write
48 public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
49 long ret = bindings.PathFailure_read(ser);
50 Reference.reachabilityFence(ser);
51 if (ret >= 0 && ret <= 4096) { return null; }
52 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
57 * Read a ClosureReason from a byte array, created by ClosureReason_write
59 public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
60 long ret = bindings.ClosureReason_read(ser);
61 Reference.reachabilityFence(ser);
62 if (ret >= 0 && ret <= 4096) { return null; }
63 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
68 * Read a HTLCDestination from a byte array, created by HTLCDestination_write
70 public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
71 long ret = bindings.HTLCDestination_read(ser);
72 Reference.reachabilityFence(ser);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
79 * Read a Event from a byte array, created by Event_write
81 public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
82 long ret = bindings.Event_read(ser);
83 Reference.reachabilityFence(ser);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
90 * Read a APIError from a byte array, created by APIError_write
92 public static Result_COption_APIErrorZDecodeErrorZ APIError_read(byte[] ser) {
93 long ret = bindings.APIError_read(ser);
94 Reference.reachabilityFence(ser);
95 if (ret >= 0 && ret <= 4096) { return null; }
96 Result_COption_APIErrorZDecodeErrorZ ret_hu_conv = Result_COption_APIErrorZDecodeErrorZ.constr_from_ptr(ret);
101 * Creates a digital signature of a message given a SecretKey, like the node's secret.
102 * 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.
103 * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
105 public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
106 long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
107 Reference.reachabilityFence(msg);
108 Reference.reachabilityFence(sk);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
115 * Recovers the PublicKey of the signer of the message given the message and the signature.
117 public static Result_PublicKeyErrorZ recover_pk(byte[] msg, java.lang.String sig) {
118 long ret = bindings.recover_pk(msg, sig);
119 Reference.reachabilityFence(msg);
120 Reference.reachabilityFence(sig);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
127 * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
130 public static boolean verify(byte[] msg, java.lang.String sig, byte[] pk) {
131 boolean ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
132 Reference.reachabilityFence(msg);
133 Reference.reachabilityFence(sig);
134 Reference.reachabilityFence(pk);
139 * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
141 public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
142 byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
143 Reference.reachabilityFence(hrp_bytes);
144 Reference.reachabilityFence(data_without_signature);
149 * Read a MonitorEvent from a byte array, created by MonitorEvent_write
151 public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
152 long ret = bindings.MonitorEvent_read(ser);
153 Reference.reachabilityFence(ser);
154 if (ret >= 0 && ret <= 4096) { return null; }
155 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
160 * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
162 public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
163 long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg_a == null ? 0 : arg_a.ptr, arg_b == null ? 0 : arg_b.ptr);
164 Reference.reachabilityFence(ser);
165 Reference.reachabilityFence(arg_a);
166 Reference.reachabilityFence(arg_b);
167 if (ret >= 0 && ret <= 4096) { return null; }
168 Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_a); };
170 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_b); };
175 * Fetches the set of [`InitFeatures`] flags which are provided by or required by
176 * [`ChannelManager`].
178 public static InitFeatures provided_init_features(org.ldk.structs.UserConfig _config) {
179 long ret = bindings.provided_init_features(_config == null ? 0 : _config.ptr);
180 Reference.reachabilityFence(_config);
181 if (ret >= 0 && ret <= 4096) { return null; }
182 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(_config); };
189 * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
191 public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_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) {
192 long ret = bindings.C2Tuple_BlockHashChannelManagerZ_read(ser, bindings.ChannelManagerReadArgs_new(arg_entropy_source == null ? 0 : arg_entropy_source.ptr, arg_node_signer == null ? 0 : arg_node_signer.ptr, arg_signer_provider == null ? 0 : arg_signer_provider.ptr, arg_fee_estimator == null ? 0 : arg_fee_estimator.ptr, arg_chain_monitor == null ? 0 : arg_chain_monitor.ptr, arg_tx_broadcaster == null ? 0 : arg_tx_broadcaster.ptr, arg_router == null ? 0 : arg_router.ptr, arg_logger == null ? 0 : arg_logger.ptr, arg_default_config == null ? 0 : arg_default_config.ptr, arg_channel_monitors != null ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr).toArray() : null));
193 Reference.reachabilityFence(ser);
194 Reference.reachabilityFence(arg_entropy_source);
195 Reference.reachabilityFence(arg_node_signer);
196 Reference.reachabilityFence(arg_signer_provider);
197 Reference.reachabilityFence(arg_fee_estimator);
198 Reference.reachabilityFence(arg_chain_monitor);
199 Reference.reachabilityFence(arg_tx_broadcaster);
200 Reference.reachabilityFence(arg_router);
201 Reference.reachabilityFence(arg_logger);
202 Reference.reachabilityFence(arg_default_config);
203 Reference.reachabilityFence(arg_channel_monitors);
204 if (ret >= 0 && ret <= 4096) { return null; }
205 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
206 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_entropy_source); };
207 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_node_signer); };
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_signer_provider); };
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_fee_estimator); };
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_chain_monitor); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_tx_broadcaster); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_router); };
213 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_logger); };
214 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_default_config); };
215 for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); }; };
220 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
221 * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
222 * a `ChannelManager`.
224 * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
225 * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
226 * regenerate it for each new inbound payment.
228 * `current_time` is a Unix timestamp representing the current time.
230 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
231 * on versions of LDK prior to 0.0.114.
233 * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
234 * [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material
236 public static Result_C2Tuple_PaymentHashPaymentSecretZNoneZ 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) {
237 long ret = bindings.create(keys == null ? 0 : keys.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, entropy_source == null ? 0 : entropy_source.ptr, current_time, min_final_cltv_expiry_delta.ptr);
238 Reference.reachabilityFence(keys);
239 Reference.reachabilityFence(min_value_msat);
240 Reference.reachabilityFence(invoice_expiry_delta_secs);
241 Reference.reachabilityFence(entropy_source);
242 Reference.reachabilityFence(current_time);
243 Reference.reachabilityFence(min_final_cltv_expiry_delta);
244 if (ret >= 0 && ret <= 4096) { return null; }
245 Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
246 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
247 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
248 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
249 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
254 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
255 * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
256 * without a `ChannelManager`.
258 * See [`create`] for information on the `keys` and `current_time` parameters.
260 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
261 * on versions of LDK prior to 0.0.114.
263 * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
265 public static Result_PaymentSecretNoneZ 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) {
266 long ret = bindings.create_from_hash(keys == null ? 0 : keys.ptr, min_value_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), invoice_expiry_delta_secs, current_time, min_final_cltv_expiry_delta.ptr);
267 Reference.reachabilityFence(keys);
268 Reference.reachabilityFence(min_value_msat);
269 Reference.reachabilityFence(payment_hash);
270 Reference.reachabilityFence(invoice_expiry_delta_secs);
271 Reference.reachabilityFence(current_time);
272 Reference.reachabilityFence(min_final_cltv_expiry_delta);
273 if (ret >= 0 && ret <= 4096) { return null; }
274 Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
275 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
276 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
277 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
282 * Gets the weight for an HTLC-Success transaction.
284 public static long htlc_success_tx_weight(boolean opt_anchors) {
285 long ret = bindings.htlc_success_tx_weight(opt_anchors);
286 Reference.reachabilityFence(opt_anchors);
291 * Gets the weight for an HTLC-Timeout transaction.
293 public static long htlc_timeout_tx_weight(boolean opt_anchors) {
294 long ret = bindings.htlc_timeout_tx_weight(opt_anchors);
295 Reference.reachabilityFence(opt_anchors);
300 * Check if a given input witness attempts to claim a HTLC.
302 public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
303 long ret = bindings.HTLCClaim_from_witness(witness);
304 Reference.reachabilityFence(witness);
305 if (ret >= 0 && ret <= 4096) { return null; }
306 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
307 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
312 * Build the commitment secret from the seed and the commitment number
314 public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
315 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
316 Reference.reachabilityFence(commitment_seed);
317 Reference.reachabilityFence(idx);
322 * Build a closing transaction
324 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) {
325 byte[] ret = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr);
326 Reference.reachabilityFence(to_holder_value_sat);
327 Reference.reachabilityFence(to_counterparty_value_sat);
328 Reference.reachabilityFence(to_holder_script);
329 Reference.reachabilityFence(to_counterparty_script);
330 Reference.reachabilityFence(funding_outpoint);
335 * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
336 * from the base secret and the per_commitment_point.
338 public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
339 byte[] ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
340 Reference.reachabilityFence(per_commitment_point);
341 Reference.reachabilityFence(base_secret);
346 * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
347 * from the base point and the per_commitment_key. This is the public equivalent of
348 * derive_private_key - using only public keys to derive a public key instead of private keys.
350 public static byte[] derive_public_key(byte[] per_commitment_point, byte[] base_point) {
351 byte[] ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
352 Reference.reachabilityFence(per_commitment_point);
353 Reference.reachabilityFence(base_point);
358 * Derives a per-commitment-transaction revocation key from its constituent parts.
360 * Only the cheating participant owns a valid witness to propagate a revoked
361 * commitment transaction, thus per_commitment_secret always come from cheater
362 * and revocation_base_secret always come from punisher, which is the broadcaster
363 * of the transaction spending with this key knowledge.
365 public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
366 byte[] ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
367 Reference.reachabilityFence(per_commitment_secret);
368 Reference.reachabilityFence(countersignatory_revocation_base_secret);
373 * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
374 * the public equivalend of derive_private_revocation_key - using only public keys to derive a
375 * public key instead of private keys.
377 * Only the cheating participant owns a valid witness to propagate a revoked
378 * commitment transaction, thus per_commitment_point always come from cheater
379 * and revocation_base_point always come from punisher, which is the broadcaster
380 * of the transaction spending with this key knowledge.
382 * Note that this is infallible iff we trust that at least one of the two input keys are randomly
383 * generated (ie our own).
385 public static byte[] derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
386 byte[] ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
387 Reference.reachabilityFence(per_commitment_point);
388 Reference.reachabilityFence(countersignatory_revocation_base_point);
393 * A script either spendable by the revocation
394 * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
395 * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
397 public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
398 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
399 Reference.reachabilityFence(revocation_key);
400 Reference.reachabilityFence(contest_delay);
401 Reference.reachabilityFence(broadcaster_delayed_payment_key);
406 * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
407 * does not need to have its previous_output_index filled.
409 public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, boolean opt_anchors, org.ldk.structs.TxCreationKeys keys) {
410 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr, opt_anchors, keys == null ? 0 : keys.ptr);
411 Reference.reachabilityFence(htlc);
412 Reference.reachabilityFence(opt_anchors);
413 Reference.reachabilityFence(keys);
418 * Gets the redeemscript for a funding output from the two funding public keys.
419 * Note that the order of funding public keys does not matter.
421 public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
422 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
423 Reference.reachabilityFence(broadcaster);
424 Reference.reachabilityFence(countersignatory);
429 * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
430 * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
431 * transaction which needs signing, and can be used to construct an HTLC transaction which is
432 * broadcastable given a counterparty HTLC signature.
434 * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
435 * commitment transaction).
437 public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, org.ldk.structs.HTLCOutputInCommitment htlc, boolean opt_anchors, boolean use_non_zero_fee_anchors, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
438 byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr, opt_anchors, use_non_zero_fee_anchors, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
439 Reference.reachabilityFence(commitment_txid);
440 Reference.reachabilityFence(feerate_per_kw);
441 Reference.reachabilityFence(contest_delay);
442 Reference.reachabilityFence(htlc);
443 Reference.reachabilityFence(opt_anchors);
444 Reference.reachabilityFence(use_non_zero_fee_anchors);
445 Reference.reachabilityFence(broadcaster_delayed_payment_key);
446 Reference.reachabilityFence(revocation_key);
451 * Returns the witness required to satisfy and spend a HTLC input.
453 * Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
455 public static byte[] build_htlc_input_witness(byte[] local_sig, byte[] remote_sig, @Nullable byte[] preimage, byte[] redeem_script, boolean opt_anchors) {
456 byte[] ret = bindings.build_htlc_input_witness(InternalUtils.check_arr_len(local_sig, 64), InternalUtils.check_arr_len(remote_sig, 64), InternalUtils.check_arr_len(preimage, 32), redeem_script, opt_anchors);
457 Reference.reachabilityFence(local_sig);
458 Reference.reachabilityFence(remote_sig);
459 Reference.reachabilityFence(preimage);
460 Reference.reachabilityFence(redeem_script);
461 Reference.reachabilityFence(opt_anchors);
466 * Gets the witnessScript for the to_remote output when anchors are enabled.
468 public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
469 byte[] ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.check_arr_len(payment_point, 33));
470 Reference.reachabilityFence(payment_point);
475 * Gets the witnessScript for an anchor output from the funding public key.
476 * The witness in the spending input must be:
477 * <BIP 143 funding_signature>
478 * After 16 blocks of confirmation, an alternative satisfying witness could be:
480 * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
482 public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
483 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
484 Reference.reachabilityFence(funding_pubkey);
489 * Returns the witness required to satisfy and spend an anchor input.
491 public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
492 byte[] ret = bindings.build_anchor_input_witness(InternalUtils.check_arr_len(funding_key, 33), InternalUtils.check_arr_len(funding_sig, 64));
493 Reference.reachabilityFence(funding_key);
494 Reference.reachabilityFence(funding_sig);
499 * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
500 * shared secret first. This prevents on-chain observers from discovering how many commitment
501 * transactions occurred in a channel before it was closed.
503 * This function gets the shared secret from relevant channel public keys and can be used to
504 * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
506 public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
507 long ret = bindings.get_commitment_transaction_number_obscure_factor(InternalUtils.check_arr_len(broadcaster_payment_basepoint, 33), InternalUtils.check_arr_len(countersignatory_payment_basepoint, 33), outbound_from_broadcaster);
508 Reference.reachabilityFence(broadcaster_payment_basepoint);
509 Reference.reachabilityFence(countersignatory_payment_basepoint);
510 Reference.reachabilityFence(outbound_from_broadcaster);
515 * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
517 public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
518 long ret = bindings.NetworkUpdate_read(ser);
519 Reference.reachabilityFence(ser);
520 if (ret >= 0 && ret <= 4096) { return null; }
521 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
526 * Finds a route from us (payer) to the given target node (payee).
528 * If the payee provided features in their invoice, they should be provided via `params.payee`.
529 * Without this, MPP will only be used if the payee's features are available in the network graph.
531 * Private routing paths between a public node and the target may be included in `params.payee`.
533 * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
534 * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
535 * from `network_graph` will be ignored, and only those in `first_hops` will be used.
537 * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
538 * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
539 * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
543 * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
544 * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
549 * Panics if first_hops contains channels without short_channel_ids;
550 * [`ChannelManager::list_usable_channels`] will never include such channels.
552 * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
553 * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
554 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
556 * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
558 public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, @Nullable ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.Score scorer, byte[] random_seed_bytes) {
559 long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr).toArray() : null, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
560 Reference.reachabilityFence(our_node_pubkey);
561 Reference.reachabilityFence(route_params);
562 Reference.reachabilityFence(network_graph);
563 Reference.reachabilityFence(first_hops);
564 Reference.reachabilityFence(logger);
565 Reference.reachabilityFence(scorer);
566 Reference.reachabilityFence(random_seed_bytes);
567 if (ret >= 0 && ret <= 4096) { return null; }
568 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
569 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
570 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
571 if (first_hops != null) { for (ChannelDetails first_hops_conv_16: first_hops) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); }; } };
572 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
573 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(scorer); };
578 * Construct a route from us (payer) to the target node (payee) via the given hops (which should
579 * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
581 * Re-uses logic from `find_route`, so the restrictions described there also apply here.
583 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) {
584 long ret = bindings.build_route_from_hops(InternalUtils.check_arr_len(our_node_pubkey, 33), hops != null ? Arrays.stream(hops).map(hops_conv_8 -> InternalUtils.check_arr_len(hops_conv_8, 33)).toArray(byte[][]::new) : null, route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, logger == null ? 0 : logger.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
585 Reference.reachabilityFence(our_node_pubkey);
586 Reference.reachabilityFence(hops);
587 Reference.reachabilityFence(route_params);
588 Reference.reachabilityFence(network_graph);
589 Reference.reachabilityFence(logger);
590 Reference.reachabilityFence(random_seed_bytes);
591 if (ret >= 0 && ret <= 4096) { return null; }
592 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
593 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
594 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
595 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
600 * Pays the given [`Invoice`], retrying if needed based on [`Retry`].
602 * [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
603 * as the payment is still pending. Once the payment completes or fails, you must ensure that
604 * a second payment with the same [`PaymentHash`] is never sent.
606 * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
608 public static Result_PaymentIdPaymentErrorZ pay_invoice(org.ldk.structs.Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
609 long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
610 Reference.reachabilityFence(invoice);
611 Reference.reachabilityFence(retry_strategy);
612 Reference.reachabilityFence(channelmanager);
613 if (ret >= 0 && ret <= 4096) { return null; }
614 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
615 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
616 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
617 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
622 * Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`].
624 * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
625 * payment completes or fails, no idempotency guarantees are made.
627 * You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`]
628 * has never been paid before.
630 * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
632 public static Result_NonePaymentErrorZ pay_invoice_with_id(org.ldk.structs.Invoice invoice, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
633 long ret = bindings.pay_invoice_with_id(invoice == null ? 0 : invoice.ptr, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
634 Reference.reachabilityFence(invoice);
635 Reference.reachabilityFence(payment_id);
636 Reference.reachabilityFence(retry_strategy);
637 Reference.reachabilityFence(channelmanager);
638 if (ret >= 0 && ret <= 4096) { return null; }
639 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
640 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
641 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
642 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
647 * Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on
650 * [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
651 * as the payment is still pending. Once the payment completes or fails, you must ensure that
652 * a second payment with the same [`PaymentHash`] is never sent.
654 * If you wish to use a different payment idempotency token, see
655 * [`pay_zero_value_invoice_with_id`].
657 public static Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
658 long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
659 Reference.reachabilityFence(invoice);
660 Reference.reachabilityFence(amount_msats);
661 Reference.reachabilityFence(retry_strategy);
662 Reference.reachabilityFence(channelmanager);
663 if (ret >= 0 && ret <= 4096) { return null; }
664 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
665 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
666 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
667 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
672 * Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key,
673 * , retrying if needed based on [`Retry`].
675 * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
676 * payment completes or fails, no idempotency guarantees are made.
678 * You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`]
679 * has never been paid before.
681 * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
684 public static Result_NonePaymentErrorZ pay_zero_value_invoice_with_id(org.ldk.structs.Invoice invoice, long amount_msats, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
685 long ret = bindings.pay_zero_value_invoice_with_id(invoice == null ? 0 : invoice.ptr, amount_msats, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
686 Reference.reachabilityFence(invoice);
687 Reference.reachabilityFence(amount_msats);
688 Reference.reachabilityFence(payment_id);
689 Reference.reachabilityFence(retry_strategy);
690 Reference.reachabilityFence(channelmanager);
691 if (ret >= 0 && ret <= 4096) { return null; }
692 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
693 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
694 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
695 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
700 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
701 * See [`PhantomKeysManager`] for more information on phantom node payments.
703 * `phantom_route_hints` parameter:
704 * Contains channel info for all nodes participating in the phantom invoice
705 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
707 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
708 * updated when a channel becomes disabled or closes
709 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
710 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
713 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
714 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
715 * If `None` is provided for `payment_hash`, then one will be created.
717 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
718 * in excess of the current time.
720 * `duration_since_epoch` is the current time since epoch in seconds.
722 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
723 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
724 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
725 * confirmations during routing.
727 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
728 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
731 * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
732 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
733 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
734 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
735 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
736 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
738 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
739 * available and the current time is supplied by the caller.
741 * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
743 public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, @Nullable byte[] payment_hash, java.lang.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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
744 long ret = bindings.create_phantom_invoice(amt_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), description, invoice_expiry_delta_secs, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source == null ? 0 : entropy_source.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
745 Reference.reachabilityFence(amt_msat);
746 Reference.reachabilityFence(payment_hash);
747 Reference.reachabilityFence(description);
748 Reference.reachabilityFence(invoice_expiry_delta_secs);
749 Reference.reachabilityFence(phantom_route_hints);
750 Reference.reachabilityFence(entropy_source);
751 Reference.reachabilityFence(node_signer);
752 Reference.reachabilityFence(logger);
753 Reference.reachabilityFence(network);
754 Reference.reachabilityFence(min_final_cltv_expiry_delta);
755 Reference.reachabilityFence(duration_since_epoch);
756 if (ret >= 0 && ret <= 4096) { return null; }
757 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
758 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
759 for (PhantomRouteHints phantom_route_hints_conv_19: phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(phantom_route_hints_conv_19); }; };
760 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
761 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
762 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
763 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
768 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
769 * See [`PhantomKeysManager`] for more information on phantom node payments.
771 * `phantom_route_hints` parameter:
772 * Contains channel info for all nodes participating in the phantom invoice
773 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
775 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
776 * updated when a channel becomes disabled or closes
777 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
778 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
781 * `description_hash` is a SHA-256 hash of the description text
783 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
784 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
785 * If `None` is provided for `payment_hash`, then one will be created.
787 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
788 * in excess of the current time.
790 * `duration_since_epoch` is the current time since epoch in seconds.
792 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
793 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
796 * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
797 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
798 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
799 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
800 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
802 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
803 * available and the current time is supplied by the caller.
805 * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
807 public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(org.ldk.structs.Option_u64Z amt_msat, @Nullable byte[] 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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
808 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), invoice_expiry_delta_secs, description_hash == null ? 0 : description_hash.ptr, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source == null ? 0 : entropy_source.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
809 Reference.reachabilityFence(amt_msat);
810 Reference.reachabilityFence(payment_hash);
811 Reference.reachabilityFence(invoice_expiry_delta_secs);
812 Reference.reachabilityFence(description_hash);
813 Reference.reachabilityFence(phantom_route_hints);
814 Reference.reachabilityFence(entropy_source);
815 Reference.reachabilityFence(node_signer);
816 Reference.reachabilityFence(logger);
817 Reference.reachabilityFence(network);
818 Reference.reachabilityFence(min_final_cltv_expiry_delta);
819 Reference.reachabilityFence(duration_since_epoch);
820 if (ret >= 0 && ret <= 4096) { return null; }
821 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
822 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
823 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
824 for (PhantomRouteHints phantom_route_hints_conv_19: phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(phantom_route_hints_conv_19); }; };
825 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
826 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
827 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
828 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
833 * Utility to construct an invoice. Generally, unless you want to do something like a custom
834 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
835 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
836 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
837 * that the payment secret is valid when the invoice is paid.
839 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
840 * in excess of the current time.
842 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
843 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
844 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
845 * confirmations during routing.
847 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
849 public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.Currency network, org.ldk.structs.Option_u64Z amt_msat, java.lang.String description, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
850 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
851 Reference.reachabilityFence(channelmanager);
852 Reference.reachabilityFence(node_signer);
853 Reference.reachabilityFence(logger);
854 Reference.reachabilityFence(network);
855 Reference.reachabilityFence(amt_msat);
856 Reference.reachabilityFence(description);
857 Reference.reachabilityFence(invoice_expiry_delta_secs);
858 Reference.reachabilityFence(min_final_cltv_expiry_delta);
859 if (ret >= 0 && ret <= 4096) { return null; }
860 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
861 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
862 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
863 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
864 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
865 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
870 * Utility to construct an invoice. Generally, unless you want to do something like a custom
871 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
872 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
873 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
874 * that the payment secret is valid when the invoice is paid.
875 * Use this variant if you want to pass the `description_hash` to the invoice.
877 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
878 * in excess of the current time.
880 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
881 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
882 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
883 * confirmations during routing.
885 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
887 public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.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) {
888 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
889 Reference.reachabilityFence(channelmanager);
890 Reference.reachabilityFence(node_signer);
891 Reference.reachabilityFence(logger);
892 Reference.reachabilityFence(network);
893 Reference.reachabilityFence(amt_msat);
894 Reference.reachabilityFence(description_hash);
895 Reference.reachabilityFence(invoice_expiry_delta_secs);
896 Reference.reachabilityFence(min_final_cltv_expiry_delta);
897 if (ret >= 0 && ret <= 4096) { return null; }
898 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
899 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
900 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
901 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
902 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
903 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
904 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
909 * See [`create_invoice_from_channelmanager_with_description_hash`]
910 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
911 * available and the current time is supplied by the caller.
913 public static Result_InvoiceSignOrCreationErrorZ 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, org.ldk.enums.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) {
914 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : 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);
915 Reference.reachabilityFence(channelmanager);
916 Reference.reachabilityFence(node_signer);
917 Reference.reachabilityFence(logger);
918 Reference.reachabilityFence(network);
919 Reference.reachabilityFence(amt_msat);
920 Reference.reachabilityFence(description_hash);
921 Reference.reachabilityFence(duration_since_epoch);
922 Reference.reachabilityFence(invoice_expiry_delta_secs);
923 Reference.reachabilityFence(min_final_cltv_expiry_delta);
924 if (ret >= 0 && ret <= 4096) { return null; }
925 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
926 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
927 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
928 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
929 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
930 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
931 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
936 * See [`create_invoice_from_channelmanager`]
937 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
938 * available and the current time is supplied by the caller.
940 public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.enums.Currency network, org.ldk.structs.Option_u64Z amt_msat, java.lang.String description, long duration_since_epoch, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
941 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
942 Reference.reachabilityFence(channelmanager);
943 Reference.reachabilityFence(node_signer);
944 Reference.reachabilityFence(logger);
945 Reference.reachabilityFence(network);
946 Reference.reachabilityFence(amt_msat);
947 Reference.reachabilityFence(description);
948 Reference.reachabilityFence(duration_since_epoch);
949 Reference.reachabilityFence(invoice_expiry_delta_secs);
950 Reference.reachabilityFence(min_final_cltv_expiry_delta);
951 if (ret >= 0 && ret <= 4096) { return null; }
952 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
953 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
954 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
955 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
956 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
957 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
962 * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
963 * This version allows for providing a custom [`PaymentHash`] for the invoice.
964 * This may be useful if you're building an on-chain swap or involving another protocol where
965 * the payment hash is also involved outside the scope of lightning.
967 public static Result_InvoiceSignOrCreationErrorZ 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, org.ldk.enums.Currency network, org.ldk.structs.Option_u64Z amt_msat, java.lang.String description, long duration_since_epoch, int invoice_expiry_delta_secs, byte[] payment_hash, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
968 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.check_arr_len(payment_hash, 32), min_final_cltv_expiry_delta.ptr);
969 Reference.reachabilityFence(channelmanager);
970 Reference.reachabilityFence(node_signer);
971 Reference.reachabilityFence(logger);
972 Reference.reachabilityFence(network);
973 Reference.reachabilityFence(amt_msat);
974 Reference.reachabilityFence(description);
975 Reference.reachabilityFence(duration_since_epoch);
976 Reference.reachabilityFence(invoice_expiry_delta_secs);
977 Reference.reachabilityFence(payment_hash);
978 Reference.reachabilityFence(min_final_cltv_expiry_delta);
979 if (ret >= 0 && ret <= 4096) { return null; }
980 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
981 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
982 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
983 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
984 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
985 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };