aa0110f17f5354f449c1aa5af41719e3cfa5c899
[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 which 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          * Create an onion message with contents `message` to the destination of `path`.
653          * Returns (introduction_node_id, onion_msg)
654          * 
655          * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
656          */
657         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 message, @Nullable org.ldk.structs.BlindedPath reply_path) {
658                 long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, path == null ? 0 : path.ptr, message.ptr, reply_path == null ? 0 : reply_path.ptr);
659                 Reference.reachabilityFence(entropy_source);
660                 Reference.reachabilityFence(node_signer);
661                 Reference.reachabilityFence(path);
662                 Reference.reachabilityFence(message);
663                 Reference.reachabilityFence(reply_path);
664                 if (ret >= 0 && ret <= 4096) { return null; }
665                 Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ ret_hu_conv = Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ.constr_from_ptr(ret);
666                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
667                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
668                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); };
669                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(message); };
670                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); };
671                 return ret_hu_conv;
672         }
673
674         /**
675          * Returns whether `tlv_type` corresponds to a TLV record for Offers.
676          */
677         public static boolean OffersMessage_is_known_type(long tlv_type) {
678                 boolean ret = bindings.OffersMessage_is_known_type(tlv_type);
679                 Reference.reachabilityFence(tlv_type);
680                 return ret;
681         }
682
683         /**
684          * Create a one-hop blinded path for a payment.
685          */
686         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) {
687                 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);
688                 Reference.reachabilityFence(payee_node_id);
689                 Reference.reachabilityFence(payee_tlvs);
690                 Reference.reachabilityFence(entropy_source);
691                 if (ret >= 0 && ret <= 4096) { return null; }
692                 Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret);
693                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); };
694                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
695                 return ret_hu_conv;
696         }
697
698         /**
699          * Read a PathFailure from a byte array, created by PathFailure_write
700          */
701         public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
702                 long ret = bindings.PathFailure_read(ser);
703                 Reference.reachabilityFence(ser);
704                 if (ret >= 0 && ret <= 4096) { return null; }
705                 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
706                 return ret_hu_conv;
707         }
708
709         /**
710          * Read a ClosureReason from a byte array, created by ClosureReason_write
711          */
712         public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
713                 long ret = bindings.ClosureReason_read(ser);
714                 Reference.reachabilityFence(ser);
715                 if (ret >= 0 && ret <= 4096) { return null; }
716                 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
717                 return ret_hu_conv;
718         }
719
720         /**
721          * Read a HTLCDestination from a byte array, created by HTLCDestination_write
722          */
723         public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
724                 long ret = bindings.HTLCDestination_read(ser);
725                 Reference.reachabilityFence(ser);
726                 if (ret >= 0 && ret <= 4096) { return null; }
727                 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
728                 return ret_hu_conv;
729         }
730
731         /**
732          * Read a Event from a byte array, created by Event_write
733          */
734         public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
735                 long ret = bindings.Event_read(ser);
736                 Reference.reachabilityFence(ser);
737                 if (ret >= 0 && ret <= 4096) { return null; }
738                 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
739                 return ret_hu_conv;
740         }
741
742         /**
743          * Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`].
744          * 
745          * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
746          * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
747          * with the same [`PaymentHash`] is never sent.
748          * 
749          * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
750          */
751         public static Result_ThirtyTwoBytesPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
752                 long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
753                 Reference.reachabilityFence(invoice);
754                 Reference.reachabilityFence(retry_strategy);
755                 Reference.reachabilityFence(channelmanager);
756                 if (ret >= 0 && ret <= 4096) { return null; }
757                 Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
758                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
759                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
760                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
761                 return ret_hu_conv;
762         }
763
764         /**
765          * Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on
766          * [`Retry`].
767          * 
768          * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
769          * payment completes or fails, no idempotency guarantees are made.
770          * 
771          * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
772          * [`PaymentHash`] has never been paid before.
773          * 
774          * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
775          */
776         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) {
777                 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);
778                 Reference.reachabilityFence(invoice);
779                 Reference.reachabilityFence(payment_id);
780                 Reference.reachabilityFence(retry_strategy);
781                 Reference.reachabilityFence(channelmanager);
782                 if (ret >= 0 && ret <= 4096) { return null; }
783                 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
784                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
785                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
786                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
787                 return ret_hu_conv;
788         }
789
790         /**
791          * Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on
792          * [`Retry`].
793          * 
794          * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
795          * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
796          * with the same [`PaymentHash`] is never sent.
797          * 
798          * If you wish to use a different payment idempotency token, see
799          * [`pay_zero_value_invoice_with_id`].
800          */
801         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) {
802                 long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
803                 Reference.reachabilityFence(invoice);
804                 Reference.reachabilityFence(amount_msats);
805                 Reference.reachabilityFence(retry_strategy);
806                 Reference.reachabilityFence(channelmanager);
807                 if (ret >= 0 && ret <= 4096) { return null; }
808                 Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret);
809                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
810                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
811                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
812                 return ret_hu_conv;
813         }
814
815         /**
816          * Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key,
817          * retrying if needed based on [`Retry`].
818          * 
819          * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
820          * payment completes or fails, no idempotency guarantees are made.
821          * 
822          * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
823          * [`PaymentHash`] has never been paid before.
824          * 
825          * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
826          * idempotency token.
827          */
828         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) {
829                 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);
830                 Reference.reachabilityFence(invoice);
831                 Reference.reachabilityFence(amount_msats);
832                 Reference.reachabilityFence(payment_id);
833                 Reference.reachabilityFence(retry_strategy);
834                 Reference.reachabilityFence(channelmanager);
835                 if (ret >= 0 && ret <= 4096) { return null; }
836                 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
837                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
838                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); };
839                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
840                 return ret_hu_conv;
841         }
842
843         /**
844          * Sends payment probes over all paths of a route that would be used to pay the given invoice.
845          * 
846          * See [`ChannelManager::send_preflight_probes`] for more information.
847          */
848         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) {
849                 long ret = bindings.preflight_probe_invoice(invoice == null ? 0 : invoice.ptr, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
850                 Reference.reachabilityFence(invoice);
851                 Reference.reachabilityFence(channelmanager);
852                 Reference.reachabilityFence(liquidity_limit_multiplier);
853                 if (ret >= 0 && ret <= 4096) { return null; }
854                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
855                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
856                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
857                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(liquidity_limit_multiplier); };
858                 return ret_hu_conv;
859         }
860
861         /**
862          * Sends payment probes over all paths of a route that would be used to pay the given zero-value
863          * invoice using the given amount.
864          * 
865          * See [`ChannelManager::send_preflight_probes`] for more information.
866          */
867         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) {
868                 long ret = bindings.preflight_probe_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msat, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr);
869                 Reference.reachabilityFence(invoice);
870                 Reference.reachabilityFence(amount_msat);
871                 Reference.reachabilityFence(channelmanager);
872                 Reference.reachabilityFence(liquidity_limit_multiplier);
873                 if (ret >= 0 && ret <= 4096) { return null; }
874                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret);
875                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); };
876                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
877                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(liquidity_limit_multiplier); };
878                 return ret_hu_conv;
879         }
880
881         /**
882          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
883          * See [`PhantomKeysManager`] for more information on phantom node payments.
884          * 
885          * `phantom_route_hints` parameter:
886          * Contains channel info for all nodes participating in the phantom invoice
887          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
888          * participating node
889          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
890          * updated when a channel becomes disabled or closes
891          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
892          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
893          * down
894          * 
895          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
896          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
897          * If `None` is provided for `payment_hash`, then one will be created.
898          * 
899          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
900          * in excess of the current time.
901          * 
902          * `duration_since_epoch` is the current time since epoch in seconds.
903          * 
904          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
905          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
906          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
907          * confirmations during routing.
908          * 
909          * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
910          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
911          * requirement).
912          * 
913          * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
914          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
915          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
916          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
917          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
918          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
919          * 
920          * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
921          * available and the current time is supplied by the caller.
922          */
923         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) {
924                 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);
925                 Reference.reachabilityFence(amt_msat);
926                 Reference.reachabilityFence(payment_hash);
927                 Reference.reachabilityFence(description);
928                 Reference.reachabilityFence(invoice_expiry_delta_secs);
929                 Reference.reachabilityFence(phantom_route_hints);
930                 Reference.reachabilityFence(entropy_source);
931                 Reference.reachabilityFence(node_signer);
932                 Reference.reachabilityFence(logger);
933                 Reference.reachabilityFence(network);
934                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
935                 Reference.reachabilityFence(duration_since_epoch);
936                 if (ret >= 0 && ret <= 4096) { return null; }
937                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
938                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
939                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
940                 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); }; };
941                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
942                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
943                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
944                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
945                 return ret_hu_conv;
946         }
947
948         /**
949          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
950          * See [`PhantomKeysManager`] for more information on phantom node payments.
951          * 
952          * `phantom_route_hints` parameter:
953          * Contains channel info for all nodes participating in the phantom invoice
954          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
955          * participating node
956          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
957          * updated when a channel becomes disabled or closes
958          * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
959          * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
960          * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
961          * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
962          * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
963          * 
964          * `description_hash` is a SHA-256 hash of the description text
965          * 
966          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
967          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
968          * If `None` is provided for `payment_hash`, then one will be created.
969          * 
970          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
971          * in excess of the current time.
972          * 
973          * `duration_since_epoch` is the current time since epoch in seconds.
974          * 
975          * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
976          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
977          * requirement).
978          * 
979          * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
980          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
981          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
982          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
983          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
984          * 
985          * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
986          * available and the current time is supplied by the caller.
987          */
988         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) {
989                 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);
990                 Reference.reachabilityFence(amt_msat);
991                 Reference.reachabilityFence(payment_hash);
992                 Reference.reachabilityFence(invoice_expiry_delta_secs);
993                 Reference.reachabilityFence(description_hash);
994                 Reference.reachabilityFence(phantom_route_hints);
995                 Reference.reachabilityFence(entropy_source);
996                 Reference.reachabilityFence(node_signer);
997                 Reference.reachabilityFence(logger);
998                 Reference.reachabilityFence(network);
999                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1000                 Reference.reachabilityFence(duration_since_epoch);
1001                 if (ret >= 0 && ret <= 4096) { return null; }
1002                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1003                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1004                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
1005                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1006                 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); }; };
1007                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
1008                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1009                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1010                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1011                 return ret_hu_conv;
1012         }
1013
1014         /**
1015          * Utility to construct an invoice. Generally, unless you want to do something like a custom
1016          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1017          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1018          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1019          * that the payment secret is valid when the invoice is paid.
1020          * 
1021          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1022          * in excess of the current time.
1023          * 
1024          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1025          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1026          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1027          * confirmations during routing.
1028          * 
1029          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1030          */
1031         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) {
1032                 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);
1033                 Reference.reachabilityFence(channelmanager);
1034                 Reference.reachabilityFence(node_signer);
1035                 Reference.reachabilityFence(logger);
1036                 Reference.reachabilityFence(network);
1037                 Reference.reachabilityFence(amt_msat);
1038                 Reference.reachabilityFence(description);
1039                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1040                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1041                 if (ret >= 0 && ret <= 4096) { return null; }
1042                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1043                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1044                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1045                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1046                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1047                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1048                 return ret_hu_conv;
1049         }
1050
1051         /**
1052          * Utility to construct an invoice. Generally, unless you want to do something like a custom
1053          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
1054          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
1055          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
1056          * that the payment secret is valid when the invoice is paid.
1057          * Use this variant if you want to pass the `description_hash` to the invoice.
1058          * 
1059          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1060          * in excess of the current time.
1061          * 
1062          * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
1063          * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1064          * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
1065          * confirmations during routing.
1066          * 
1067          * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
1068          */
1069         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) {
1070                 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);
1071                 Reference.reachabilityFence(channelmanager);
1072                 Reference.reachabilityFence(node_signer);
1073                 Reference.reachabilityFence(logger);
1074                 Reference.reachabilityFence(network);
1075                 Reference.reachabilityFence(amt_msat);
1076                 Reference.reachabilityFence(description_hash);
1077                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1078                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1079                 if (ret >= 0 && ret <= 4096) { return null; }
1080                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1081                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1082                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1083                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1084                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1085                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1086                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1087                 return ret_hu_conv;
1088         }
1089
1090         /**
1091          * See [`create_invoice_from_channelmanager_with_description_hash`]
1092          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1093          * available and the current time is supplied by the caller.
1094          */
1095         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) {
1096                 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);
1097                 Reference.reachabilityFence(channelmanager);
1098                 Reference.reachabilityFence(node_signer);
1099                 Reference.reachabilityFence(logger);
1100                 Reference.reachabilityFence(network);
1101                 Reference.reachabilityFence(amt_msat);
1102                 Reference.reachabilityFence(description_hash);
1103                 Reference.reachabilityFence(duration_since_epoch);
1104                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1105                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1106                 if (ret >= 0 && ret <= 4096) { return null; }
1107                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(description_hash); };
1113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1114                 return ret_hu_conv;
1115         }
1116
1117         /**
1118          * See [`create_invoice_from_channelmanager`]
1119          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1120          * available and the current time is supplied by the caller.
1121          */
1122         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) {
1123                 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);
1124                 Reference.reachabilityFence(channelmanager);
1125                 Reference.reachabilityFence(node_signer);
1126                 Reference.reachabilityFence(logger);
1127                 Reference.reachabilityFence(network);
1128                 Reference.reachabilityFence(amt_msat);
1129                 Reference.reachabilityFence(description);
1130                 Reference.reachabilityFence(duration_since_epoch);
1131                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1132                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1133                 if (ret >= 0 && ret <= 4096) { return null; }
1134                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1139                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1140                 return ret_hu_conv;
1141         }
1142
1143         /**
1144          * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1145          * This version allows for providing a custom [`PaymentHash`] for the invoice.
1146          * This may be useful if you're building an on-chain swap or involving another protocol where
1147          * the payment hash is also involved outside the scope of lightning.
1148          */
1149         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) {
1150                 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);
1151                 Reference.reachabilityFence(channelmanager);
1152                 Reference.reachabilityFence(node_signer);
1153                 Reference.reachabilityFence(logger);
1154                 Reference.reachabilityFence(network);
1155                 Reference.reachabilityFence(amt_msat);
1156                 Reference.reachabilityFence(description);
1157                 Reference.reachabilityFence(duration_since_epoch);
1158                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1159                 Reference.reachabilityFence(payment_hash);
1160                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1161                 if (ret >= 0 && ret <= 4096) { return null; }
1162                 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1163                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); };
1164                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
1165                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
1166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(amt_msat); };
1167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); };
1168                 return ret_hu_conv;
1169         }
1170
1171 }