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 APIError from a byte array, created by APIError_write
48 public static Result_COption_APIErrorZDecodeErrorZ APIError_read(byte[] ser) {
49 long ret = bindings.APIError_read(ser);
50 Reference.reachabilityFence(ser);
51 if (ret >= 0 && ret <= 4096) { return null; }
52 Result_COption_APIErrorZDecodeErrorZ ret_hu_conv = Result_COption_APIErrorZDecodeErrorZ.constr_from_ptr(ret);
57 * Creates a digital signature of a message given a SecretKey, like the node's secret.
58 * 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.
59 * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
61 public static Result_StrSecp256k1ErrorZ sign(byte[] msg, byte[] sk) {
62 long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
63 Reference.reachabilityFence(msg);
64 Reference.reachabilityFence(sk);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 Result_StrSecp256k1ErrorZ ret_hu_conv = Result_StrSecp256k1ErrorZ.constr_from_ptr(ret);
71 * Recovers the PublicKey of the signer of the message given the message and the signature.
73 public static Result_PublicKeySecp256k1ErrorZ recover_pk(byte[] msg, java.lang.String sig) {
74 long ret = bindings.recover_pk(msg, sig);
75 Reference.reachabilityFence(msg);
76 Reference.reachabilityFence(sig);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
83 * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
86 public static boolean verify(byte[] msg, java.lang.String sig, byte[] pk) {
87 boolean ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
88 Reference.reachabilityFence(msg);
89 Reference.reachabilityFence(sig);
90 Reference.reachabilityFence(pk);
95 * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
97 public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
98 byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
99 Reference.reachabilityFence(hrp_bytes);
100 Reference.reachabilityFence(data_without_signature);
105 * Read previously persisted [`ChannelMonitor`]s from the store.
107 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) {
108 long ret = bindings.read_channel_monitors(kv_store.ptr, entropy_source.ptr, signer_provider.ptr);
109 Reference.reachabilityFence(kv_store);
110 Reference.reachabilityFence(entropy_source);
111 Reference.reachabilityFence(signer_provider);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.constr_from_ptr(ret);
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(kv_store); };
115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(signer_provider); };
121 * Extracts the block height (most significant 3-bytes) from the `short_channel_id`
123 public static int block_from_scid(long short_channel_id) {
124 int ret = bindings.block_from_scid(short_channel_id);
125 Reference.reachabilityFence(short_channel_id);
130 * Extracts the tx index (bytes [2..4]) from the `short_channel_id`
132 public static int tx_index_from_scid(long short_channel_id) {
133 int ret = bindings.tx_index_from_scid(short_channel_id);
134 Reference.reachabilityFence(short_channel_id);
139 * Extracts the vout (bytes [0..2]) from the `short_channel_id`
141 public static short vout_from_scid(long short_channel_id) {
142 short ret = bindings.vout_from_scid(short_channel_id);
143 Reference.reachabilityFence(short_channel_id);
148 * Constructs a `short_channel_id` using the components pieces. Results in an error
149 * if the block height, tx index, or vout index overflow the maximum sizes.
151 public static Result_u64ShortChannelIdErrorZ scid_from_parts(long block, long tx_index, long vout_index) {
152 long ret = bindings.scid_from_parts(block, tx_index, vout_index);
153 Reference.reachabilityFence(block);
154 Reference.reachabilityFence(tx_index);
155 Reference.reachabilityFence(vout_index);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 Result_u64ShortChannelIdErrorZ ret_hu_conv = Result_u64ShortChannelIdErrorZ.constr_from_ptr(ret);
162 * Read a C2Tuple_BestBlockOutputSweeperZ from a byte array, created by C2Tuple_BestBlockOutputSweeperZ_write
164 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) {
165 long ret = bindings.C2Tuple_BestBlockOutputSweeperZ_read(ser, arg_a.ptr, arg_b.ptr, arg_c.ptr, arg_d.ptr, arg_e.ptr, arg_f.ptr, arg_g.ptr);
166 Reference.reachabilityFence(ser);
167 Reference.reachabilityFence(arg_a);
168 Reference.reachabilityFence(arg_b);
169 Reference.reachabilityFence(arg_c);
170 Reference.reachabilityFence(arg_d);
171 Reference.reachabilityFence(arg_e);
172 Reference.reachabilityFence(arg_f);
173 Reference.reachabilityFence(arg_g);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ.constr_from_ptr(ret);
176 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_a); };
177 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_b); };
178 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_c); };
179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_d); };
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_e); };
181 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_f); };
182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_g); };
187 * Read a MonitorEvent from a byte array, created by MonitorEvent_write
189 public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
190 long ret = bindings.MonitorEvent_read(ser);
191 Reference.reachabilityFence(ser);
192 if (ret >= 0 && ret <= 4096) { return null; }
193 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
198 * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write
200 public static Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
201 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser, arg_a.ptr, arg_b.ptr);
202 Reference.reachabilityFence(ser);
203 Reference.reachabilityFence(arg_a);
204 Reference.reachabilityFence(arg_b);
205 if (ret >= 0 && ret <= 4096) { return null; }
206 Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
207 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_a); };
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_b); };
213 * Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information
214 * about the intended next-hop for the HTLC.
216 * This does all the relevant context-free checks that LDK requires for payment relay or
217 * acceptance. If the payment is to be received, and the amount matches the expected amount for
218 * a given invoice, this indicates the [`msgs::UpdateAddHTLC`], once fully committed in the
219 * channel, will generate an [`Event::PaymentClaimable`].
221 * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
223 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, boolean accept_mpp_keysend, boolean allow_skimmed_fees) {
224 long ret = bindings.peel_payment_onion(msg.ptr, node_signer.ptr, logger.ptr, cur_height, accept_mpp_keysend, allow_skimmed_fees);
225 Reference.reachabilityFence(msg);
226 Reference.reachabilityFence(node_signer);
227 Reference.reachabilityFence(logger);
228 Reference.reachabilityFence(cur_height);
229 Reference.reachabilityFence(accept_mpp_keysend);
230 Reference.reachabilityFence(allow_skimmed_fees);
231 if (ret >= 0 && ret <= 4096) { return null; }
232 Result_PendingHTLCInfoInboundHTLCErrZ ret_hu_conv = Result_PendingHTLCInfoInboundHTLCErrZ.constr_from_ptr(ret);
233 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
235 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
240 * Fetches the set of [`InitFeatures`] flags that are provided by or required by
241 * [`ChannelManager`].
243 public static InitFeatures provided_init_features(org.ldk.structs.UserConfig config) {
244 long ret = bindings.provided_init_features(config.ptr);
245 Reference.reachabilityFence(config);
246 if (ret >= 0 && ret <= 4096) { return null; }
247 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
248 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
249 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(config); };
254 * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write
256 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) {
257 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelManagerZ_read(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, arg_channel_monitors != null ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16.ptr).toArray() : null));
258 Reference.reachabilityFence(ser);
259 Reference.reachabilityFence(arg_entropy_source);
260 Reference.reachabilityFence(arg_node_signer);
261 Reference.reachabilityFence(arg_signer_provider);
262 Reference.reachabilityFence(arg_fee_estimator);
263 Reference.reachabilityFence(arg_chain_monitor);
264 Reference.reachabilityFence(arg_tx_broadcaster);
265 Reference.reachabilityFence(arg_router);
266 Reference.reachabilityFence(arg_logger);
267 Reference.reachabilityFence(arg_default_config);
268 Reference.reachabilityFence(arg_channel_monitors);
269 if (ret >= 0 && ret <= 4096) { return null; }
270 Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
271 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_entropy_source); };
272 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_node_signer); };
273 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_signer_provider); };
274 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_fee_estimator); };
275 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_chain_monitor); };
276 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_tx_broadcaster); };
277 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_router); };
278 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_logger); };
279 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_default_config); };
280 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); }; };
285 * Adds a tweak to a public key to derive a new public key.
287 * May panic if `tweak` is not the output of a SHA-256 hash.
289 public static byte[] add_public_key_tweak(byte[] base_point, byte[] tweak) {
290 byte[] ret = bindings.add_public_key_tweak(InternalUtils.check_arr_len(base_point, 33), InternalUtils.check_arr_len(tweak, 32));
291 Reference.reachabilityFence(base_point);
292 Reference.reachabilityFence(tweak);
297 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
298 * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
299 * a `ChannelManager`.
301 * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
302 * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
303 * regenerate it for each new inbound payment.
305 * `current_time` is a Unix timestamp representing the current time.
307 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
308 * on versions of LDK prior to 0.0.114.
310 * [phantom node payments]: crate::sign::PhantomKeysManager
311 * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material
313 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) {
314 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);
315 Reference.reachabilityFence(keys);
316 Reference.reachabilityFence(min_value_msat);
317 Reference.reachabilityFence(invoice_expiry_delta_secs);
318 Reference.reachabilityFence(entropy_source);
319 Reference.reachabilityFence(current_time);
320 Reference.reachabilityFence(min_final_cltv_expiry_delta);
321 if (ret >= 0 && ret <= 4096) { return null; }
322 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
323 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
324 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
325 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
326 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
331 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
332 * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
333 * without a `ChannelManager`.
335 * See [`create`] for information on the `keys` and `current_time` parameters.
337 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
338 * on versions of LDK prior to 0.0.114.
340 * [phantom node payments]: crate::sign::PhantomKeysManager
342 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) {
343 long ret = bindings.create_from_hash(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);
344 Reference.reachabilityFence(keys);
345 Reference.reachabilityFence(min_value_msat);
346 Reference.reachabilityFence(payment_hash);
347 Reference.reachabilityFence(invoice_expiry_delta_secs);
348 Reference.reachabilityFence(current_time);
349 Reference.reachabilityFence(min_final_cltv_expiry_delta);
350 if (ret >= 0 && ret <= 4096) { return null; }
351 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
352 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
353 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
354 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
359 * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
361 * The host part must end with \".onion\".
363 public static Result_SocketAddressSocketAddressParseErrorZ parse_onion_address(java.lang.String host, short port) {
364 long ret = bindings.parse_onion_address(host, port);
365 Reference.reachabilityFence(host);
366 Reference.reachabilityFence(port);
367 if (ret >= 0 && ret <= 4096) { return null; }
368 Result_SocketAddressSocketAddressParseErrorZ ret_hu_conv = Result_SocketAddressSocketAddressParseErrorZ.constr_from_ptr(ret);
373 * Gets the weight for an HTLC-Success transaction.
375 public static long htlc_success_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
376 long ret = bindings.htlc_success_tx_weight(channel_type_features.ptr);
377 Reference.reachabilityFence(channel_type_features);
382 * Gets the weight for an HTLC-Timeout transaction.
384 public static long htlc_timeout_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
385 long ret = bindings.htlc_timeout_tx_weight(channel_type_features.ptr);
386 Reference.reachabilityFence(channel_type_features);
391 * Check if a given input witness attempts to claim a HTLC.
393 public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
394 long ret = bindings.HTLCClaim_from_witness(witness);
395 Reference.reachabilityFence(witness);
396 if (ret >= 0 && ret <= 4096) { return null; }
397 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
398 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
403 * Build the commitment secret from the seed and the commitment number
405 public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
406 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
407 Reference.reachabilityFence(commitment_seed);
408 Reference.reachabilityFence(idx);
413 * Build a closing transaction
415 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) {
416 byte[] ret = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint.ptr);
417 Reference.reachabilityFence(to_holder_value_sat);
418 Reference.reachabilityFence(to_counterparty_value_sat);
419 Reference.reachabilityFence(to_holder_script);
420 Reference.reachabilityFence(to_counterparty_script);
421 Reference.reachabilityFence(funding_outpoint);
426 * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
427 * from the base secret and the per_commitment_point.
429 public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
430 byte[] ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
431 Reference.reachabilityFence(per_commitment_point);
432 Reference.reachabilityFence(base_secret);
437 * Derives a per-commitment-transaction revocation key from its constituent parts.
439 * Only the cheating participant owns a valid witness to propagate a revoked
440 * commitment transaction, thus per_commitment_secret always come from cheater
441 * and revocation_base_secret always come from punisher, which is the broadcaster
442 * of the transaction spending with this key knowledge.
444 public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
445 byte[] ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
446 Reference.reachabilityFence(per_commitment_secret);
447 Reference.reachabilityFence(countersignatory_revocation_base_secret);
452 * A script either spendable by the revocation
453 * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
454 * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
456 public static byte[] get_revokeable_redeemscript(org.ldk.structs.RevocationKey revocation_key, short contest_delay, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key) {
457 byte[] ret = bindings.get_revokeable_redeemscript(revocation_key.ptr, contest_delay, broadcaster_delayed_payment_key.ptr);
458 Reference.reachabilityFence(revocation_key);
459 Reference.reachabilityFence(contest_delay);
460 Reference.reachabilityFence(broadcaster_delayed_payment_key);
465 * Returns the script for the counterparty's output on a holder's commitment transaction based on
468 public static byte[] get_counterparty_payment_script(org.ldk.structs.ChannelTypeFeatures channel_type_features, byte[] payment_key) {
469 byte[] ret = bindings.get_counterparty_payment_script(channel_type_features.ptr, InternalUtils.check_arr_len(payment_key, 33));
470 Reference.reachabilityFence(channel_type_features);
471 Reference.reachabilityFence(payment_key);
476 * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
477 * does not need to have its previous_output_index filled.
479 public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.TxCreationKeys keys) {
480 byte[] ret = bindings.get_htlc_redeemscript(htlc.ptr, channel_type_features.ptr, keys.ptr);
481 Reference.reachabilityFence(htlc);
482 Reference.reachabilityFence(channel_type_features);
483 Reference.reachabilityFence(keys);
488 * Gets the redeemscript for a funding output from the two funding public keys.
489 * Note that the order of funding public keys does not matter.
491 public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
492 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
493 Reference.reachabilityFence(broadcaster);
494 Reference.reachabilityFence(countersignatory);
499 * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
500 * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
501 * transaction which needs signing, and can be used to construct an HTLC transaction which is
502 * broadcastable given a counterparty HTLC signature.
504 * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
505 * commitment transaction).
507 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) {
508 byte[] ret = bindings.build_htlc_transaction(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);
509 Reference.reachabilityFence(commitment_txid);
510 Reference.reachabilityFence(feerate_per_kw);
511 Reference.reachabilityFence(contest_delay);
512 Reference.reachabilityFence(htlc);
513 Reference.reachabilityFence(channel_type_features);
514 Reference.reachabilityFence(broadcaster_delayed_payment_key);
515 Reference.reachabilityFence(revocation_key);
520 * Returns the witness required to satisfy and spend a HTLC input.
522 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) {
523 byte[] ret = bindings.build_htlc_input_witness(InternalUtils.check_arr_len(local_sig, 64), InternalUtils.check_arr_len(remote_sig, 64), preimage.ptr, redeem_script, channel_type_features.ptr);
524 Reference.reachabilityFence(local_sig);
525 Reference.reachabilityFence(remote_sig);
526 Reference.reachabilityFence(preimage);
527 Reference.reachabilityFence(redeem_script);
528 Reference.reachabilityFence(channel_type_features);
533 * Gets the witnessScript for the to_remote output when anchors are enabled.
535 public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
536 byte[] ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.check_arr_len(payment_point, 33));
537 Reference.reachabilityFence(payment_point);
542 * Gets the witnessScript for an anchor output from the funding public key.
543 * The witness in the spending input must be:
544 * <BIP 143 funding_signature>
545 * After 16 blocks of confirmation, an alternative satisfying witness could be:
547 * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
549 public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
550 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
551 Reference.reachabilityFence(funding_pubkey);
556 * Returns the witness required to satisfy and spend an anchor input.
558 public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
559 byte[] ret = bindings.build_anchor_input_witness(InternalUtils.check_arr_len(funding_key, 33), InternalUtils.check_arr_len(funding_sig, 64));
560 Reference.reachabilityFence(funding_key);
561 Reference.reachabilityFence(funding_sig);
566 * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
567 * shared secret first. This prevents on-chain observers from discovering how many commitment
568 * transactions occurred in a channel before it was closed.
570 * This function gets the shared secret from relevant channel public keys and can be used to
571 * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
573 public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
574 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);
575 Reference.reachabilityFence(broadcaster_payment_basepoint);
576 Reference.reachabilityFence(countersignatory_payment_basepoint);
577 Reference.reachabilityFence(outbound_from_broadcaster);
582 * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
584 public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
585 long ret = bindings.NetworkUpdate_read(ser);
586 Reference.reachabilityFence(ser);
587 if (ret >= 0 && ret <= 4096) { return null; }
588 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
593 * Verifies the signature of a [`NodeAnnouncement`].
595 * Returns an error if it is invalid.
597 public static Result_NoneLightningErrorZ verify_node_announcement(org.ldk.structs.NodeAnnouncement msg) {
598 long ret = bindings.verify_node_announcement(msg.ptr);
599 Reference.reachabilityFence(msg);
600 if (ret >= 0 && ret <= 4096) { return null; }
601 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
602 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
607 * Verifies all signatures included in a [`ChannelAnnouncement`].
609 * Returns an error if one of the signatures is invalid.
611 public static Result_NoneLightningErrorZ verify_channel_announcement(org.ldk.structs.ChannelAnnouncement msg) {
612 long ret = bindings.verify_channel_announcement(msg.ptr);
613 Reference.reachabilityFence(msg);
614 if (ret >= 0 && ret <= 4096) { return null; }
615 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
616 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
621 * Finds a route from us (payer) to the given target node (payee).
623 * If the payee provided features in their invoice, they should be provided via the `payee` field
624 * in the given [`RouteParameters::payment_params`].
625 * Without this, MPP will only be used if the payee's features are available in the network graph.
627 * Private routing paths between a public node and the target may be included in the `payee` field
628 * of [`RouteParameters::payment_params`].
630 * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
631 * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
632 * from `network_graph` will be ignored, and only those in `first_hops` will be used.
634 * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
635 * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
636 * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
640 * Panics if first_hops contains channels without `short_channel_id`s;
641 * [`ChannelManager::list_usable_channels`] will never include such channels.
643 * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
644 * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
645 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
647 * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
649 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.ScoreLookUp scorer, org.ldk.structs.ProbabilisticScoringFeeParameters score_params, byte[] random_seed_bytes) {
650 long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), route_params.ptr, network_graph.ptr, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16.ptr).toArray() : null, logger.ptr, scorer.ptr, score_params.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
651 Reference.reachabilityFence(our_node_pubkey);
652 Reference.reachabilityFence(route_params);
653 Reference.reachabilityFence(network_graph);
654 Reference.reachabilityFence(first_hops);
655 Reference.reachabilityFence(logger);
656 Reference.reachabilityFence(scorer);
657 Reference.reachabilityFence(score_params);
658 Reference.reachabilityFence(random_seed_bytes);
659 if (ret >= 0 && ret <= 4096) { return null; }
660 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
661 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
662 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
663 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); }; } };
664 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
665 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(scorer); };
666 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(score_params); };
671 * Construct a route from us (payer) to the target node (payee) via the given hops (which should
672 * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
674 * Re-uses logic from `find_route`, so the restrictions described there also apply here.
676 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) {
677 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.ptr, network_graph.ptr, logger.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
678 Reference.reachabilityFence(our_node_pubkey);
679 Reference.reachabilityFence(hops);
680 Reference.reachabilityFence(route_params);
681 Reference.reachabilityFence(network_graph);
682 Reference.reachabilityFence(logger);
683 Reference.reachabilityFence(random_seed_bytes);
684 if (ret >= 0 && ret <= 4096) { return null; }
685 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
686 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
687 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
688 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
693 * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
694 * the given outputs, plus an output to the given change destination (if sufficient
695 * change value remains). The PSBT will have a feerate, at least, of the given value.
697 * The `locktime` argument is used to set the transaction's locktime. If `None`, the
698 * transaction will have a locktime of 0. It it recommended to set this to the current block
699 * height to avoid fee sniping, unless you have some specific reason to use a different
702 * Returns the PSBT and expected max transaction weight.
704 * Returns `Err(())` if the output value is greater than the input value minus required fee,
705 * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
706 * does not match the one we can spend.
708 * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
710 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) {
711 long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors != null ? Arrays.stream(descriptors).mapToLong(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray() : null, outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_7 -> outputs_conv_7.ptr).toArray() : null, change_destination_script, feerate_sat_per_1000_weight, locktime.ptr);
712 Reference.reachabilityFence(descriptors);
713 Reference.reachabilityFence(outputs);
714 Reference.reachabilityFence(change_destination_script);
715 Reference.reachabilityFence(feerate_sat_per_1000_weight);
716 Reference.reachabilityFence(locktime);
717 if (ret >= 0 && ret <= 4096) { return null; }
718 Result_C2Tuple_CVec_u8Zu64ZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8Zu64ZNoneZ.constr_from_ptr(ret);
719 for (SpendableOutputDescriptor descriptors_conv_27: descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(descriptors_conv_27); }; };
720 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(locktime); };
725 * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
726 * `path`, first calling [`Destination::resolve`] on `path.destination` with the given
727 * [`ReadOnlyNetworkGraph`].
729 * Returns the node id of the peer to send the message to, the message itself, and any addresses
730 * needed to connect to the first node.
732 * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
734 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, @Nullable org.ldk.structs.BlindedPath reply_path) {
735 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);
736 Reference.reachabilityFence(entropy_source);
737 Reference.reachabilityFence(node_signer);
738 Reference.reachabilityFence(node_id_lookup);
739 Reference.reachabilityFence(network_graph);
740 Reference.reachabilityFence(path);
741 Reference.reachabilityFence(contents);
742 Reference.reachabilityFence(reply_path);
743 if (ret >= 0 && ret <= 4096) { return null; }
744 Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
745 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
746 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
747 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_lookup); };
748 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
749 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
750 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents); };
751 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
756 * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
759 * Returns the node id of the peer to send the message to, the message itself, and any addresses
760 * needed to connect to the first node.
762 * Returns [`SendError::UnresolvedIntroductionNode`] if:
763 * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`],
764 * - unless it can be resolved by [`NodeIdLookUp::next_node_id`].
765 * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node
766 * first with a [`ReadOnlyNetworkGraph`].
768 * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
770 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, @Nullable org.ldk.structs.BlindedPath reply_path) {
771 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);
772 Reference.reachabilityFence(entropy_source);
773 Reference.reachabilityFence(node_signer);
774 Reference.reachabilityFence(node_id_lookup);
775 Reference.reachabilityFence(path);
776 Reference.reachabilityFence(contents);
777 Reference.reachabilityFence(reply_path);
778 if (ret >= 0 && ret <= 4096) { return null; }
779 Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ ret_hu_conv = Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.constr_from_ptr(ret);
780 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
781 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
782 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_id_lookup); };
783 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
784 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents); };
785 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
790 * Decode one layer of an incoming [`OnionMessage`].
792 * Returns either the next layer of the onion for forwarding or the decrypted content for the
795 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) {
796 long ret = bindings.peel_onion_message(msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
797 Reference.reachabilityFence(msg);
798 Reference.reachabilityFence(node_signer);
799 Reference.reachabilityFence(logger);
800 Reference.reachabilityFence(custom_handler);
801 if (ret >= 0 && ret <= 4096) { return null; }
802 Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
803 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
804 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
805 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
806 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(custom_handler); };
811 * Returns whether `tlv_type` corresponds to a TLV record for Offers.
813 public static boolean OffersMessage_is_known_type(long tlv_type) {
814 boolean ret = bindings.OffersMessage_is_known_type(tlv_type);
815 Reference.reachabilityFence(tlv_type);
820 * Create a one-hop blinded path for a payment.
822 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) {
823 long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs.ptr, min_final_cltv_expiry_delta, entropy_source.ptr);
824 Reference.reachabilityFence(payee_node_id);
825 Reference.reachabilityFence(payee_tlvs);
826 Reference.reachabilityFence(min_final_cltv_expiry_delta);
827 Reference.reachabilityFence(entropy_source);
828 if (ret >= 0 && ret <= 4096) { return null; }
829 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
830 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
831 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
836 * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
839 * a provided node id is invalid
840 * [`BlindedPayInfo`] calculation results in an integer overflow
841 * any unknown features are required in the provided [`ForwardTlvs`]
843 * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
845 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) {
846 long ret = bindings.BlindedPath_new_for_payment(intermediate_nodes != null ? Arrays.stream(intermediate_nodes).mapToLong(intermediate_nodes_conv_13 -> intermediate_nodes_conv_13.ptr).toArray() : null, InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs.ptr, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source.ptr);
847 Reference.reachabilityFence(intermediate_nodes);
848 Reference.reachabilityFence(payee_node_id);
849 Reference.reachabilityFence(payee_tlvs);
850 Reference.reachabilityFence(htlc_maximum_msat);
851 Reference.reachabilityFence(min_final_cltv_expiry_delta);
852 Reference.reachabilityFence(entropy_source);
853 if (ret >= 0 && ret <= 4096) { return null; }
854 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
855 for (ForwardNode intermediate_nodes_conv_13: intermediate_nodes) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(intermediate_nodes_conv_13); }; };
856 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
857 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
862 * Read a PathFailure from a byte array, created by PathFailure_write
864 public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
865 long ret = bindings.PathFailure_read(ser);
866 Reference.reachabilityFence(ser);
867 if (ret >= 0 && ret <= 4096) { return null; }
868 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
873 * Read a ClosureReason from a byte array, created by ClosureReason_write
875 public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
876 long ret = bindings.ClosureReason_read(ser);
877 Reference.reachabilityFence(ser);
878 if (ret >= 0 && ret <= 4096) { return null; }
879 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
884 * Read a HTLCDestination from a byte array, created by HTLCDestination_write
886 public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
887 long ret = bindings.HTLCDestination_read(ser);
888 Reference.reachabilityFence(ser);
889 if (ret >= 0 && ret <= 4096) { return null; }
890 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
895 * Read a Event from a byte array, created by Event_write
897 public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
898 long ret = bindings.Event_read(ser);
899 Reference.reachabilityFence(ser);
900 if (ret >= 0 && ret <= 4096) { return null; }
901 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
906 * Builds the necessary parameters to pay or pre-flight probe the given zero-amount
907 * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
908 * [`ChannelManager::send_preflight_probes`].
910 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
911 * same [`PaymentHash`] has never been paid before.
913 * Will always succeed unless the invoice has an amount specified, in which case
914 * [`payment_parameters_from_invoice`] should be used.
916 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
917 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
919 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat) {
920 long ret = bindings.payment_parameters_from_zero_amount_invoice(invoice.ptr, amount_msat);
921 Reference.reachabilityFence(invoice);
922 Reference.reachabilityFence(amount_msat);
923 if (ret >= 0 && ret <= 4096) { return null; }
924 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
925 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
930 * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using
931 * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`].
933 * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the
934 * same [`PaymentHash`] has never been paid before.
936 * Will always succeed unless the invoice has no amount specified, in which case
937 * [`payment_parameters_from_zero_amount_invoice`] should be used.
939 * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment
940 * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes
942 public static Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(org.ldk.structs.Bolt11Invoice invoice) {
943 long ret = bindings.payment_parameters_from_invoice(invoice.ptr);
944 Reference.reachabilityFence(invoice);
945 if (ret >= 0 && ret <= 4096) { return null; }
946 Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ ret_hu_conv = Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.constr_from_ptr(ret);
947 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
952 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
953 * See [`PhantomKeysManager`] for more information on phantom node payments.
955 * `phantom_route_hints` parameter:
956 * Contains channel info for all nodes participating in the phantom invoice
957 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
959 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
960 * updated when a channel becomes disabled or closes
961 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
962 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
965 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
966 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
967 * If `None` is provided for `payment_hash`, then one will be created.
969 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
970 * in excess of the current time.
972 * `duration_since_epoch` is the current time since epoch in seconds.
974 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
975 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
976 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
977 * confirmations during routing.
979 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
980 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
983 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
984 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
985 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
986 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
987 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
988 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
990 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
991 * available and the current time is supplied by the caller.
993 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ 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) {
994 long ret = bindings.create_phantom_invoice(amt_msat.ptr, payment_hash.ptr, 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.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
995 Reference.reachabilityFence(amt_msat);
996 Reference.reachabilityFence(payment_hash);
997 Reference.reachabilityFence(description);
998 Reference.reachabilityFence(invoice_expiry_delta_secs);
999 Reference.reachabilityFence(phantom_route_hints);
1000 Reference.reachabilityFence(entropy_source);
1001 Reference.reachabilityFence(node_signer);
1002 Reference.reachabilityFence(logger);
1003 Reference.reachabilityFence(network);
1004 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1005 Reference.reachabilityFence(duration_since_epoch);
1006 if (ret >= 0 && ret <= 4096) { return null; }
1007 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1008 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1009 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
1010 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); }; };
1011 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
1012 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1013 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1014 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1019 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
1020 * See [`PhantomKeysManager`] for more information on phantom node payments.
1022 * `phantom_route_hints` parameter:
1023 * Contains channel info for all nodes participating in the phantom invoice
1024 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
1025 * participating node
1026 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
1027 * updated when a channel becomes disabled or closes
1028 * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
1029 * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
1030 * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
1031 * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
1032 * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
1034 * `description_hash` is a SHA-256 hash of the description text
1036 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
1037 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
1038 * If `None` is provided for `payment_hash`, then one will be created.
1040 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1041 * in excess of the current time.
1043 * `duration_since_epoch` is the current time since epoch in seconds.
1045 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
1046 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
1049 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
1050 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
1051 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
1052 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
1053 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
1055 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1056 * available and the current time is supplied by the caller.
1058 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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) {
1059 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, payment_hash.ptr, invoice_expiry_delta_secs, description_hash.ptr, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
1060 Reference.reachabilityFence(amt_msat);
1061 Reference.reachabilityFence(payment_hash);
1062 Reference.reachabilityFence(invoice_expiry_delta_secs);
1063 Reference.reachabilityFence(description_hash);
1064 Reference.reachabilityFence(phantom_route_hints);
1065 Reference.reachabilityFence(entropy_source);
1066 Reference.reachabilityFence(node_signer);
1067 Reference.reachabilityFence(logger);
1068 Reference.reachabilityFence(network);
1069 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1070 Reference.reachabilityFence(duration_since_epoch);
1071 if (ret >= 0 && ret <= 4096) { return null; }
1072 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1073 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1074 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
1075 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1076 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); }; };
1077 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
1078 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1079 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1080 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1085 * Utility to construct an invoice. Generally, unless you want to do something like a custom
1086 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1087 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1088 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1089 * that the payment secret is valid when the invoice is paid.
1091 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1092 * in excess of the current time.
1094 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1095 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1096 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1097 * confirmations during routing.
1099 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1101 public static Result_Bolt11InvoiceSignOrCreationErrorZ 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) {
1102 long ret = bindings.create_invoice_from_channelmanager(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1103 Reference.reachabilityFence(channelmanager);
1104 Reference.reachabilityFence(node_signer);
1105 Reference.reachabilityFence(logger);
1106 Reference.reachabilityFence(network);
1107 Reference.reachabilityFence(amt_msat);
1108 Reference.reachabilityFence(description);
1109 Reference.reachabilityFence(invoice_expiry_delta_secs);
1110 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1111 if (ret >= 0 && ret <= 4096) { return null; }
1112 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1122 * Utility to construct an invoice. Generally, unless you want to do something like a custom
1123 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1124 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1125 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1126 * that the payment secret is valid when the invoice is paid.
1127 * Use this variant if you want to pass the `description_hash` to the invoice.
1129 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1130 * in excess of the current time.
1132 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1133 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1134 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1135 * confirmations during routing.
1137 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1139 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, 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) {
1140 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);
1141 Reference.reachabilityFence(channelmanager);
1142 Reference.reachabilityFence(node_signer);
1143 Reference.reachabilityFence(logger);
1144 Reference.reachabilityFence(network);
1145 Reference.reachabilityFence(amt_msat);
1146 Reference.reachabilityFence(description_hash);
1147 Reference.reachabilityFence(invoice_expiry_delta_secs);
1148 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1149 if (ret >= 0 && ret <= 4096) { return null; }
1150 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1151 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1153 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1154 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1155 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1156 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1161 * See [`create_invoice_from_channelmanager_with_description_hash`]
1162 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1163 * available and the current time is supplied by the caller.
1165 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, 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) {
1166 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);
1167 Reference.reachabilityFence(channelmanager);
1168 Reference.reachabilityFence(node_signer);
1169 Reference.reachabilityFence(logger);
1170 Reference.reachabilityFence(network);
1171 Reference.reachabilityFence(amt_msat);
1172 Reference.reachabilityFence(description_hash);
1173 Reference.reachabilityFence(duration_since_epoch);
1174 Reference.reachabilityFence(invoice_expiry_delta_secs);
1175 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1176 if (ret >= 0 && ret <= 4096) { return null; }
1177 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1178 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1181 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1183 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1188 * See [`create_invoice_from_channelmanager`]
1189 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1190 * available and the current time is supplied by the caller.
1192 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, 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) {
1193 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1194 Reference.reachabilityFence(channelmanager);
1195 Reference.reachabilityFence(node_signer);
1196 Reference.reachabilityFence(logger);
1197 Reference.reachabilityFence(network);
1198 Reference.reachabilityFence(amt_msat);
1199 Reference.reachabilityFence(description);
1200 Reference.reachabilityFence(duration_since_epoch);
1201 Reference.reachabilityFence(invoice_expiry_delta_secs);
1202 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1203 if (ret >= 0 && ret <= 4096) { return null; }
1204 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1205 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1206 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1207 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1214 * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1215 * This version allows for providing a custom [`PaymentHash`] for the invoice.
1216 * This may be useful if you're building an on-chain swap or involving another protocol where
1217 * the payment hash is also involved outside the scope of lightning.
1219 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, 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) {
1220 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, description, duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.check_arr_len(payment_hash, 32), min_final_cltv_expiry_delta.ptr);
1221 Reference.reachabilityFence(channelmanager);
1222 Reference.reachabilityFence(node_signer);
1223 Reference.reachabilityFence(logger);
1224 Reference.reachabilityFence(network);
1225 Reference.reachabilityFence(amt_msat);
1226 Reference.reachabilityFence(description);
1227 Reference.reachabilityFence(duration_since_epoch);
1228 Reference.reachabilityFence(invoice_expiry_delta_secs);
1229 Reference.reachabilityFence(payment_hash);
1230 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1231 if (ret >= 0 && ret <= 4096) { return null; }
1232 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1233 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1235 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1236 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1237 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };