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