[C#] Check in initial auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / UtilMethods.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using org.ldk.structs;
5 using System;
6
7 namespace org { namespace ldk { namespace util {
8 public class UtilMethods {
9         /**
10          * Gets the 128-bit integer, as 16 little-endian bytes
11          */
12         public static byte[] U128_le_bytes(org.ldk.util.UInt128 val) {
13                 byte[] ret = bindings.U128_le_bytes(val.getLEBytes());
14                 GC.KeepAlive(val);
15                 return ret;
16         }
17
18         /**
19          * Constructs a new U128 from 16 little-endian bytes
20          */
21         public static UInt128 U128_new(byte[] le_bytes) {
22                 byte[] ret = bindings.U128_new(InternalUtils.check_arr_len(le_bytes, 16));
23                 GC.KeepAlive(le_bytes);
24                 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
25                 return ret_conv;
26         }
27
28         /**
29          * Constructs a new COption_NoneZ containing a
30          */
31         public static COption_NoneZ COption_NoneZ_some() {
32                 COption_NoneZ ret = bindings.COption_NoneZ_some();
33                 return ret;
34         }
35
36         /**
37          * Constructs a new COption_NoneZ containing nothing
38          */
39         public static COption_NoneZ COption_NoneZ_none() {
40                 COption_NoneZ ret = bindings.COption_NoneZ_none();
41                 return ret;
42         }
43
44         /**
45          * Read a ClosureReason from a byte array, created by ClosureReason_write
46          */
47         public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
48                 long ret = bindings.ClosureReason_read(ser);
49                 GC.KeepAlive(ser);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
52                 return ret_hu_conv;
53         }
54
55         /**
56          * Read a HTLCDestination from a byte array, created by HTLCDestination_write
57          */
58         public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
59                 long ret = bindings.HTLCDestination_read(ser);
60                 GC.KeepAlive(ser);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Read a Event from a byte array, created by Event_write
68          */
69         public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
70                 long ret = bindings.Event_read(ser);
71                 GC.KeepAlive(ser);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Creates a digital signature of a message given a SecretKey, like the node's secret.
79          * 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.
80          * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
81          */
82         public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
83                 long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
84                 GC.KeepAlive(msg);
85                 GC.KeepAlive(sk);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
88                 return ret_hu_conv;
89         }
90
91         /**
92          * Recovers the PublicKey of the signer of the message given the message and the signature.
93          */
94         public static Result_PublicKeyErrorZ recover_pk(byte[] msg, string sig) {
95                 long ret = bindings.recover_pk(msg, sig);
96                 GC.KeepAlive(msg);
97                 GC.KeepAlive(sig);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
100                 return ret_hu_conv;
101         }
102
103         /**
104          * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
105          * and the PublicKey.
106          */
107         public static bool verify(byte[] msg, string sig, byte[] pk) {
108                 bool ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
109                 GC.KeepAlive(msg);
110                 GC.KeepAlive(sig);
111                 GC.KeepAlive(pk);
112                 return ret;
113         }
114
115         /**
116          * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
117          */
118         public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
119                 byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
120                 GC.KeepAlive(hrp_bytes);
121                 GC.KeepAlive(data_without_signature);
122                 return ret;
123         }
124
125         /**
126          * Read a MonitorEvent from a byte array, created by MonitorEvent_write
127          */
128         public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
129                 long ret = bindings.MonitorEvent_read(ser);
130                 GC.KeepAlive(ser);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
133                 return ret_hu_conv;
134         }
135
136         /**
137          * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
138          */
139         public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, org.ldk.structs.KeysInterface arg) {
140                 long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg == null ? 0 : arg.ptr);
141                 GC.KeepAlive(ser);
142                 GC.KeepAlive(arg);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Fetches the set of [`NodeFeatures`] flags which are provided by or required by
151          * [`ChannelManager`].
152          */
153         public static NodeFeatures provided_node_features() {
154                 long ret = bindings.provided_node_features();
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
163          * [`ChannelManager`].
164          */
165         public static ChannelFeatures provided_channel_features() {
166                 long ret = bindings.provided_channel_features();
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
169                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
170                 return ret_hu_conv;
171         }
172
173         /**
174          * Fetches the set of [`InitFeatures`] flags which are provided by or required by
175          * [`ChannelManager`].
176          */
177         public static InitFeatures provided_init_features() {
178                 long ret = bindings.provided_init_features();
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
182                 return ret_hu_conv;
183         }
184
185         /**
186          * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
187          */
188         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) {
189                 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, arg_channel_monitors != null ? InternalUtils.mapArray(arg_channel_monitors, arg_channel_monitors_conv_16 => arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr) : null));
190                 GC.KeepAlive(ser);
191                 GC.KeepAlive(arg_keys_manager);
192                 GC.KeepAlive(arg_fee_estimator);
193                 GC.KeepAlive(arg_chain_monitor);
194                 GC.KeepAlive(arg_tx_broadcaster);
195                 GC.KeepAlive(arg_logger);
196                 GC.KeepAlive(arg_default_config);
197                 GC.KeepAlive(arg_channel_monitors);
198                 if (ret >= 0 && ret <= 4096) { return null; }
199                 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
200                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_keys_manager); };
201                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_fee_estimator); };
202                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_chain_monitor); };
203                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_tx_broadcaster); };
204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_logger); };
205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_default_config); };
206                 foreach (ChannelMonitor arg_channel_monitors_conv_16 in arg_channel_monitors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_channel_monitors_conv_16); }; };
207                 return ret_hu_conv;
208         }
209
210         /**
211          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
212          * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
213          * a `ChannelManager`.
214          * 
215          * `keys` is generated by calling [`KeysInterface::get_inbound_payment_key_material`] and then
216          * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
217          * regenerate it for each new inbound payment.
218          * 
219          * `current_time` is a Unix timestamp representing the current time.
220          * 
221          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
222          */
223         public static Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create(org.ldk.structs.ExpandedKey keys, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs, org.ldk.structs.KeysInterface keys_manager, long current_time) {
224                 long ret = bindings.create(keys == null ? 0 : keys.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, keys_manager == null ? 0 : keys_manager.ptr, current_time);
225                 GC.KeepAlive(keys);
226                 GC.KeepAlive(min_value_msat);
227                 GC.KeepAlive(invoice_expiry_delta_secs);
228                 GC.KeepAlive(keys_manager);
229                 GC.KeepAlive(current_time);
230                 if (ret >= 0 && ret <= 4096) { return null; }
231                 Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
232                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
233                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
234                 return ret_hu_conv;
235         }
236
237         /**
238          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
239          * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
240          * without a `ChannelManager`.
241          * 
242          * See [`create`] for information on the `keys` and `current_time` parameters.
243          * 
244          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
245          */
246         public static Result_PaymentSecretNoneZ 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) {
247                 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);
248                 GC.KeepAlive(keys);
249                 GC.KeepAlive(min_value_msat);
250                 GC.KeepAlive(payment_hash);
251                 GC.KeepAlive(invoice_expiry_delta_secs);
252                 GC.KeepAlive(current_time);
253                 if (ret >= 0 && ret <= 4096) { return null; }
254                 Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
255                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
256                 return ret_hu_conv;
257         }
258
259         /**
260          * Gets the weight for an HTLC-Success transaction.
261          */
262         public static long htlc_success_tx_weight(bool opt_anchors) {
263                 long ret = bindings.htlc_success_tx_weight(opt_anchors);
264                 GC.KeepAlive(opt_anchors);
265                 return ret;
266         }
267
268         /**
269          * Gets the weight for an HTLC-Timeout transaction.
270          */
271         public static long htlc_timeout_tx_weight(bool opt_anchors) {
272                 long ret = bindings.htlc_timeout_tx_weight(opt_anchors);
273                 GC.KeepAlive(opt_anchors);
274                 return ret;
275         }
276
277         /**
278          * Check if a given input witness attempts to claim a HTLC.
279          */
280         public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
281                 long ret = bindings.HTLCClaim_from_witness(witness);
282                 GC.KeepAlive(witness);
283                 if (ret >= 0 && ret <= 4096) { return null; }
284                 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
285                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
286                 return ret_hu_conv;
287         }
288
289         /**
290          * Build the commitment secret from the seed and the commitment number
291          */
292         public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
293                 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
294                 GC.KeepAlive(commitment_seed);
295                 GC.KeepAlive(idx);
296                 return ret;
297         }
298
299         /**
300          * Build a closing transaction
301          */
302         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) {
303                 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);
304                 GC.KeepAlive(to_holder_value_sat);
305                 GC.KeepAlive(to_counterparty_value_sat);
306                 GC.KeepAlive(to_holder_script);
307                 GC.KeepAlive(to_counterparty_script);
308                 GC.KeepAlive(funding_outpoint);
309                 return ret;
310         }
311
312         /**
313          * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
314          * from the base secret and the per_commitment_point.
315          */
316         public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
317                 byte[] ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
318                 GC.KeepAlive(per_commitment_point);
319                 GC.KeepAlive(base_secret);
320                 return ret;
321         }
322
323         /**
324          * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
325          * from the base point and the per_commitment_key. This is the public equivalent of
326          * derive_private_key - using only public keys to derive a public key instead of private keys.
327          */
328         public static byte[] derive_public_key(byte[] per_commitment_point, byte[] base_point) {
329                 byte[] ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
330                 GC.KeepAlive(per_commitment_point);
331                 GC.KeepAlive(base_point);
332                 return ret;
333         }
334
335         /**
336          * Derives a per-commitment-transaction revocation key from its constituent parts.
337          * 
338          * Only the cheating participant owns a valid witness to propagate a revoked
339          * commitment transaction, thus per_commitment_secret always come from cheater
340          * and revocation_base_secret always come from punisher, which is the broadcaster
341          * of the transaction spending with this key knowledge.
342          */
343         public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
344                 byte[] ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
345                 GC.KeepAlive(per_commitment_secret);
346                 GC.KeepAlive(countersignatory_revocation_base_secret);
347                 return ret;
348         }
349
350         /**
351          * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
352          * the public equivalend of derive_private_revocation_key - using only public keys to derive a
353          * public key instead of private keys.
354          * 
355          * Only the cheating participant owns a valid witness to propagate a revoked
356          * commitment transaction, thus per_commitment_point always come from cheater
357          * and revocation_base_point always come from punisher, which is the broadcaster
358          * of the transaction spending with this key knowledge.
359          * 
360          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
361          * generated (ie our own).
362          */
363         public static byte[] derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
364                 byte[] ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
365                 GC.KeepAlive(per_commitment_point);
366                 GC.KeepAlive(countersignatory_revocation_base_point);
367                 return ret;
368         }
369
370         /**
371          * A script either spendable by the revocation
372          * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
373          * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
374          */
375         public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
376                 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
377                 GC.KeepAlive(revocation_key);
378                 GC.KeepAlive(contest_delay);
379                 GC.KeepAlive(broadcaster_delayed_payment_key);
380                 return ret;
381         }
382
383         /**
384          * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
385          * does not need to have its previous_output_index filled.
386          */
387         public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, bool opt_anchors, org.ldk.structs.TxCreationKeys keys) {
388                 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr, opt_anchors, keys == null ? 0 : keys.ptr);
389                 GC.KeepAlive(htlc);
390                 GC.KeepAlive(opt_anchors);
391                 GC.KeepAlive(keys);
392                 return ret;
393         }
394
395         /**
396          * Gets the redeemscript for a funding output from the two funding public keys.
397          * Note that the order of funding public keys does not matter.
398          */
399         public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
400                 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
401                 GC.KeepAlive(broadcaster);
402                 GC.KeepAlive(countersignatory);
403                 return ret;
404         }
405
406         /**
407          * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
408          * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
409          * transaction which needs signing, and can be used to construct an HTLC transaction which is
410          * broadcastable given a counterparty HTLC signature.
411          * 
412          * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
413          * commitment transaction).
414          */
415         public static byte[] build_htlc_transaction(byte[] commitment_txid, int feerate_per_kw, short contest_delay, org.ldk.structs.HTLCOutputInCommitment htlc, bool opt_anchors, bool use_non_zero_fee_anchors, byte[] broadcaster_delayed_payment_key, byte[] revocation_key) {
416                 byte[] ret = bindings.build_htlc_transaction(InternalUtils.check_arr_len(commitment_txid, 32), feerate_per_kw, contest_delay, htlc == null ? 0 : htlc.ptr, opt_anchors, use_non_zero_fee_anchors, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
417                 GC.KeepAlive(commitment_txid);
418                 GC.KeepAlive(feerate_per_kw);
419                 GC.KeepAlive(contest_delay);
420                 GC.KeepAlive(htlc);
421                 GC.KeepAlive(opt_anchors);
422                 GC.KeepAlive(use_non_zero_fee_anchors);
423                 GC.KeepAlive(broadcaster_delayed_payment_key);
424                 GC.KeepAlive(revocation_key);
425                 return ret;
426         }
427
428         /**
429          * Returns the witness required to satisfy and spend a HTLC input.
430          * 
431          * Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
432          */
433         public static byte[] build_htlc_input_witness(byte[] local_sig, byte[] remote_sig, byte[] preimage, byte[] redeem_script, bool opt_anchors) {
434                 byte[] ret = bindings.build_htlc_input_witness(InternalUtils.check_arr_len(local_sig, 64), InternalUtils.check_arr_len(remote_sig, 64), InternalUtils.check_arr_len(preimage, 32), redeem_script, opt_anchors);
435                 GC.KeepAlive(local_sig);
436                 GC.KeepAlive(remote_sig);
437                 GC.KeepAlive(preimage);
438                 GC.KeepAlive(redeem_script);
439                 GC.KeepAlive(opt_anchors);
440                 return ret;
441         }
442
443         /**
444          * Gets the witnessScript for the to_remote output when anchors are enabled.
445          */
446         public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
447                 byte[] ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.check_arr_len(payment_point, 33));
448                 GC.KeepAlive(payment_point);
449                 return ret;
450         }
451
452         /**
453          * Gets the witnessScript for an anchor output from the funding public key.
454          * The witness in the spending input must be:
455          * <BIP 143 funding_signature>
456          * After 16 blocks of confirmation, an alternative satisfying witness could be:
457          * <>
458          * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
459          */
460         public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
461                 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
462                 GC.KeepAlive(funding_pubkey);
463                 return ret;
464         }
465
466         /**
467          * Returns the witness required to satisfy and spend an anchor input.
468          */
469         public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
470                 byte[] ret = bindings.build_anchor_input_witness(InternalUtils.check_arr_len(funding_key, 33), InternalUtils.check_arr_len(funding_sig, 64));
471                 GC.KeepAlive(funding_key);
472                 GC.KeepAlive(funding_sig);
473                 return ret;
474         }
475
476         /**
477          * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
478          * shared secret first. This prevents on-chain observers from discovering how many commitment
479          * transactions occurred in a channel before it was closed.
480          * 
481          * This function gets the shared secret from relevant channel public keys and can be used to
482          * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
483          */
484         public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, bool outbound_from_broadcaster) {
485                 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);
486                 GC.KeepAlive(broadcaster_payment_basepoint);
487                 GC.KeepAlive(countersignatory_payment_basepoint);
488                 GC.KeepAlive(outbound_from_broadcaster);
489                 return ret;
490         }
491
492         /**
493          * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
494          */
495         public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
496                 long ret = bindings.NetworkUpdate_read(ser);
497                 GC.KeepAlive(ser);
498                 if (ret >= 0 && ret <= 4096) { return null; }
499                 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
500                 return ret_hu_conv;
501         }
502
503         /**
504          * Finds a route from us (payer) to the given target node (payee).
505          * 
506          * If the payee provided features in their invoice, they should be provided via `params.payee`.
507          * Without this, MPP will only be used if the payee's features are available in the network graph.
508          * 
509          * Private routing paths between a public node and the target may be included in `params.payee`.
510          * 
511          * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
512          * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
513          * from `network_graph` will be ignored, and only those in `first_hops` will be used.
514          * 
515          * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
516          * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
517          * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
518          * 
519          * # Note
520          * 
521          * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
522          * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
523          * function.
524          * 
525          * # Panics
526          * 
527          * Panics if first_hops contains channels without short_channel_ids;
528          * [`ChannelManager::list_usable_channels`] will never include such channels.
529          * 
530          * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
531          * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
532          * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
533          * 
534          * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
535          */
536         public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.Score scorer, byte[] random_seed_bytes) {
537                 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 ? InternalUtils.mapArray(first_hops, first_hops_conv_16 => first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr) : null, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
538                 GC.KeepAlive(our_node_pubkey);
539                 GC.KeepAlive(route_params);
540                 GC.KeepAlive(network_graph);
541                 GC.KeepAlive(first_hops);
542                 GC.KeepAlive(logger);
543                 GC.KeepAlive(scorer);
544                 GC.KeepAlive(random_seed_bytes);
545                 if (ret >= 0 && ret <= 4096) { return null; }
546                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
547                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
548                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
549                 if (first_hops != null) { foreach (ChannelDetails first_hops_conv_16 in first_hops) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(first_hops_conv_16); }; } };
550                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
551                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(scorer); };
552                 return ret_hu_conv;
553         }
554
555         /**
556          * Construct a route from us (payer) to the target node (payee) via the given hops (which should
557          * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
558          * 
559          * Re-uses logic from `find_route`, so the restrictions described there also apply here.
560          */
561         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) {
562                 long ret = bindings.build_route_from_hops(InternalUtils.check_arr_len(our_node_pubkey, 33), hops != null ? InternalUtils.mapArray(hops, hops_conv_8 => InternalUtils.check_arr_len(hops_conv_8, 33)) : null, route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, logger == null ? 0 : logger.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
563                 GC.KeepAlive(our_node_pubkey);
564                 GC.KeepAlive(hops);
565                 GC.KeepAlive(route_params);
566                 GC.KeepAlive(network_graph);
567                 GC.KeepAlive(logger);
568                 GC.KeepAlive(random_seed_bytes);
569                 if (ret >= 0 && ret <= 4096) { return null; }
570                 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
571                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
572                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
573                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
574                 return ret_hu_conv;
575         }
576
577         /**
578          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
579          * See [`PhantomKeysManager`] for more information on phantom node payments.
580          * 
581          * `phantom_route_hints` parameter:
582          * Contains channel info for all nodes participating in the phantom invoice
583          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
584          * participating node
585          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
586          * updated when a channel becomes disabled or closes
587          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
588          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
589          * down
590          * 
591          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
592          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
593          * If `None` is provided for `payment_hash`, then one will be created.
594          * 
595          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
596          * in excess of the current time.
597          * 
598          * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
599          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
600          * requirement).
601          * 
602          * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
603          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
604          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
605          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
606          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
607          * 
608          * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
609          */
610         public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, byte[] payment_hash, string description, int invoice_expiry_delta_secs, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network) {
611                 long ret = bindings.create_phantom_invoice(amt_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), description, invoice_expiry_delta_secs, phantom_route_hints != null ? InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr) : null, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network);
612                 GC.KeepAlive(amt_msat);
613                 GC.KeepAlive(payment_hash);
614                 GC.KeepAlive(description);
615                 GC.KeepAlive(invoice_expiry_delta_secs);
616                 GC.KeepAlive(phantom_route_hints);
617                 GC.KeepAlive(keys_manager);
618                 GC.KeepAlive(logger);
619                 GC.KeepAlive(network);
620                 if (ret >= 0 && ret <= 4096) { return null; }
621                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
622                 foreach (PhantomRouteHints phantom_route_hints_conv_19 in phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(phantom_route_hints_conv_19); }; };
623                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
624                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
625                 return ret_hu_conv;
626         }
627
628         /**
629          * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
630          * See [`PhantomKeysManager`] for more information on phantom node payments.
631          * 
632          * `phantom_route_hints` parameter:
633          * Contains channel info for all nodes participating in the phantom invoice
634          * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
635          * participating node
636          * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
637          * updated when a channel becomes disabled or closes
638          * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
639          * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
640          * down
641          * 
642          * `description_hash` is a SHA-256 hash of the description text
643          * 
644          * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
645          * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
646          * If `None` is provided for `payment_hash`, then one will be created.
647          * 
648          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
649          * in excess of the current time.
650          * 
651          * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
652          * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
653          * requirement).
654          * 
655          * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
656          * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
657          * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
658          * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
659          * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
660          * 
661          * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None
662          */
663         public static Result_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(org.ldk.structs.Option_u64Z amt_msat, byte[] payment_hash, int invoice_expiry_delta_secs, org.ldk.structs.Sha256 description_hash, PhantomRouteHints[] phantom_route_hints, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network) {
664                 long ret = bindings.create_phantom_invoice_with_description_hash(amt_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), invoice_expiry_delta_secs, description_hash == null ? 0 : description_hash.ptr, phantom_route_hints != null ? InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr) : null, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network);
665                 GC.KeepAlive(amt_msat);
666                 GC.KeepAlive(payment_hash);
667                 GC.KeepAlive(invoice_expiry_delta_secs);
668                 GC.KeepAlive(description_hash);
669                 GC.KeepAlive(phantom_route_hints);
670                 GC.KeepAlive(keys_manager);
671                 GC.KeepAlive(logger);
672                 GC.KeepAlive(network);
673                 if (ret >= 0 && ret <= 4096) { return null; }
674                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
675                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
676                 foreach (PhantomRouteHints phantom_route_hints_conv_19 in phantom_route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(phantom_route_hints_conv_19); }; };
677                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
678                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
679                 return ret_hu_conv;
680         }
681
682         /**
683          * Utility to construct an invoice. Generally, unless you want to do something like a custom
684          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
685          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
686          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
687          * that the payment secret is valid when the invoice is paid.
688          * 
689          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
690          * in excess of the current time.
691          */
692         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, int invoice_expiry_delta_secs) {
693                 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs);
694                 GC.KeepAlive(channelmanager);
695                 GC.KeepAlive(keys_manager);
696                 GC.KeepAlive(logger);
697                 GC.KeepAlive(network);
698                 GC.KeepAlive(amt_msat);
699                 GC.KeepAlive(description);
700                 GC.KeepAlive(invoice_expiry_delta_secs);
701                 if (ret >= 0 && ret <= 4096) { return null; }
702                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
703                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
704                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
705                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
706                 return ret_hu_conv;
707         }
708
709         /**
710          * Utility to construct an invoice. Generally, unless you want to do something like a custom
711          * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
712          * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
713          * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
714          * that the payment secret is valid when the invoice is paid.
715          * Use this variant if you want to pass the `description_hash` to the invoice.
716          * 
717          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
718          * in excess of the current time.
719          */
720         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Sha256 description_hash, int invoice_expiry_delta_secs) {
721                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash(channelmanager == null ? 0 : channelmanager.ptr, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, invoice_expiry_delta_secs);
722                 GC.KeepAlive(channelmanager);
723                 GC.KeepAlive(keys_manager);
724                 GC.KeepAlive(logger);
725                 GC.KeepAlive(network);
726                 GC.KeepAlive(amt_msat);
727                 GC.KeepAlive(description_hash);
728                 GC.KeepAlive(invoice_expiry_delta_secs);
729                 if (ret >= 0 && ret <= 4096) { return null; }
730                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
731                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
732                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
733                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
734                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
735                 return ret_hu_conv;
736         }
737
738         /**
739          * See [`create_invoice_from_channelmanager_with_description_hash`]
740          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
741          * available and the current time is supplied by the caller.
742          */
743         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Sha256 description_hash, long duration_since_epoch, int invoice_expiry_delta_secs) {
744                 long ret = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description_hash == null ? 0 : description_hash.ptr, duration_since_epoch, invoice_expiry_delta_secs);
745                 GC.KeepAlive(channelmanager);
746                 GC.KeepAlive(keys_manager);
747                 GC.KeepAlive(logger);
748                 GC.KeepAlive(network);
749                 GC.KeepAlive(amt_msat);
750                 GC.KeepAlive(description_hash);
751                 GC.KeepAlive(duration_since_epoch);
752                 GC.KeepAlive(invoice_expiry_delta_secs);
753                 if (ret >= 0 && ret <= 4096) { return null; }
754                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
755                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
756                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
757                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
758                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
759                 return ret_hu_conv;
760         }
761
762         /**
763          * See [`create_invoice_from_channelmanager`]
764          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
765          * available and the current time is supplied by the caller.
766          */
767         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, long duration_since_epoch, int invoice_expiry_delta_secs) {
768                 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : channelmanager.ptr, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs);
769                 GC.KeepAlive(channelmanager);
770                 GC.KeepAlive(keys_manager);
771                 GC.KeepAlive(logger);
772                 GC.KeepAlive(network);
773                 GC.KeepAlive(amt_msat);
774                 GC.KeepAlive(description);
775                 GC.KeepAlive(duration_since_epoch);
776                 GC.KeepAlive(invoice_expiry_delta_secs);
777                 if (ret >= 0 && ret <= 4096) { return null; }
778                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
779                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
780                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
781                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
782                 return ret_hu_conv;
783         }
784
785         /**
786          * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
787          * This version allows for providing a custom [`PaymentHash`] for the invoice.
788          * This may be useful if you're building an on-chain swap or involving another protocol where
789          * the payment hash is also involved outside the scope of lightning.
790          */
791         public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.Logger logger, Currency network, org.ldk.structs.Option_u64Z amt_msat, string description, long duration_since_epoch, int invoice_expiry_delta_secs, byte[] payment_hash) {
792                 long ret = bindings.create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager == null ? 0 : channelmanager.ptr, keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, network, amt_msat.ptr, description, duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.check_arr_len(payment_hash, 32));
793                 GC.KeepAlive(channelmanager);
794                 GC.KeepAlive(keys_manager);
795                 GC.KeepAlive(logger);
796                 GC.KeepAlive(network);
797                 GC.KeepAlive(amt_msat);
798                 GC.KeepAlive(description);
799                 GC.KeepAlive(duration_since_epoch);
800                 GC.KeepAlive(invoice_expiry_delta_secs);
801                 GC.KeepAlive(payment_hash);
802                 if (ret >= 0 && ret <= 4096) { return null; }
803                 Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
804                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
805                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
806                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
807                 return ret_hu_conv;
808         }
809
810 } } } }