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