624cb60a3715bab286d65af68a0a4c5440d08525
[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          * Read a MonitorEvent from a byte array, created by MonitorEvent_write
88          */
89         public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
90                 long ret = bindings.MonitorEvent_read(ser);
91                 Reference.reachabilityFence(ser);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
99          */
100         public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, KeysInterface arg) {
101                 long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg == null ? 0 : arg.ptr);
102                 Reference.reachabilityFence(ser);
103                 Reference.reachabilityFence(arg);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
106                 ret_hu_conv.ptrs_to.add(arg);
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
112          */
113         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) {
114                 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));
115                 Reference.reachabilityFence(ser);
116                 Reference.reachabilityFence(arg_keys_manager);
117                 Reference.reachabilityFence(arg_fee_estimator);
118                 Reference.reachabilityFence(arg_chain_monitor);
119                 Reference.reachabilityFence(arg_tx_broadcaster);
120                 Reference.reachabilityFence(arg_logger);
121                 Reference.reachabilityFence(arg_default_config);
122                 Reference.reachabilityFence(arg_channel_monitors);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
125                 ret_hu_conv.ptrs_to.add(arg_keys_manager);
126                 ret_hu_conv.ptrs_to.add(arg_fee_estimator);
127                 ret_hu_conv.ptrs_to.add(arg_chain_monitor);
128                 ret_hu_conv.ptrs_to.add(arg_tx_broadcaster);
129                 ret_hu_conv.ptrs_to.add(arg_logger);
130                 ;
131                 for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Gets the weight for an HTLC-Success transaction.
137          */
138         public static long htlc_success_tx_weight(boolean opt_anchors) {
139                 long ret = bindings.htlc_success_tx_weight(opt_anchors);
140                 Reference.reachabilityFence(opt_anchors);
141                 return ret;
142         }
143
144         /**
145          * Gets the weight for an HTLC-Timeout transaction.
146          */
147         public static long htlc_timeout_tx_weight(boolean opt_anchors) {
148                 long ret = bindings.htlc_timeout_tx_weight(opt_anchors);
149                 Reference.reachabilityFence(opt_anchors);
150                 return ret;
151         }
152
153         /**
154          * Build the commitment secret from the seed and the commitment number
155          */
156         public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
157                 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
158                 Reference.reachabilityFence(commitment_seed);
159                 Reference.reachabilityFence(idx);
160                 return ret;
161         }
162
163         /**
164          * Build a closing transaction
165          */
166         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) {
167                 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);
168                 Reference.reachabilityFence(to_holder_value_sat);
169                 Reference.reachabilityFence(to_counterparty_value_sat);
170                 Reference.reachabilityFence(to_holder_script);
171                 Reference.reachabilityFence(to_counterparty_script);
172                 Reference.reachabilityFence(funding_outpoint);
173                 return ret;
174         }
175
176         /**
177          * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
178          * from the base secret and the per_commitment_point.
179          * 
180          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
181          * generated (ie our own).
182          */
183         public static Result_SecretKeyErrorZ derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
184                 long ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
185                 Reference.reachabilityFence(per_commitment_point);
186                 Reference.reachabilityFence(base_secret);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
189                 return ret_hu_conv;
190         }
191
192         /**
193          * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
194          * from the base point and the per_commitment_key. This is the public equivalent of
195          * derive_private_key - using only public keys to derive a public key instead of private keys.
196          * 
197          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
198          * generated (ie our own).
199          */
200         public static Result_PublicKeyErrorZ derive_public_key(byte[] per_commitment_point, byte[] base_point) {
201                 long ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
202                 Reference.reachabilityFence(per_commitment_point);
203                 Reference.reachabilityFence(base_point);
204                 if (ret >= 0 && ret <= 4096) { return null; }
205                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
206                 return ret_hu_conv;
207         }
208
209         /**
210          * Derives a per-commitment-transaction revocation key from its constituent parts.
211          * 
212          * Only the cheating participant owns a valid witness to propagate a revoked
213          * commitment transaction, thus per_commitment_secret always come from cheater
214          * and revocation_base_secret always come from punisher, which is the broadcaster
215          * of the transaction spending with this key knowledge.
216          * 
217          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
218          * generated (ie our own).
219          */
220         public static Result_SecretKeyErrorZ derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
221                 long ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
222                 Reference.reachabilityFence(per_commitment_secret);
223                 Reference.reachabilityFence(countersignatory_revocation_base_secret);
224                 if (ret >= 0 && ret <= 4096) { return null; }
225                 Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
226                 return ret_hu_conv;
227         }
228
229         /**
230          * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
231          * the public equivalend of derive_private_revocation_key - using only public keys to derive a
232          * public key instead of private keys.
233          * 
234          * Only the cheating participant owns a valid witness to propagate a revoked
235          * commitment transaction, thus per_commitment_point always come from cheater
236          * and revocation_base_point always come from punisher, which is the broadcaster
237          * of the transaction spending with this key knowledge.
238          * 
239          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
240          * generated (ie our own).
241          */
242         public static Result_PublicKeyErrorZ derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
243                 long ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
244                 Reference.reachabilityFence(per_commitment_point);
245                 Reference.reachabilityFence(countersignatory_revocation_base_point);
246                 if (ret >= 0 && ret <= 4096) { return null; }
247                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
248                 return ret_hu_conv;
249         }
250
251         /**
252          * A script either spendable by the revocation
253          * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
254          * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
255          */
256         public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
257                 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
258                 Reference.reachabilityFence(revocation_key);
259                 Reference.reachabilityFence(contest_delay);
260                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
261                 return ret;
262         }
263
264         /**
265          * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
266          * does not need to have its previous_output_index filled.
267          */
268         public static byte[] get_htlc_redeemscript(HTLCOutputInCommitment htlc, boolean opt_anchors, TxCreationKeys keys) {
269                 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr & ~1, opt_anchors, keys == null ? 0 : keys.ptr & ~1);
270                 Reference.reachabilityFence(htlc);
271                 Reference.reachabilityFence(opt_anchors);
272                 Reference.reachabilityFence(keys);
273                 return ret;
274         }
275
276         /**
277          * Gets the redeemscript for a funding output from the two funding public keys.
278          * Note that the order of funding public keys does not matter.
279          */
280         public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
281                 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
282                 Reference.reachabilityFence(broadcaster);
283                 Reference.reachabilityFence(countersignatory);
284                 return ret;
285         }
286
287         /**
288          * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
289          * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
290          * transaction which needs signing, and can be used to construct an HTLC transaction which is
291          * broadcastable given a counterparty HTLC signature.
292          * 
293          * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
294          * commitment transaction).
295          */
296         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) {
297                 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));
298                 Reference.reachabilityFence(commitment_txid);
299                 Reference.reachabilityFence(feerate_per_kw);
300                 Reference.reachabilityFence(contest_delay);
301                 Reference.reachabilityFence(htlc);
302                 Reference.reachabilityFence(opt_anchors);
303                 Reference.reachabilityFence(broadcaster_delayed_payment_key);
304                 Reference.reachabilityFence(revocation_key);
305                 return ret;
306         }
307
308         /**
309          * Gets the witnessScript for an anchor output from the funding public key.
310          * The witness in the spending input must be:
311          * <BIP 143 funding_signature>
312          * After 16 blocks of confirmation, an alternative satisfying witness could be:
313          * <>
314          * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
315          */
316         public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
317                 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
318                 Reference.reachabilityFence(funding_pubkey);
319                 return ret;
320         }
321
322         /**
323          * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
324          * shared secret first. This prevents on-chain observers from discovering how many commitment
325          * transactions occurred in a channel before it was closed.
326          * 
327          * This function gets the shared secret from relevant channel public keys and can be used to
328          * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
329          */
330         public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, boolean outbound_from_broadcaster) {
331                 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);
332                 Reference.reachabilityFence(broadcaster_payment_basepoint);
333                 Reference.reachabilityFence(countersignatory_payment_basepoint);
334                 Reference.reachabilityFence(outbound_from_broadcaster);
335                 return ret;
336         }
337
338         /**
339          * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
340          */
341         public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
342                 long ret = bindings.NetworkUpdate_read(ser);
343                 Reference.reachabilityFence(ser);
344                 if (ret >= 0 && ret <= 4096) { return null; }
345                 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
346                 return ret_hu_conv;
347         }
348
349         /**
350          * Finds a route from us (payer) to the given target node (payee).
351          * 
352          * If the payee provided features in their invoice, they should be provided via `params.payee`.
353          * Without this, MPP will only be used if the payee's features are available in the network graph.
354          * 
355          * Private routing paths between a public node and the target may be included in `params.payee`.
356          * 
357          * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
358          * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of our local
359          * channels from [`NetworkGraph`] will be ignored, and only those in `first_hops` will be used.
360          * 
361          * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
362          * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
363          * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
364          * 
365          * # Note
366          * 
367          * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
368          * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
369          * function.
370          * 
371          * # Panics
372          * 
373          * Panics if first_hops contains channels without short_channel_ids;
374          * [`ChannelManager::list_usable_channels`] will never include such channels.
375          * 
376          * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
377          * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
378          * 
379          * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
380          */
381         public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, RouteParameters params, NetworkGraph network, @Nullable ChannelDetails[] first_hops, Logger logger, Score scorer) {
382                 long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), params == null ? 0 : 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);
383                 Reference.reachabilityFence(our_node_pubkey);
384                 Reference.reachabilityFence(params);
385                 Reference.reachabilityFence(network);
386                 Reference.reachabilityFence(first_hops);
387                 Reference.reachabilityFence(logger);
388                 Reference.reachabilityFence(scorer);
389                 if (ret >= 0 && ret <= 4096) { return null; }
390                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
391                 ret_hu_conv.ptrs_to.add(params);
392                 ret_hu_conv.ptrs_to.add(network);
393                 for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
394                 ret_hu_conv.ptrs_to.add(logger);
395                 ret_hu_conv.ptrs_to.add(scorer);
396                 return ret_hu_conv;
397         }
398
399         /**
400          * Writes the provided `ChannelManager` to the path provided at `FilesystemPersister`
401          * initialization, within a file called \"manager\".
402          */
403         public static Result_NoneErrorZ FilesystemPersister_persist_manager(java.lang.String data_dir, ChannelManager manager) {
404                 long ret = bindings.FilesystemPersister_persist_manager(data_dir, manager == null ? 0 : manager.ptr & ~1);
405                 Reference.reachabilityFence(data_dir);
406                 Reference.reachabilityFence(manager);
407                 if (ret >= 0 && ret <= 4096) { return null; }
408                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
409                 ret_hu_conv.ptrs_to.add(manager);
410                 return ret_hu_conv;
411         }
412
413         /**
414          * Utility to construct an invoice. Generally, unless you want to do something like a custom
415          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
416          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
417          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
418          * that the payment secret is valid when the invoice is paid.
419          */
420         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) {
421                 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);
422                 Reference.reachabilityFence(channelmanager);
423                 Reference.reachabilityFence(keys_manager);
424                 Reference.reachabilityFence(network);
425                 Reference.reachabilityFence(amt_msat);
426                 Reference.reachabilityFence(description);
427                 if (ret >= 0 && ret <= 4096) { return null; }
428                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
429                 ret_hu_conv.ptrs_to.add(channelmanager);
430                 ret_hu_conv.ptrs_to.add(keys_manager);
431                 return ret_hu_conv;
432         }
433
434 }