[Java] Update auto-generated bindings
[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          * Constructs a new COption_NoneZ containing a
12          */
13         public static COption_NoneZ COption_NoneZ_some() {
14                 COption_NoneZ ret = bindings.COption_NoneZ_some();
15                 return ret;
16         }
17
18         /**
19          * Constructs a new COption_NoneZ containing nothing
20          */
21         public static COption_NoneZ COption_NoneZ_none() {
22                 COption_NoneZ ret = bindings.COption_NoneZ_none();
23                 return ret;
24         }
25
26         /**
27          * Read a ClosureReason from a byte array, created by ClosureReason_write
28          */
29         public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
30                 long ret = bindings.ClosureReason_read(ser);
31                 Reference.reachabilityFence(ser);
32                 if (ret >= 0 && ret <= 4096) { return null; }
33                 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Read a Event from a byte array, created by Event_write
39          */
40         public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
41                 long ret = bindings.Event_read(ser);
42                 Reference.reachabilityFence(ser);
43                 if (ret >= 0 && ret <= 4096) { return null; }
44                 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
45                 return ret_hu_conv;
46         }
47
48         /**
49          * Creates a digital signature of a message given a SecretKey, like the node's secret.
50          * 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.
51          * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
52          */
53         public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
54                 long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
55                 Reference.reachabilityFence(msg);
56                 Reference.reachabilityFence(sk);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Recovers the PublicKey of the signer of the message given the message and the signature.
64          */
65         public static Result_PublicKeyErrorZ recover_pk(byte[] msg, java.lang.String sig) {
66                 long ret = bindings.recover_pk(msg, sig);
67                 Reference.reachabilityFence(msg);
68                 Reference.reachabilityFence(sig);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
71                 return ret_hu_conv;
72         }
73
74         /**
75          * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
76          * and the PublicKey.
77          */
78         public static boolean verify(byte[] msg, java.lang.String sig, byte[] pk) {
79                 boolean ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
80                 Reference.reachabilityFence(msg);
81                 Reference.reachabilityFence(sig);
82                 Reference.reachabilityFence(pk);
83                 return ret;
84         }
85
86         /**
87          * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
88          */
89         public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
90                 byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
91                 Reference.reachabilityFence(hrp_bytes);
92                 Reference.reachabilityFence(data_without_signature);
93                 return ret;
94         }
95
96         /**
97          * Read a MonitorEvent from a byte array, created by MonitorEvent_write
98          */
99         public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
100                 long ret = bindings.MonitorEvent_read(ser);
101                 Reference.reachabilityFence(ser);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
104                 return ret_hu_conv;
105         }
106
107         /**
108          * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
109          */
110         public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, KeysInterface arg) {
111                 long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg == null ? 0 : arg.ptr);
112                 Reference.reachabilityFence(ser);
113                 Reference.reachabilityFence(arg);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
116                 ret_hu_conv.ptrs_to.add(arg);
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
122          */
123         public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(byte[] ser, KeysInterface arg_keys_manager, FeeEstimator arg_fee_estimator, Watch arg_chain_monitor, BroadcasterInterface arg_tx_broadcaster, Logger arg_logger, UserConfig arg_default_config, ChannelMonitor[] arg_channel_monitors) {
124                 long ret = bindings.C2Tuple_BlockHashChannelManagerZ_read(ser, bindings.ChannelManagerReadArgs_new(arg_keys_manager == null ? 0 : arg_keys_manager.ptr, arg_fee_estimator == null ? 0 : arg_fee_estimator.ptr, arg_chain_monitor == null ? 0 : arg_chain_monitor.ptr, arg_tx_broadcaster == null ? 0 : arg_tx_broadcaster.ptr, arg_logger == null ? 0 : arg_logger.ptr, arg_default_config == null ? 0 : arg_default_config.ptr & ~1, 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 & ~1).toArray() : null));
125                 Reference.reachabilityFence(ser);
126                 Reference.reachabilityFence(arg_keys_manager);
127                 Reference.reachabilityFence(arg_fee_estimator);
128                 Reference.reachabilityFence(arg_chain_monitor);
129                 Reference.reachabilityFence(arg_tx_broadcaster);
130                 Reference.reachabilityFence(arg_logger);
131                 Reference.reachabilityFence(arg_default_config);
132                 Reference.reachabilityFence(arg_channel_monitors);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
135                 ret_hu_conv.ptrs_to.add(arg_keys_manager);
136                 ret_hu_conv.ptrs_to.add(arg_fee_estimator);
137                 ret_hu_conv.ptrs_to.add(arg_chain_monitor);
138                 ret_hu_conv.ptrs_to.add(arg_tx_broadcaster);
139                 ret_hu_conv.ptrs_to.add(arg_logger);
140                 ;
141                 for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); };
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Gets the weight for an HTLC-Success transaction.
147          */
148         public static long htlc_success_tx_weight(boolean opt_anchors) {
149                 long ret = bindings.htlc_success_tx_weight(opt_anchors);
150                 Reference.reachabilityFence(opt_anchors);
151                 return ret;
152         }
153
154         /**
155          * Gets the weight for an HTLC-Timeout transaction.
156          */
157         public static long htlc_timeout_tx_weight(boolean opt_anchors) {
158                 long ret = bindings.htlc_timeout_tx_weight(opt_anchors);
159                 Reference.reachabilityFence(opt_anchors);
160                 return ret;
161         }
162
163         /**
164          * Build the commitment secret from the seed and the commitment number
165          */
166         public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
167                 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
168                 Reference.reachabilityFence(commitment_seed);
169                 Reference.reachabilityFence(idx);
170                 return ret;
171         }
172
173         /**
174          * Build a closing transaction
175          */
176         public static byte[] build_closing_transaction(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, OutPoint funding_outpoint) {
177                 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 & ~1);
178                 Reference.reachabilityFence(to_holder_value_sat);
179                 Reference.reachabilityFence(to_counterparty_value_sat);
180                 Reference.reachabilityFence(to_holder_script);
181                 Reference.reachabilityFence(to_counterparty_script);
182                 Reference.reachabilityFence(funding_outpoint);
183                 return ret;
184         }
185
186         /**
187          * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
188          * from the base secret and the per_commitment_point.
189          * 
190          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
191          * generated (ie our own).
192          */
193         public static Result_SecretKeyErrorZ derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
194                 long ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
195                 Reference.reachabilityFence(per_commitment_point);
196                 Reference.reachabilityFence(base_secret);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
204          * from the base point and the per_commitment_key. This is the public equivalent of
205          * derive_private_key - using only public keys to derive a public key instead of private keys.
206          * 
207          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
208          * generated (ie our own).
209          */
210         public static Result_PublicKeyErrorZ derive_public_key(byte[] per_commitment_point, byte[] base_point) {
211                 long ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
212                 Reference.reachabilityFence(per_commitment_point);
213                 Reference.reachabilityFence(base_point);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
216                 return ret_hu_conv;
217         }
218
219         /**
220          * Derives a per-commitment-transaction revocation key from its constituent parts.
221          * 
222          * Only the cheating participant owns a valid witness to propagate a revoked
223          * commitment transaction, thus per_commitment_secret always come from cheater
224          * and revocation_base_secret always come from punisher, which is the broadcaster
225          * of the transaction spending with this key knowledge.
226          * 
227          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
228          * generated (ie our own).
229          */
230         public static Result_SecretKeyErrorZ derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
231                 long ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
232                 Reference.reachabilityFence(per_commitment_secret);
233                 Reference.reachabilityFence(countersignatory_revocation_base_secret);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
241          * the public equivalend of derive_private_revocation_key - using only public keys to derive a
242          * public key instead of private keys.
243          * 
244          * Only the cheating participant owns a valid witness to propagate a revoked
245          * commitment transaction, thus per_commitment_point always come from cheater
246          * and revocation_base_point always come from punisher, which is the broadcaster
247          * of the transaction spending with this key knowledge.
248          * 
249          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
250          * generated (ie our own).
251          */
252         public static Result_PublicKeyErrorZ derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
253                 long ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
254                 Reference.reachabilityFence(per_commitment_point);
255                 Reference.reachabilityFence(countersignatory_revocation_base_point);
256                 if (ret >= 0 && ret <= 4096) { return null; }
257                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
258                 return ret_hu_conv;
259         }
260
261         /**
262          * A script either spendable by the revocation
263          * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
264          * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
265          */
266         public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
267                 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
268                 Reference.reachabilityFence(revocation_key);
269                 Reference.reachabilityFence(contest_delay);
270                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
271                 return ret;
272         }
273
274         /**
275          * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
276          * does not need to have its previous_output_index filled.
277          */
278         public static byte[] get_htlc_redeemscript(HTLCOutputInCommitment htlc, boolean opt_anchors, TxCreationKeys keys) {
279                 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr & ~1, opt_anchors, keys == null ? 0 : keys.ptr & ~1);
280                 Reference.reachabilityFence(htlc);
281                 Reference.reachabilityFence(opt_anchors);
282                 Reference.reachabilityFence(keys);
283                 return ret;
284         }
285
286         /**
287          * Gets the redeemscript for a funding output from the two funding public keys.
288          * Note that the order of funding public keys does not matter.
289          */
290         public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
291                 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
292                 Reference.reachabilityFence(broadcaster);
293                 Reference.reachabilityFence(countersignatory);
294                 return ret;
295         }
296
297         /**
298          * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
299          * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
300          * transaction which needs signing, and can be used to construct an HTLC transaction which is
301          * broadcastable given a counterparty HTLC signature.
302          * 
303          * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
304          * commitment transaction).
305          */
306         public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, HTLCOutputInCommitment htlc, boolean opt_anchors, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
307                 byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr & ~1, opt_anchors, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
308                 Reference.reachabilityFence(commitment_txid);
309                 Reference.reachabilityFence(feerate_per_kw);
310                 Reference.reachabilityFence(contest_delay);
311                 Reference.reachabilityFence(htlc);
312                 Reference.reachabilityFence(opt_anchors);
313                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
314                 Reference.reachabilityFence(revocation_key);
315                 return ret;
316         }
317
318         /**
319          * Gets the witnessScript for an anchor output from the funding public key.
320          * The witness in the spending input must be:
321          * <BIP 143 funding_signature>
322          * After 16 blocks of confirmation, an alternative satisfying witness could be:
323          * <>
324          * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
325          */
326         public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
327                 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
328                 Reference.reachabilityFence(funding_pubkey);
329                 return ret;
330         }
331
332         /**
333          * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
334          * shared secret first. This prevents on-chain observers from discovering how many commitment
335          * transactions occurred in a channel before it was closed.
336          * 
337          * This function gets the shared secret from relevant channel public keys and can be used to
338          * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
339          */
340         public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
341                 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);
342                 Reference.reachabilityFence(broadcaster_payment_basepoint);
343                 Reference.reachabilityFence(countersignatory_payment_basepoint);
344                 Reference.reachabilityFence(outbound_from_broadcaster);
345                 return ret;
346         }
347
348         /**
349          * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
350          */
351         public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
352                 long ret = bindings.NetworkUpdate_read(ser);
353                 Reference.reachabilityFence(ser);
354                 if (ret >= 0 && ret <= 4096) { return null; }
355                 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
356                 return ret_hu_conv;
357         }
358
359         /**
360          * Finds a route from us (payer) to the given target node (payee).
361          * 
362          * If the payee provided features in their invoice, they should be provided via `params.payee`.
363          * Without this, MPP will only be used if the payee's features are available in the network graph.
364          * 
365          * Private routing paths between a public node and the target may be included in `params.payee`.
366          * 
367          * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
368          * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of our local
369          * channels from [`NetworkGraph`] will be ignored, and only those in `first_hops` will be used.
370          * 
371          * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
372          * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
373          * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
374          * 
375          * # Note
376          * 
377          * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
378          * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
379          * function.
380          * 
381          * # Panics
382          * 
383          * Panics if first_hops contains channels without short_channel_ids;
384          * [`ChannelManager::list_usable_channels`] will never include such channels.
385          * 
386          * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
387          * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
388          * 
389          * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
390          */
391         public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, RouteParameters route_params, NetworkGraph network, @Nullable ChannelDetails[] first_hops, Logger logger, Score scorer, byte[] random_seed_bytes) {
392                 long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), route_params == null ? 0 : route_params.ptr & ~1, network == null ? 0 : network.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
393                 Reference.reachabilityFence(our_node_pubkey);
394                 Reference.reachabilityFence(route_params);
395                 Reference.reachabilityFence(network);
396                 Reference.reachabilityFence(first_hops);
397                 Reference.reachabilityFence(logger);
398                 Reference.reachabilityFence(scorer);
399                 Reference.reachabilityFence(random_seed_bytes);
400                 if (ret >= 0 && ret <= 4096) { return null; }
401                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
402                 ret_hu_conv.ptrs_to.add(route_params);
403                 ret_hu_conv.ptrs_to.add(network);
404                 for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
405                 ret_hu_conv.ptrs_to.add(logger);
406                 ret_hu_conv.ptrs_to.add(scorer);
407                 return ret_hu_conv;
408         }
409
410         /**
411          * Writes the provided `ChannelManager` to the path provided at `FilesystemPersister`
412          * initialization, within a file called \"manager\".
413          */
414         public static Result_NoneErrorZ FilesystemPersister_persist_manager(java.lang.String data_dir, ChannelManager manager) {
415                 long ret = bindings.FilesystemPersister_persist_manager(data_dir, manager == null ? 0 : manager.ptr & ~1);
416                 Reference.reachabilityFence(data_dir);
417                 Reference.reachabilityFence(manager);
418                 if (ret >= 0 && ret <= 4096) { return null; }
419                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
420                 ret_hu_conv.ptrs_to.add(manager);
421                 return ret_hu_conv;
422         }
423
424         /**
425          * Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
426          * initialization, within a file called \"network_graph\"
427          */
428         public static Result_NoneErrorZ FilesystemPersister_persist_network_graph(java.lang.String data_dir, NetworkGraph network_graph) {
429                 long ret = bindings.FilesystemPersister_persist_network_graph(data_dir, network_graph == null ? 0 : network_graph.ptr & ~1);
430                 Reference.reachabilityFence(data_dir);
431                 Reference.reachabilityFence(network_graph);
432                 if (ret >= 0 && ret <= 4096) { return null; }
433                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
434                 ret_hu_conv.ptrs_to.add(network_graph);
435                 return ret_hu_conv;
436         }
437
438         /**
439          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
440          * See [`PhantomKeysManager`] for more information on phantom node payments.
441          * 
442          * `phantom_route_hints` parameter:
443          * Contains channel info for all nodes participating in the phantom invoice
444          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
445          * participating node
446          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
447          * updated when a channel becomes disabled or closes
448          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
449          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
450          * down
451          * 
452          * `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
453          * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
454          * participating node.
455          * 
456          * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
457          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
458          * requirement).
459          * 
460          * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
461          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
462          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
463          */
464         public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice(Option_u64Z amt_msat, java.lang.String description, byte[] payment_hash, byte[] payment_secret, PhantomRouteHints[] phantom_route_hints, KeysInterface keys_manager, org.ldk.enums.Currency network) {
465                 long ret = bindings.create_phantom_invoice(amt_msat.ptr, description, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), 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 & ~1).toArray() : null, keys_manager == null ? 0 : keys_manager.ptr, network);
466                 Reference.reachabilityFence(amt_msat);
467                 Reference.reachabilityFence(description);
468                 Reference.reachabilityFence(payment_hash);
469                 Reference.reachabilityFence(payment_secret);
470                 Reference.reachabilityFence(phantom_route_hints);
471                 Reference.reachabilityFence(keys_manager);
472                 Reference.reachabilityFence(network);
473                 if (ret >= 0 && ret <= 4096) { return null; }
474                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
475                 ret_hu_conv.ptrs_to.add(keys_manager);
476                 return ret_hu_conv;
477         }
478
479         /**
480          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
481          * See [`PhantomKeysManager`] for more information on phantom node payments.
482          * 
483          * `phantom_route_hints` parameter:
484          * Contains channel info for all nodes participating in the phantom invoice
485          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
486          * participating node
487          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
488          * updated when a channel becomes disabled or closes
489          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
490          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
491          * down
492          * 
493          * `description_hash` is a SHA-256 hash of the description text
494          * 
495          * `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
496          * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
497          * participating node.
498          * 
499          * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
500          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
501          * requirement).
502          * 
503          * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
504          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
505          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
506          */
507         public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(Option_u64Z amt_msat, Sha256 description_hash, byte[] payment_hash, byte[] payment_secret, PhantomRouteHints[] phantom_route_hints, KeysInterface keys_manager, org.ldk.enums.Currency network) {
508                 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), 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 & ~1).toArray() : null, keys_manager == null ? 0 : keys_manager.ptr, network);
509                 Reference.reachabilityFence(amt_msat);
510                 Reference.reachabilityFence(description_hash);
511                 Reference.reachabilityFence(payment_hash);
512                 Reference.reachabilityFence(payment_secret);
513                 Reference.reachabilityFence(phantom_route_hints);
514                 Reference.reachabilityFence(keys_manager);
515                 Reference.reachabilityFence(network);
516                 if (ret >= 0 && ret <= 4096) { return null; }
517                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
518                 ret_hu_conv.ptrs_to.add(keys_manager);
519                 return ret_hu_conv;
520         }
521
522         /**
523          * Utility to construct an invoice. Generally, unless you want to do something like a custom
524          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
525          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
526          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
527          * that the payment secret is valid when the invoice is paid.
528          */
529         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, java.lang.String description) {
530                 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description);
531                 Reference.reachabilityFence(channelmanager);
532                 Reference.reachabilityFence(keys_manager);
533                 Reference.reachabilityFence(network);
534                 Reference.reachabilityFence(amt_msat);
535                 Reference.reachabilityFence(description);
536                 if (ret >= 0 && ret <= 4096) { return null; }
537                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
538                 ret_hu_conv.ptrs_to.add(channelmanager);
539                 ret_hu_conv.ptrs_to.add(keys_manager);
540                 return ret_hu_conv;
541         }
542
543         /**
544          * Utility to construct an invoice. Generally, unless you want to do something like a custom
545          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
546          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
547          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
548          * that the payment secret is valid when the invoice is paid.
549          * Use this variant if you want to pass the `description_hash` to the invoice.
550          */
551         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, Sha256 description_hash) {
552                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1);
553                 Reference.reachabilityFence(channelmanager);
554                 Reference.reachabilityFence(keys_manager);
555                 Reference.reachabilityFence(network);
556                 Reference.reachabilityFence(amt_msat);
557                 Reference.reachabilityFence(description_hash);
558                 if (ret >= 0 && ret <= 4096) { return null; }
559                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
560                 ret_hu_conv.ptrs_to.add(channelmanager);
561                 ret_hu_conv.ptrs_to.add(keys_manager);
562                 return ret_hu_conv;
563         }
564
565         /**
566          * See [`create_invoice_from_channelmanager_with_description_hash`]
567          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
568          * available and the current time is supplied by the caller.
569          */
570         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, Sha256 description_hash, long duration_since_epoch) {
571                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr & ~1, duration_since_epoch);
572                 Reference.reachabilityFence(channelmanager);
573                 Reference.reachabilityFence(keys_manager);
574                 Reference.reachabilityFence(network);
575                 Reference.reachabilityFence(amt_msat);
576                 Reference.reachabilityFence(description_hash);
577                 Reference.reachabilityFence(duration_since_epoch);
578                 if (ret >= 0 && ret <= 4096) { return null; }
579                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
580                 ret_hu_conv.ptrs_to.add(channelmanager);
581                 ret_hu_conv.ptrs_to.add(keys_manager);
582                 return ret_hu_conv;
583         }
584
585         /**
586          * See [`create_invoice_from_channelmanager`]
587          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
588          * available and the current time is supplied by the caller.
589          */
590         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, java.lang.String description, long duration_since_epoch) {
591                 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description, duration_since_epoch);
592                 Reference.reachabilityFence(channelmanager);
593                 Reference.reachabilityFence(keys_manager);
594                 Reference.reachabilityFence(network);
595                 Reference.reachabilityFence(amt_msat);
596                 Reference.reachabilityFence(description);
597                 Reference.reachabilityFence(duration_since_epoch);
598                 if (ret >= 0 && ret <= 4096) { return null; }
599                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
600                 ret_hu_conv.ptrs_to.add(channelmanager);
601                 ret_hu_conv.ptrs_to.add(keys_manager);
602                 return ret_hu_conv;
603         }
604
605 }