b6e562537627209c4cc1c35cc369f4c5bb0dbd98
[ldk-java] / src / main / java / org / ldk / structs / UtilMethods.java
1 package org.ldk.structs;
2 import org.ldk.impl.bindings;
3 import org.ldk.enums.*;
4 import org.ldk.util.*;
5 import java.util.Arrays;
6 import java.lang.ref.Reference;
7 import javax.annotation.Nullable;
8
9 public class UtilMethods {
10         /**
11          * Gets the 128-bit integer, as 16 little-endian bytes
12          */
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);
16                 return ret;
17         }
18
19         /**
20          * Constructs a new U128 from 16 little-endian bytes
21          */
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);
26                 return ret_conv;
27         }
28
29         /**
30          * Constructs a new COption_NoneZ containing a
31          */
32         public static COption_NoneZ COption_NoneZ_some() {
33                 COption_NoneZ ret = bindings.COption_NoneZ_some();
34                 return ret;
35         }
36
37         /**
38          * Constructs a new COption_NoneZ containing nothing
39          */
40         public static COption_NoneZ COption_NoneZ_none() {
41                 COption_NoneZ ret = bindings.COption_NoneZ_none();
42                 return ret;
43         }
44
45         /**
46          * Read a APIError from a byte array, created by APIError_write
47          */
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);
53                 return ret_hu_conv;
54         }
55
56         /**
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.
60          */
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);
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Recovers the PublicKey of the signer of the message given the message and the signature.
72          */
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);
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
84          * and the PublicKey.
85          */
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);
91                 return ret;
92         }
93
94         /**
95          * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
96          */
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);
101                 return ret;
102         }
103
104         /**
105          * Read previously persisted [`ChannelMonitor`]s from the store.
106          */
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); };
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Read a MonitorEvent from a byte array, created by MonitorEvent_write
122          */
123         public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
124                 long ret = bindings.MonitorEvent_read(ser);
125                 Reference.reachabilityFence(ser);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write
133          */
134         public static Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
135                 long ret = bindings.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser, arg_a.ptr, arg_b.ptr);
136                 Reference.reachabilityFence(ser);
137                 Reference.reachabilityFence(arg_a);
138                 Reference.reachabilityFence(arg_b);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_a); };
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_b); };
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Fetches the set of [`InitFeatures`] flags that are provided by or required by
148          * [`ChannelManager`].
149          */
150         public static InitFeatures provided_init_features(org.ldk.structs.UserConfig config) {
151                 long ret = bindings.provided_init_features(config == null ? 0 : config.ptr);
152                 Reference.reachabilityFence(config);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(config); };
157                 return ret_hu_conv;
158         }
159
160         /**
161          * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write
162          */
163         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) {
164                 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 == 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));
165                 Reference.reachabilityFence(ser);
166                 Reference.reachabilityFence(arg_entropy_source);
167                 Reference.reachabilityFence(arg_node_signer);
168                 Reference.reachabilityFence(arg_signer_provider);
169                 Reference.reachabilityFence(arg_fee_estimator);
170                 Reference.reachabilityFence(arg_chain_monitor);
171                 Reference.reachabilityFence(arg_tx_broadcaster);
172                 Reference.reachabilityFence(arg_router);
173                 Reference.reachabilityFence(arg_logger);
174                 Reference.reachabilityFence(arg_default_config);
175                 Reference.reachabilityFence(arg_channel_monitors);
176                 if (ret >= 0 && ret <= 4096) { return null; }
177                 Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_entropy_source); };
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_node_signer); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_signer_provider); };
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_fee_estimator); };
182                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_chain_monitor); };
183                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_tx_broadcaster); };
184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_router); };
185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_logger); };
186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_default_config); };
187                 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); }; };
188                 return ret_hu_conv;
189         }
190
191         /**
192          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
193          * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
194          * a `ChannelManager`.
195          * 
196          * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
197          * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
198          * regenerate it for each new inbound payment.
199          * 
200          * `current_time` is a Unix timestamp representing the current time.
201          * 
202          * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
203          * on versions of LDK prior to 0.0.114.
204          * 
205          * [phantom node payments]: crate::sign::PhantomKeysManager
206          * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material
207          */
208         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) {
209                 long ret = bindings.create(keys == null ? 0 : keys.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, entropy_source.ptr, current_time, min_final_cltv_expiry_delta.ptr);
210                 Reference.reachabilityFence(keys);
211                 Reference.reachabilityFence(min_value_msat);
212                 Reference.reachabilityFence(invoice_expiry_delta_secs);
213                 Reference.reachabilityFence(entropy_source);
214                 Reference.reachabilityFence(current_time);
215                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
216                 if (ret >= 0 && ret <= 4096) { return null; }
217                 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
218                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
219                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
221                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
222                 return ret_hu_conv;
223         }
224
225         /**
226          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
227          * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
228          * without a `ChannelManager`.
229          * 
230          * See [`create`] for information on the `keys` and `current_time` parameters.
231          * 
232          * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
233          * on versions of LDK prior to 0.0.114.
234          * 
235          * [phantom node payments]: crate::sign::PhantomKeysManager
236          */
237         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) {
238                 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);
239                 Reference.reachabilityFence(keys);
240                 Reference.reachabilityFence(min_value_msat);
241                 Reference.reachabilityFence(payment_hash);
242                 Reference.reachabilityFence(invoice_expiry_delta_secs);
243                 Reference.reachabilityFence(current_time);
244                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
245                 if (ret >= 0 && ret <= 4096) { return null; }
246                 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
247                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); };
248                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); };
249                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
250                 return ret_hu_conv;
251         }
252
253         /**
254          * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
255          * 
256          * The host part must end with \".onion\".
257          */
258         public static Result_SocketAddressSocketAddressParseErrorZ parse_onion_address(java.lang.String host, short port) {
259                 long ret = bindings.parse_onion_address(host, port);
260                 Reference.reachabilityFence(host);
261                 Reference.reachabilityFence(port);
262                 if (ret >= 0 && ret <= 4096) { return null; }
263                 Result_SocketAddressSocketAddressParseErrorZ ret_hu_conv = Result_SocketAddressSocketAddressParseErrorZ.constr_from_ptr(ret);
264                 return ret_hu_conv;
265         }
266
267         /**
268          * Gets the weight for an HTLC-Success transaction.
269          */
270         public static long htlc_success_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
271                 long ret = bindings.htlc_success_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
272                 Reference.reachabilityFence(channel_type_features);
273                 return ret;
274         }
275
276         /**
277          * Gets the weight for an HTLC-Timeout transaction.
278          */
279         public static long htlc_timeout_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
280                 long ret = bindings.htlc_timeout_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
281                 Reference.reachabilityFence(channel_type_features);
282                 return ret;
283         }
284
285         /**
286          * Check if a given input witness attempts to claim a HTLC.
287          */
288         public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
289                 long ret = bindings.HTLCClaim_from_witness(witness);
290                 Reference.reachabilityFence(witness);
291                 if (ret >= 0 && ret <= 4096) { return null; }
292                 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
293                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
294                 return ret_hu_conv;
295         }
296
297         /**
298          * Build the commitment secret from the seed and the commitment number
299          */
300         public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
301                 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
302                 Reference.reachabilityFence(commitment_seed);
303                 Reference.reachabilityFence(idx);
304                 return ret;
305         }
306
307         /**
308          * Build a closing transaction
309          */
310         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) {
311                 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);
312                 Reference.reachabilityFence(to_holder_value_sat);
313                 Reference.reachabilityFence(to_counterparty_value_sat);
314                 Reference.reachabilityFence(to_holder_script);
315                 Reference.reachabilityFence(to_counterparty_script);
316                 Reference.reachabilityFence(funding_outpoint);
317                 return ret;
318         }
319
320         /**
321          * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
322          * from the base secret and the per_commitment_point.
323          */
324         public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
325                 byte[] ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
326                 Reference.reachabilityFence(per_commitment_point);
327                 Reference.reachabilityFence(base_secret);
328                 return ret;
329         }
330
331         /**
332          * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
333          * from the base point and the per_commitment_key. This is the public equivalent of
334          * derive_private_key - using only public keys to derive a public key instead of private keys.
335          */
336         public static byte[] derive_public_key(byte[] per_commitment_point, byte[] base_point) {
337                 byte[] ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
338                 Reference.reachabilityFence(per_commitment_point);
339                 Reference.reachabilityFence(base_point);
340                 return ret;
341         }
342
343         /**
344          * Derives a per-commitment-transaction revocation key from its constituent parts.
345          * 
346          * Only the cheating participant owns a valid witness to propagate a revoked
347          * commitment transaction, thus per_commitment_secret always come from cheater
348          * and revocation_base_secret always come from punisher, which is the broadcaster
349          * of the transaction spending with this key knowledge.
350          */
351         public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
352                 byte[] ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
353                 Reference.reachabilityFence(per_commitment_secret);
354                 Reference.reachabilityFence(countersignatory_revocation_base_secret);
355                 return ret;
356         }
357
358         /**
359          * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
360          * the public equivalend of derive_private_revocation_key - using only public keys to derive a
361          * public key instead of private keys.
362          * 
363          * Only the cheating participant owns a valid witness to propagate a revoked
364          * commitment transaction, thus per_commitment_point always come from cheater
365          * and revocation_base_point always come from punisher, which is the broadcaster
366          * of the transaction spending with this key knowledge.
367          * 
368          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
369          * generated (ie our own).
370          */
371         public static byte[] derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
372                 byte[] ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
373                 Reference.reachabilityFence(per_commitment_point);
374                 Reference.reachabilityFence(countersignatory_revocation_base_point);
375                 return ret;
376         }
377
378         /**
379          * A script either spendable by the revocation
380          * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
381          * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
382          */
383         public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
384                 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
385                 Reference.reachabilityFence(revocation_key);
386                 Reference.reachabilityFence(contest_delay);
387                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
388                 return ret;
389         }
390
391         /**
392          * Returns the script for the counterparty's output on a holder's commitment transaction based on
393          * the channel type.
394          */
395         public static byte[] get_counterparty_payment_script(org.ldk.structs.ChannelTypeFeatures channel_type_features, byte[] payment_key) {
396                 byte[] ret = bindings.get_counterparty_payment_script(channel_type_features == null ? 0 : channel_type_features.ptr, InternalUtils.check_arr_len(payment_key, 33));
397                 Reference.reachabilityFence(channel_type_features);
398                 Reference.reachabilityFence(payment_key);
399                 return ret;
400         }
401
402         /**
403          * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
404          * does not need to have its previous_output_index filled.
405          */
406         public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.TxCreationKeys keys) {
407                 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr, channel_type_features == null ? 0 : channel_type_features.ptr, keys == null ? 0 : keys.ptr);
408                 Reference.reachabilityFence(htlc);
409                 Reference.reachabilityFence(channel_type_features);
410                 Reference.reachabilityFence(keys);
411                 return ret;
412         }
413
414         /**
415          * Gets the redeemscript for a funding output from the two funding public keys.
416          * Note that the order of funding public keys does not matter.
417          */
418         public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
419                 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
420                 Reference.reachabilityFence(broadcaster);
421                 Reference.reachabilityFence(countersignatory);
422                 return ret;
423         }
424
425         /**
426          * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
427          * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
428          * transaction which needs signing, and can be used to construct an HTLC transaction which is
429          * broadcastable given a counterparty HTLC signature.
430          * 
431          * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
432          * commitment transaction).
433          */
434         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, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
435                 byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr, channel_type_features == null ? 0 : channel_type_features.ptr, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
436                 Reference.reachabilityFence(commitment_txid);
437                 Reference.reachabilityFence(feerate_per_kw);
438                 Reference.reachabilityFence(contest_delay);
439                 Reference.reachabilityFence(htlc);
440                 Reference.reachabilityFence(channel_type_features);
441                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
442                 Reference.reachabilityFence(revocation_key);
443                 return ret;
444         }
445
446         /**
447          * Returns the witness required to satisfy and spend a HTLC input.
448          */
449         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) {
450                 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 == null ? 0 : channel_type_features.ptr);
451                 Reference.reachabilityFence(local_sig);
452                 Reference.reachabilityFence(remote_sig);
453                 Reference.reachabilityFence(preimage);
454                 Reference.reachabilityFence(redeem_script);
455                 Reference.reachabilityFence(channel_type_features);
456                 return ret;
457         }
458
459         /**
460          * Gets the witnessScript for the to_remote output when anchors are enabled.
461          */
462         public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
463                 byte[] ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.check_arr_len(payment_point, 33));
464                 Reference.reachabilityFence(payment_point);
465                 return ret;
466         }
467
468         /**
469          * Gets the witnessScript for an anchor output from the funding public key.
470          * The witness in the spending input must be:
471          * <BIP 143 funding_signature>
472          * After 16 blocks of confirmation, an alternative satisfying witness could be:
473          * <>
474          * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
475          */
476         public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
477                 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
478                 Reference.reachabilityFence(funding_pubkey);
479                 return ret;
480         }
481
482         /**
483          * Returns the witness required to satisfy and spend an anchor input.
484          */
485         public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
486                 byte[] ret = bindings.build_anchor_input_witness(InternalUtils.check_arr_len(funding_key, 33), InternalUtils.check_arr_len(funding_sig, 64));
487                 Reference.reachabilityFence(funding_key);
488                 Reference.reachabilityFence(funding_sig);
489                 return ret;
490         }
491
492         /**
493          * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
494          * shared secret first. This prevents on-chain observers from discovering how many commitment
495          * transactions occurred in a channel before it was closed.
496          * 
497          * This function gets the shared secret from relevant channel public keys and can be used to
498          * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
499          */
500         public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
501                 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);
502                 Reference.reachabilityFence(broadcaster_payment_basepoint);
503                 Reference.reachabilityFence(countersignatory_payment_basepoint);
504                 Reference.reachabilityFence(outbound_from_broadcaster);
505                 return ret;
506         }
507
508         /**
509          * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
510          */
511         public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
512                 long ret = bindings.NetworkUpdate_read(ser);
513                 Reference.reachabilityFence(ser);
514                 if (ret >= 0 && ret <= 4096) { return null; }
515                 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
516                 return ret_hu_conv;
517         }
518
519         /**
520          * Verifies the signature of a [`NodeAnnouncement`].
521          * 
522          * Returns an error if it is invalid.
523          */
524         public static Result_NoneLightningErrorZ verify_node_announcement(org.ldk.structs.NodeAnnouncement msg) {
525                 long ret = bindings.verify_node_announcement(msg == null ? 0 : msg.ptr);
526                 Reference.reachabilityFence(msg);
527                 if (ret >= 0 && ret <= 4096) { return null; }
528                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
529                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
530                 return ret_hu_conv;
531         }
532
533         /**
534          * Verifies all signatures included in a [`ChannelAnnouncement`].
535          * 
536          * Returns an error if one of the signatures is invalid.
537          */
538         public static Result_NoneLightningErrorZ verify_channel_announcement(org.ldk.structs.ChannelAnnouncement msg) {
539                 long ret = bindings.verify_channel_announcement(msg == null ? 0 : msg.ptr);
540                 Reference.reachabilityFence(msg);
541                 if (ret >= 0 && ret <= 4096) { return null; }
542                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
543                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
544                 return ret_hu_conv;
545         }
546
547         /**
548          * Finds a route from us (payer) to the given target node (payee).
549          * 
550          * If the payee provided features in their invoice, they should be provided via the `payee` field
551          * in the given [`RouteParameters::payment_params`].
552          * Without this, MPP will only be used if the payee's features are available in the network graph.
553          * 
554          * Private routing paths between a public node and the target may be included in the `payee` field
555          * of [`RouteParameters::payment_params`].
556          * 
557          * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
558          * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
559          * from `network_graph` will be ignored, and only those in `first_hops` will be used.
560          * 
561          * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
562          * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
563          * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
564          * 
565          * # Panics
566          * 
567          * Panics if first_hops contains channels without `short_channel_id`s;
568          * [`ChannelManager::list_usable_channels`] will never include such channels.
569          * 
570          * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
571          * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
572          * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
573          * 
574          * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
575          */
576         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) {
577                 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.ptr, scorer.ptr, score_params == null ? 0 : score_params.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
578                 Reference.reachabilityFence(our_node_pubkey);
579                 Reference.reachabilityFence(route_params);
580                 Reference.reachabilityFence(network_graph);
581                 Reference.reachabilityFence(first_hops);
582                 Reference.reachabilityFence(logger);
583                 Reference.reachabilityFence(scorer);
584                 Reference.reachabilityFence(score_params);
585                 Reference.reachabilityFence(random_seed_bytes);
586                 if (ret >= 0 && ret <= 4096) { return null; }
587                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
588                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
589                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
590                 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); }; } };
591                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
592                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(scorer); };
593                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(score_params); };
594                 return ret_hu_conv;
595         }
596
597         /**
598          * Construct a route from us (payer) to the target node (payee) via the given hops (which should
599          * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
600          * 
601          * Re-uses logic from `find_route`, so the restrictions described there also apply here.
602          */
603         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) {
604                 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.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
605                 Reference.reachabilityFence(our_node_pubkey);
606                 Reference.reachabilityFence(hops);
607                 Reference.reachabilityFence(route_params);
608                 Reference.reachabilityFence(network_graph);
609                 Reference.reachabilityFence(logger);
610                 Reference.reachabilityFence(random_seed_bytes);
611                 if (ret >= 0 && ret <= 4096) { return null; }
612                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
613                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_params); };
614                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(network_graph); };
615                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
616                 return ret_hu_conv;
617         }
618
619         /**
620          * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
621          * the given outputs, plus an output to the given change destination (if sufficient
622          * change value remains). The PSBT will have a feerate, at least, of the given value.
623          * 
624          * The `locktime` argument is used to set the transaction's locktime. If `None`, the
625          * transaction will have a locktime of 0. It it recommended to set this to the current block
626          * height to avoid fee sniping, unless you have some specific reason to use a different
627          * locktime.
628          * 
629          * Returns the PSBT and expected max transaction weight.
630          * 
631          * Returns `Err(())` if the output value is greater than the input value minus required fee,
632          * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
633          * does not match the one we can spend.
634          * 
635          * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
636          */
637         public static Result_C2Tuple_CVec_u8ZusizeZNoneZ 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) {
638                 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);
639                 Reference.reachabilityFence(descriptors);
640                 Reference.reachabilityFence(outputs);
641                 Reference.reachabilityFence(change_destination_script);
642                 Reference.reachabilityFence(feerate_sat_per_1000_weight);
643                 Reference.reachabilityFence(locktime);
644                 if (ret >= 0 && ret <= 4096) { return null; }
645                 Result_C2Tuple_CVec_u8ZusizeZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8ZusizeZNoneZ.constr_from_ptr(ret);
646                 for (SpendableOutputDescriptor descriptors_conv_27: descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(descriptors_conv_27); }; };
647                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(locktime); };
648                 return ret_hu_conv;
649         }
650
651         /**
652          * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of
653          * `path`.
654          * 
655          * Returns both the node id of the peer to send the message to and the message itself.
656          * 
657          * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
658          */
659         public static Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ create_onion_message(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents contents, @Nullable org.ldk.structs.BlindedPath reply_path) {
660                 long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, path == null ? 0 : path.ptr, contents.ptr, reply_path == null ? 0 : reply_path.ptr);
661                 Reference.reachabilityFence(entropy_source);
662                 Reference.reachabilityFence(node_signer);
663                 Reference.reachabilityFence(path);
664                 Reference.reachabilityFence(contents);
665                 Reference.reachabilityFence(reply_path);
666                 if (ret >= 0 && ret <= 4096) { return null; }
667                 Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ ret_hu_conv = Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ.constr_from_ptr(ret);
668                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
669                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
670                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
671                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents); };
672                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
673                 return ret_hu_conv;
674         }
675
676         /**
677          * Decode one layer of an incoming [`OnionMessage`].
678          * 
679          * Returns either the next layer of the onion for forwarding or the decrypted content for the
680          * receiver.
681          */
682         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) {
683                 long ret = bindings.peel_onion_message(msg == null ? 0 : msg.ptr, node_signer.ptr, logger.ptr, custom_handler.ptr);
684                 Reference.reachabilityFence(msg);
685                 Reference.reachabilityFence(node_signer);
686                 Reference.reachabilityFence(logger);
687                 Reference.reachabilityFence(custom_handler);
688                 if (ret >= 0 && ret <= 4096) { return null; }
689                 Result_PeeledOnionNoneZ ret_hu_conv = Result_PeeledOnionNoneZ.constr_from_ptr(ret);
690                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
691                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
692                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
693                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(custom_handler); };
694                 return ret_hu_conv;
695         }
696
697         /**
698          * Returns whether `tlv_type` corresponds to a TLV record for Offers.
699          */
700         public static boolean OffersMessage_is_known_type(long tlv_type) {
701                 boolean ret = bindings.OffersMessage_is_known_type(tlv_type);
702                 Reference.reachabilityFence(tlv_type);
703                 return ret;
704         }
705
706         /**
707          * Create a one-hop blinded path for a payment.
708          */
709         public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, org.ldk.structs.EntropySource entropy_source) {
710                 long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs == null ? 0 : payee_tlvs.ptr, entropy_source.ptr);
711                 Reference.reachabilityFence(payee_node_id);
712                 Reference.reachabilityFence(payee_tlvs);
713                 Reference.reachabilityFence(entropy_source);
714                 if (ret >= 0 && ret <= 4096) { return null; }
715                 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
716                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
717                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
718                 return ret_hu_conv;
719         }
720
721         /**
722          * Read a PathFailure from a byte array, created by PathFailure_write
723          */
724         public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
725                 long ret = bindings.PathFailure_read(ser);
726                 Reference.reachabilityFence(ser);
727                 if (ret >= 0 && ret <= 4096) { return null; }
728                 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
729                 return ret_hu_conv;
730         }
731
732         /**
733          * Read a ClosureReason from a byte array, created by ClosureReason_write
734          */
735         public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
736                 long ret = bindings.ClosureReason_read(ser);
737                 Reference.reachabilityFence(ser);
738                 if (ret >= 0 && ret <= 4096) { return null; }
739                 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
740                 return ret_hu_conv;
741         }
742
743         /**
744          * Read a HTLCDestination from a byte array, created by HTLCDestination_write
745          */
746         public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
747                 long ret = bindings.HTLCDestination_read(ser);
748                 Reference.reachabilityFence(ser);
749                 if (ret >= 0 && ret <= 4096) { return null; }
750                 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
751                 return ret_hu_conv;
752         }
753
754         /**
755          * Read a Event from a byte array, created by Event_write
756          */
757         public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
758                 long ret = bindings.Event_read(ser);
759                 Reference.reachabilityFence(ser);
760                 if (ret >= 0 && ret <= 4096) { return null; }
761                 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
762                 return ret_hu_conv;
763         }
764
765         /**
766          * Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`].
767          * 
768          * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
769          * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
770          * with the same [`PaymentHash`] is never sent.
771          * 
772          * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
773          */
774         public static Result_ThirtyTwoBytesPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
775                 long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
776                 Reference.reachabilityFence(invoice);
777                 Reference.reachabilityFence(retry_strategy);
778                 Reference.reachabilityFence(channelmanager);
779                 if (ret >= 0 && ret <= 4096) { return null; }
780                 Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
781                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
782                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
783                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
784                 return ret_hu_conv;
785         }
786
787         /**
788          * Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on
789          * [`Retry`].
790          * 
791          * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
792          * payment completes or fails, no idempotency guarantees are made.
793          * 
794          * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
795          * [`PaymentHash`] has never been paid before.
796          * 
797          * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
798          */
799         public static Result_NonePaymentErrorZ pay_invoice_with_id(org.ldk.structs.Bolt11Invoice invoice, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
800                 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);
801                 Reference.reachabilityFence(invoice);
802                 Reference.reachabilityFence(payment_id);
803                 Reference.reachabilityFence(retry_strategy);
804                 Reference.reachabilityFence(channelmanager);
805                 if (ret >= 0 && ret <= 4096) { return null; }
806                 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
807                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
808                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
809                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
810                 return ret_hu_conv;
811         }
812
813         /**
814          * Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on
815          * [`Retry`].
816          * 
817          * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
818          * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
819          * with the same [`PaymentHash`] is never sent.
820          * 
821          * If you wish to use a different payment idempotency token, see
822          * [`pay_zero_value_invoice_with_id`].
823          */
824         public static Result_ThirtyTwoBytesPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
825                 long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
826                 Reference.reachabilityFence(invoice);
827                 Reference.reachabilityFence(amount_msats);
828                 Reference.reachabilityFence(retry_strategy);
829                 Reference.reachabilityFence(channelmanager);
830                 if (ret >= 0 && ret <= 4096) { return null; }
831                 Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
832                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
833                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
834                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
835                 return ret_hu_conv;
836         }
837
838         /**
839          * Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key,
840          * retrying if needed based on [`Retry`].
841          * 
842          * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
843          * payment completes or fails, no idempotency guarantees are made.
844          * 
845          * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
846          * [`PaymentHash`] has never been paid before.
847          * 
848          * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
849          * idempotency token.
850          */
851         public static Result_NonePaymentErrorZ pay_zero_value_invoice_with_id(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
852                 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);
853                 Reference.reachabilityFence(invoice);
854                 Reference.reachabilityFence(amount_msats);
855                 Reference.reachabilityFence(payment_id);
856                 Reference.reachabilityFence(retry_strategy);
857                 Reference.reachabilityFence(channelmanager);
858                 if (ret >= 0 && ret <= 4096) { return null; }
859                 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
860                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
861                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
862                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
863                 return ret_hu_conv;
864         }
865
866         /**
867          * Sends payment probes over all paths of a route that would be used to pay the given invoice.
868          * 
869          * See [`ChannelManager::send_preflight_probes`] for more information.
870          */
871         public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
872                 long ret = bindings.preflight_probe_invoice(invoice == null ? 0 : invoice.ptr, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
873                 Reference.reachabilityFence(invoice);
874                 Reference.reachabilityFence(channelmanager);
875                 Reference.reachabilityFence(liquidity_limit_multiplier);
876                 if (ret >= 0 && ret <= 4096) { return null; }
877                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
878                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
879                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
880                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(liquidity_limit_multiplier); };
881                 return ret_hu_conv;
882         }
883
884         /**
885          * Sends payment probes over all paths of a route that would be used to pay the given zero-value
886          * invoice using the given amount.
887          * 
888          * See [`ChannelManager::send_preflight_probes`] for more information.
889          */
890         public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
891                 long ret = bindings.preflight_probe_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msat, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
892                 Reference.reachabilityFence(invoice);
893                 Reference.reachabilityFence(amount_msat);
894                 Reference.reachabilityFence(channelmanager);
895                 Reference.reachabilityFence(liquidity_limit_multiplier);
896                 if (ret >= 0 && ret <= 4096) { return null; }
897                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
898                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
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(liquidity_limit_multiplier); };
901                 return ret_hu_conv;
902         }
903
904         /**
905          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
906          * See [`PhantomKeysManager`] for more information on phantom node payments.
907          * 
908          * `phantom_route_hints` parameter:
909          * Contains channel info for all nodes participating in the phantom invoice
910          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
911          * participating node
912          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
913          * updated when a channel becomes disabled or closes
914          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
915          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
916          * down
917          * 
918          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
919          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
920          * If `None` is provided for `payment_hash`, then one will be created.
921          * 
922          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
923          * in excess of the current time.
924          * 
925          * `duration_since_epoch` is the current time since epoch in seconds.
926          * 
927          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
928          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
929          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
930          * confirmations during routing.
931          * 
932          * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
933          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
934          * requirement).
935          * 
936          * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
937          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
938          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
939          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
940          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
941          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
942          * 
943          * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
944          * available and the current time is supplied by the caller.
945          */
946         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) {
947                 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 == null ? 0 : 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);
948                 Reference.reachabilityFence(amt_msat);
949                 Reference.reachabilityFence(payment_hash);
950                 Reference.reachabilityFence(description);
951                 Reference.reachabilityFence(invoice_expiry_delta_secs);
952                 Reference.reachabilityFence(phantom_route_hints);
953                 Reference.reachabilityFence(entropy_source);
954                 Reference.reachabilityFence(node_signer);
955                 Reference.reachabilityFence(logger);
956                 Reference.reachabilityFence(network);
957                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
958                 Reference.reachabilityFence(duration_since_epoch);
959                 if (ret >= 0 && ret <= 4096) { return null; }
960                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
961                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
962                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
963                 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); }; };
964                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
965                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
966                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
967                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
968                 return ret_hu_conv;
969         }
970
971         /**
972          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
973          * See [`PhantomKeysManager`] for more information on phantom node payments.
974          * 
975          * `phantom_route_hints` parameter:
976          * Contains channel info for all nodes participating in the phantom invoice
977          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
978          * participating node
979          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
980          * updated when a channel becomes disabled or closes
981          * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
982          * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
983          * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
984          * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
985          * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
986          * 
987          * `description_hash` is a SHA-256 hash of the description text
988          * 
989          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
990          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
991          * If `None` is provided for `payment_hash`, then one will be created.
992          * 
993          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
994          * in excess of the current time.
995          * 
996          * `duration_since_epoch` is the current time since epoch in seconds.
997          * 
998          * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
999          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
1000          * requirement).
1001          * 
1002          * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
1003          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
1004          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
1005          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
1006          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
1007          * 
1008          * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1009          * available and the current time is supplied by the caller.
1010          */
1011         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) {
1012                 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, payment_hash.ptr, invoice_expiry_delta_secs, description_hash == null ? 0 : description_hash.ptr, 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.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
1013                 Reference.reachabilityFence(amt_msat);
1014                 Reference.reachabilityFence(payment_hash);
1015                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1016                 Reference.reachabilityFence(description_hash);
1017                 Reference.reachabilityFence(phantom_route_hints);
1018                 Reference.reachabilityFence(entropy_source);
1019                 Reference.reachabilityFence(node_signer);
1020                 Reference.reachabilityFence(logger);
1021                 Reference.reachabilityFence(network);
1022                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1023                 Reference.reachabilityFence(duration_since_epoch);
1024                 if (ret >= 0 && ret <= 4096) { return null; }
1025                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1026                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1027                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
1028                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1029                 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); }; };
1030                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
1031                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1032                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1033                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1034                 return ret_hu_conv;
1035         }
1036
1037         /**
1038          * Utility to construct an invoice. Generally, unless you want to do something like a custom
1039          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1040          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1041          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1042          * that the payment secret is valid when the invoice is paid.
1043          * 
1044          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1045          * in excess of the current time.
1046          * 
1047          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1048          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1049          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1050          * confirmations during routing.
1051          * 
1052          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1053          */
1054         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) {
1055                 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1056                 Reference.reachabilityFence(channelmanager);
1057                 Reference.reachabilityFence(node_signer);
1058                 Reference.reachabilityFence(logger);
1059                 Reference.reachabilityFence(network);
1060                 Reference.reachabilityFence(amt_msat);
1061                 Reference.reachabilityFence(description);
1062                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1063                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1064                 if (ret >= 0 && ret <= 4096) { return null; }
1065                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1066                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1067                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1068                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1069                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1070                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1071                 return ret_hu_conv;
1072         }
1073
1074         /**
1075          * Utility to construct an invoice. Generally, unless you want to do something like a custom
1076          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1077          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1078          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1079          * that the payment secret is valid when the invoice is paid.
1080          * Use this variant if you want to pass the `description_hash` to the invoice.
1081          * 
1082          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1083          * in excess of the current time.
1084          * 
1085          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1086          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1087          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1088          * confirmations during routing.
1089          * 
1090          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1091          */
1092         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) {
1093                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1094                 Reference.reachabilityFence(channelmanager);
1095                 Reference.reachabilityFence(node_signer);
1096                 Reference.reachabilityFence(logger);
1097                 Reference.reachabilityFence(network);
1098                 Reference.reachabilityFence(amt_msat);
1099                 Reference.reachabilityFence(description_hash);
1100                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1101                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1102                 if (ret >= 0 && ret <= 4096) { return null; }
1103                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1110                 return ret_hu_conv;
1111         }
1112
1113         /**
1114          * See [`create_invoice_from_channelmanager_with_description_hash`]
1115          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1116          * available and the current time is supplied by the caller.
1117          */
1118         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) {
1119                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1120                 Reference.reachabilityFence(channelmanager);
1121                 Reference.reachabilityFence(node_signer);
1122                 Reference.reachabilityFence(logger);
1123                 Reference.reachabilityFence(network);
1124                 Reference.reachabilityFence(amt_msat);
1125                 Reference.reachabilityFence(description_hash);
1126                 Reference.reachabilityFence(duration_since_epoch);
1127                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1128                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1129                 if (ret >= 0 && ret <= 4096) { return null; }
1130                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1134                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1137                 return ret_hu_conv;
1138         }
1139
1140         /**
1141          * See [`create_invoice_from_channelmanager`]
1142          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1143          * available and the current time is supplied by the caller.
1144          */
1145         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) {
1146                 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1147                 Reference.reachabilityFence(channelmanager);
1148                 Reference.reachabilityFence(node_signer);
1149                 Reference.reachabilityFence(logger);
1150                 Reference.reachabilityFence(network);
1151                 Reference.reachabilityFence(amt_msat);
1152                 Reference.reachabilityFence(description);
1153                 Reference.reachabilityFence(duration_since_epoch);
1154                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1155                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1156                 if (ret >= 0 && ret <= 4096) { return null; }
1157                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1159                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1160                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1162                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1163                 return ret_hu_conv;
1164         }
1165
1166         /**
1167          * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1168          * This version allows for providing a custom [`PaymentHash`] for the invoice.
1169          * This may be useful if you're building an on-chain swap or involving another protocol where
1170          * the payment hash is also involved outside the scope of lightning.
1171          */
1172         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) {
1173                 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.check_arr_len(payment_hash, 32), min_final_cltv_expiry_delta.ptr);
1174                 Reference.reachabilityFence(channelmanager);
1175                 Reference.reachabilityFence(node_signer);
1176                 Reference.reachabilityFence(logger);
1177                 Reference.reachabilityFence(network);
1178                 Reference.reachabilityFence(amt_msat);
1179                 Reference.reachabilityFence(description);
1180                 Reference.reachabilityFence(duration_since_epoch);
1181                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1182                 Reference.reachabilityFence(payment_hash);
1183                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1184                 if (ret >= 0 && ret <= 4096) { return null; }
1185                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1187                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1188                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1190                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1191                 return ret_hu_conv;
1192         }
1193
1194 }