7 namespace org { namespace ldk { namespace util {
8 public class UtilMethods {
10 * Gets the 128-bit integer, as 16 little-endian bytes
12 public static byte[] U128_le_bytes(org.ldk.util.UInt128 val) {
13 byte[] ret = bindings.U128_le_bytes(val.getLEBytes());
19 * Constructs a new U128 from 16 little-endian bytes
21 public static UInt128 U128_new(byte[] le_bytes) {
22 byte[] ret = bindings.U128_new(InternalUtils.check_arr_len(le_bytes, 16));
23 GC.KeepAlive(le_bytes);
24 org.ldk.util.UInt128 ret_conv = new org.ldk.util.UInt128(ret);
29 * Constructs a new COption_NoneZ containing a
31 public static COption_NoneZ COption_NoneZ_some() {
32 COption_NoneZ ret = bindings.COption_NoneZ_some();
37 * Constructs a new COption_NoneZ containing nothing
39 public static COption_NoneZ COption_NoneZ_none() {
40 COption_NoneZ ret = bindings.COption_NoneZ_none();
45 * Read a APIError from a byte array, created by APIError_write
47 public static Result_COption_APIErrorZDecodeErrorZ APIError_read(byte[] ser) {
48 long ret = bindings.APIError_read(ser);
50 if (ret >= 0 && ret <= 4096) { return null; }
51 Result_COption_APIErrorZDecodeErrorZ ret_hu_conv = Result_COption_APIErrorZDecodeErrorZ.constr_from_ptr(ret);
56 * Creates a digital signature of a message given a SecretKey, like the node's secret.
57 * 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.
58 * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
60 public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
61 long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32));
64 if (ret >= 0 && ret <= 4096) { return null; }
65 Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
70 * Recovers the PublicKey of the signer of the message given the message and the signature.
72 public static Result_PublicKeyErrorZ recover_pk(byte[] msg, string sig) {
73 long ret = bindings.recover_pk(msg, sig);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
82 * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
85 public static bool verify(byte[] msg, string sig, byte[] pk) {
86 bool ret = bindings.verify(msg, sig, InternalUtils.check_arr_len(pk, 33));
94 * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
96 public static byte[] construct_invoice_preimage(byte[] hrp_bytes, UInt5[] data_without_signature) {
97 byte[] ret = bindings.construct_invoice_preimage(hrp_bytes, data_without_signature != null ? InternalUtils.convUInt5Array(data_without_signature) : null);
98 GC.KeepAlive(hrp_bytes);
99 GC.KeepAlive(data_without_signature);
104 * Read a MonitorEvent from a byte array, created by MonitorEvent_write
106 public static Result_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(byte[] ser) {
107 long ret = bindings.MonitorEvent_read(ser);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Result_COption_MonitorEventZDecodeErrorZ ret_hu_conv = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
115 * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
117 public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) {
118 long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg_a.ptr, arg_b.ptr);
122 if (ret >= 0 && ret <= 4096) { return null; }
123 Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_a); };
125 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_b); };
130 * Fetches the set of [`InitFeatures`] flags which are provided by or required by
131 * [`ChannelManager`].
133 public static InitFeatures provided_init_features(org.ldk.structs.UserConfig config) {
134 long ret = bindings.provided_init_features(config == null ? 0 : config.ptr);
135 GC.KeepAlive(config);
136 if (ret >= 0 && ret <= 4096) { return null; }
137 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
138 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
139 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(config); };
144 * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
146 public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_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) {
147 long ret = bindings.C2Tuple_BlockHashChannelManagerZ_read(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, arg_channel_monitors != null ? InternalUtils.mapArray(arg_channel_monitors, arg_channel_monitors_conv_16 => arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr) : null));
149 GC.KeepAlive(arg_entropy_source);
150 GC.KeepAlive(arg_node_signer);
151 GC.KeepAlive(arg_signer_provider);
152 GC.KeepAlive(arg_fee_estimator);
153 GC.KeepAlive(arg_chain_monitor);
154 GC.KeepAlive(arg_tx_broadcaster);
155 GC.KeepAlive(arg_router);
156 GC.KeepAlive(arg_logger);
157 GC.KeepAlive(arg_default_config);
158 GC.KeepAlive(arg_channel_monitors);
159 if (ret >= 0 && ret <= 4096) { return null; }
160 Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
161 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_entropy_source); };
162 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_node_signer); };
163 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_signer_provider); };
164 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_fee_estimator); };
165 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_chain_monitor); };
166 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_tx_broadcaster); };
167 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_router); };
168 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_logger); };
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg_default_config); };
170 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); }; };
175 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
176 * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
177 * a `ChannelManager`.
179 * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then
180 * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
181 * regenerate it for each new inbound payment.
183 * `current_time` is a Unix timestamp representing the current time.
185 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
186 * on versions of LDK prior to 0.0.114.
188 * [phantom node payments]: crate::sign::PhantomKeysManager
189 * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material
191 public static Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create(org.ldk.structs.ExpandedKey keys, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs, org.ldk.structs.EntropySource entropy_source, long current_time, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
192 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);
194 GC.KeepAlive(min_value_msat);
195 GC.KeepAlive(invoice_expiry_delta_secs);
196 GC.KeepAlive(entropy_source);
197 GC.KeepAlive(current_time);
198 GC.KeepAlive(min_final_cltv_expiry_delta);
199 if (ret >= 0 && ret <= 4096) { return null; }
200 Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
201 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
202 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
203 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
204 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
209 * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
210 * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
211 * without a `ChannelManager`.
213 * See [`create`] for information on the `keys` and `current_time` parameters.
215 * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
216 * on versions of LDK prior to 0.0.114.
218 * [phantom node payments]: crate::sign::PhantomKeysManager
220 public static Result_PaymentSecretNoneZ create_from_hash(org.ldk.structs.ExpandedKey keys, org.ldk.structs.Option_u64Z min_value_msat, byte[] payment_hash, int invoice_expiry_delta_secs, long current_time, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
221 long ret = bindings.create_from_hash(keys == null ? 0 : keys.ptr, min_value_msat.ptr, InternalUtils.check_arr_len(payment_hash, 32), invoice_expiry_delta_secs, current_time, min_final_cltv_expiry_delta.ptr);
223 GC.KeepAlive(min_value_msat);
224 GC.KeepAlive(payment_hash);
225 GC.KeepAlive(invoice_expiry_delta_secs);
226 GC.KeepAlive(current_time);
227 GC.KeepAlive(min_final_cltv_expiry_delta);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys); };
231 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_value_msat); };
232 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
237 * Gets the weight for an HTLC-Success transaction.
239 public static long htlc_success_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
240 long ret = bindings.htlc_success_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
241 GC.KeepAlive(channel_type_features);
246 * Gets the weight for an HTLC-Timeout transaction.
248 public static long htlc_timeout_tx_weight(org.ldk.structs.ChannelTypeFeatures channel_type_features) {
249 long ret = bindings.htlc_timeout_tx_weight(channel_type_features == null ? 0 : channel_type_features.ptr);
250 GC.KeepAlive(channel_type_features);
255 * Check if a given input witness attempts to claim a HTLC.
257 public static Option_HTLCClaimZ HTLCClaim_from_witness(byte[] witness) {
258 long ret = bindings.HTLCClaim_from_witness(witness);
259 GC.KeepAlive(witness);
260 if (ret >= 0 && ret <= 4096) { return null; }
261 org.ldk.structs.Option_HTLCClaimZ ret_hu_conv = org.ldk.structs.Option_HTLCClaimZ.constr_from_ptr(ret);
262 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
267 * Build the commitment secret from the seed and the commitment number
269 public static byte[] build_commitment_secret(byte[] commitment_seed, long idx) {
270 byte[] ret = bindings.build_commitment_secret(InternalUtils.check_arr_len(commitment_seed, 32), idx);
271 GC.KeepAlive(commitment_seed);
277 * Build a closing transaction
279 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) {
280 byte[] ret = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr);
281 GC.KeepAlive(to_holder_value_sat);
282 GC.KeepAlive(to_counterparty_value_sat);
283 GC.KeepAlive(to_holder_script);
284 GC.KeepAlive(to_counterparty_script);
285 GC.KeepAlive(funding_outpoint);
290 * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
291 * from the base secret and the per_commitment_point.
293 public static byte[] derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
294 byte[] ret = bindings.derive_private_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_secret, 32));
295 GC.KeepAlive(per_commitment_point);
296 GC.KeepAlive(base_secret);
301 * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
302 * from the base point and the per_commitment_key. This is the public equivalent of
303 * derive_private_key - using only public keys to derive a public key instead of private keys.
305 public static byte[] derive_public_key(byte[] per_commitment_point, byte[] base_point) {
306 byte[] ret = bindings.derive_public_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(base_point, 33));
307 GC.KeepAlive(per_commitment_point);
308 GC.KeepAlive(base_point);
313 * Derives a per-commitment-transaction revocation key from its constituent parts.
315 * Only the cheating participant owns a valid witness to propagate a revoked
316 * commitment transaction, thus per_commitment_secret always come from cheater
317 * and revocation_base_secret always come from punisher, which is the broadcaster
318 * of the transaction spending with this key knowledge.
320 public static byte[] derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
321 byte[] ret = bindings.derive_private_revocation_key(InternalUtils.check_arr_len(per_commitment_secret, 32), InternalUtils.check_arr_len(countersignatory_revocation_base_secret, 32));
322 GC.KeepAlive(per_commitment_secret);
323 GC.KeepAlive(countersignatory_revocation_base_secret);
328 * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
329 * the public equivalend of derive_private_revocation_key - using only public keys to derive a
330 * public key instead of private keys.
332 * Only the cheating participant owns a valid witness to propagate a revoked
333 * commitment transaction, thus per_commitment_point always come from cheater
334 * and revocation_base_point always come from punisher, which is the broadcaster
335 * of the transaction spending with this key knowledge.
337 * Note that this is infallible iff we trust that at least one of the two input keys are randomly
338 * generated (ie our own).
340 public static byte[] derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
341 byte[] ret = bindings.derive_public_revocation_key(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(countersignatory_revocation_base_point, 33));
342 GC.KeepAlive(per_commitment_point);
343 GC.KeepAlive(countersignatory_revocation_base_point);
348 * A script either spendable by the revocation
349 * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
350 * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
352 public static byte[] get_revokeable_redeemscript(byte[] revocation_key, short contest_delay, byte[] broadcaster_delayed_payment_key) {
353 byte[] ret = bindings.get_revokeable_redeemscript(InternalUtils.check_arr_len(revocation_key, 33), contest_delay, InternalUtils.check_arr_len(broadcaster_delayed_payment_key, 33));
354 GC.KeepAlive(revocation_key);
355 GC.KeepAlive(contest_delay);
356 GC.KeepAlive(broadcaster_delayed_payment_key);
361 * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
362 * does not need to have its previous_output_index filled.
364 public static byte[] get_htlc_redeemscript(org.ldk.structs.HTLCOutputInCommitment htlc, org.ldk.structs.ChannelTypeFeatures channel_type_features, org.ldk.structs.TxCreationKeys keys) {
365 byte[] ret = bindings.get_htlc_redeemscript(htlc == null ? 0 : htlc.ptr, channel_type_features == null ? 0 : channel_type_features.ptr, keys == null ? 0 : keys.ptr);
367 GC.KeepAlive(channel_type_features);
373 * Gets the redeemscript for a funding output from the two funding public keys.
374 * Note that the order of funding public keys does not matter.
376 public static byte[] make_funding_redeemscript(byte[] broadcaster, byte[] countersignatory) {
377 byte[] ret = bindings.make_funding_redeemscript(InternalUtils.check_arr_len(broadcaster, 33), InternalUtils.check_arr_len(countersignatory, 33));
378 GC.KeepAlive(broadcaster);
379 GC.KeepAlive(countersignatory);
384 * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
385 * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
386 * transaction which needs signing, and can be used to construct an HTLC transaction which is
387 * broadcastable given a counterparty HTLC signature.
389 * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
390 * commitment transaction).
392 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) {
393 byte[] ret = bindings.build_htlc_transaction(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.check_arr_len(broadcaster_delayed_payment_key, 33), InternalUtils.check_arr_len(revocation_key, 33));
394 GC.KeepAlive(commitment_txid);
395 GC.KeepAlive(feerate_per_kw);
396 GC.KeepAlive(contest_delay);
398 GC.KeepAlive(channel_type_features);
399 GC.KeepAlive(broadcaster_delayed_payment_key);
400 GC.KeepAlive(revocation_key);
405 * Returns the witness required to satisfy and spend a HTLC input.
407 public static byte[] build_htlc_input_witness(byte[] local_sig, byte[] remote_sig, org.ldk.structs.Option_PaymentPreimageZ preimage, byte[] redeem_script, org.ldk.structs.ChannelTypeFeatures channel_type_features) {
408 byte[] ret = bindings.build_htlc_input_witness(InternalUtils.check_arr_len(local_sig, 64), InternalUtils.check_arr_len(remote_sig, 64), preimage.ptr, redeem_script, channel_type_features == null ? 0 : channel_type_features.ptr);
409 GC.KeepAlive(local_sig);
410 GC.KeepAlive(remote_sig);
411 GC.KeepAlive(preimage);
412 GC.KeepAlive(redeem_script);
413 GC.KeepAlive(channel_type_features);
418 * Gets the witnessScript for the to_remote output when anchors are enabled.
420 public static byte[] get_to_countersignatory_with_anchors_redeemscript(byte[] payment_point) {
421 byte[] ret = bindings.get_to_countersignatory_with_anchors_redeemscript(InternalUtils.check_arr_len(payment_point, 33));
422 GC.KeepAlive(payment_point);
427 * Gets the witnessScript for an anchor output from the funding public key.
428 * The witness in the spending input must be:
429 * <BIP 143 funding_signature>
430 * After 16 blocks of confirmation, an alternative satisfying witness could be:
432 * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
434 public static byte[] get_anchor_redeemscript(byte[] funding_pubkey) {
435 byte[] ret = bindings.get_anchor_redeemscript(InternalUtils.check_arr_len(funding_pubkey, 33));
436 GC.KeepAlive(funding_pubkey);
441 * Returns the witness required to satisfy and spend an anchor input.
443 public static byte[] build_anchor_input_witness(byte[] funding_key, byte[] funding_sig) {
444 byte[] ret = bindings.build_anchor_input_witness(InternalUtils.check_arr_len(funding_key, 33), InternalUtils.check_arr_len(funding_sig, 64));
445 GC.KeepAlive(funding_key);
446 GC.KeepAlive(funding_sig);
451 * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
452 * shared secret first. This prevents on-chain observers from discovering how many commitment
453 * transactions occurred in a channel before it was closed.
455 * This function gets the shared secret from relevant channel public keys and can be used to
456 * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
458 public static long get_commitment_transaction_number_obscure_factor(byte[] broadcaster_payment_basepoint, byte[] countersignatory_payment_basepoint, bool outbound_from_broadcaster) {
459 long ret = bindings.get_commitment_transaction_number_obscure_factor(InternalUtils.check_arr_len(broadcaster_payment_basepoint, 33), InternalUtils.check_arr_len(countersignatory_payment_basepoint, 33), outbound_from_broadcaster);
460 GC.KeepAlive(broadcaster_payment_basepoint);
461 GC.KeepAlive(countersignatory_payment_basepoint);
462 GC.KeepAlive(outbound_from_broadcaster);
467 * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
469 public static Result_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(byte[] ser) {
470 long ret = bindings.NetworkUpdate_read(ser);
472 if (ret >= 0 && ret <= 4096) { return null; }
473 Result_COption_NetworkUpdateZDecodeErrorZ ret_hu_conv = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
478 * Verifies the signature of a [`NodeAnnouncement`].
480 * Returns an error if it is invalid.
482 public static Result_NoneLightningErrorZ verify_node_announcement(org.ldk.structs.NodeAnnouncement msg) {
483 long ret = bindings.verify_node_announcement(msg == null ? 0 : msg.ptr);
485 if (ret >= 0 && ret <= 4096) { return null; }
486 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
487 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
492 * Verifies all signatures included in a [`ChannelAnnouncement`].
494 * Returns an error if one of the signatures is invalid.
496 public static Result_NoneLightningErrorZ verify_channel_announcement(org.ldk.structs.ChannelAnnouncement msg) {
497 long ret = bindings.verify_channel_announcement(msg == null ? 0 : msg.ptr);
499 if (ret >= 0 && ret <= 4096) { return null; }
500 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
501 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
506 * Finds a route from us (payer) to the given target node (payee).
508 * If the payee provided features in their invoice, they should be provided via the `payee` field
509 * in the given [`RouteParameters::payment_params`].
510 * Without this, MPP will only be used if the payee's features are available in the network graph.
512 * Private routing paths between a public node and the target may be included in the `payee` field
513 * of [`RouteParameters::payment_params`].
515 * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
516 * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
517 * from `network_graph` will be ignored, and only those in `first_hops` will be used.
519 * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
520 * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
521 * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
525 * Panics if first_hops contains channels without `short_channel_id`s;
526 * [`ChannelManager::list_usable_channels`] will never include such channels.
528 * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
529 * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
530 * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
532 * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
534 public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.Score scorer, org.ldk.structs.ProbabilisticScoringFeeParameters score_params, byte[] random_seed_bytes) {
535 long ret = bindings.find_route(InternalUtils.check_arr_len(our_node_pubkey, 33), route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, first_hops != null ? InternalUtils.mapArray(first_hops, first_hops_conv_16 => first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr) : null, logger.ptr, scorer.ptr, score_params == null ? 0 : score_params.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
536 GC.KeepAlive(our_node_pubkey);
537 GC.KeepAlive(route_params);
538 GC.KeepAlive(network_graph);
539 GC.KeepAlive(first_hops);
540 GC.KeepAlive(logger);
541 GC.KeepAlive(scorer);
542 GC.KeepAlive(score_params);
543 GC.KeepAlive(random_seed_bytes);
544 if (ret >= 0 && ret <= 4096) { return null; }
545 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
546 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
547 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
548 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); }; } };
549 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
550 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(scorer); };
551 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(score_params); };
556 * Construct a route from us (payer) to the target node (payee) via the given hops (which should
557 * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
559 * Re-uses logic from `find_route`, so the restrictions described there also apply here.
561 public static Result_RouteLightningErrorZ build_route_from_hops(byte[] our_node_pubkey, byte[][] hops, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.Logger logger, byte[] random_seed_bytes) {
562 long ret = bindings.build_route_from_hops(InternalUtils.check_arr_len(our_node_pubkey, 33), hops != null ? InternalUtils.mapArray(hops, hops_conv_8 => InternalUtils.check_arr_len(hops_conv_8, 33)) : null, route_params == null ? 0 : route_params.ptr, network_graph == null ? 0 : network_graph.ptr, logger.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32));
563 GC.KeepAlive(our_node_pubkey);
565 GC.KeepAlive(route_params);
566 GC.KeepAlive(network_graph);
567 GC.KeepAlive(logger);
568 GC.KeepAlive(random_seed_bytes);
569 if (ret >= 0 && ret <= 4096) { return null; }
570 Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
571 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_params); };
572 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
573 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
578 * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to
579 * the given outputs, plus an output to the given change destination (if sufficient
580 * change value remains). The PSBT will have a feerate, at least, of the given value.
582 * The `locktime` argument is used to set the transaction's locktime. If `None`, the
583 * transaction will have a locktime of 0. It it recommended to set this to the current block
584 * height to avoid fee sniping, unless you have some specific reason to use a different
587 * Returns the PSBT and expected max transaction weight.
589 * Returns `Err(())` if the output value is greater than the input value minus required fee,
590 * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
591 * does not match the one we can spend.
593 * We do not enforce that outputs meet the dust limit or that any output scripts are standard.
595 public static Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_PackedLockTimeZ locktime) {
596 long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors != null ? InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr) : null, outputs != null ? InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr) : null, change_destination_script, feerate_sat_per_1000_weight, locktime.ptr);
597 GC.KeepAlive(descriptors);
598 GC.KeepAlive(outputs);
599 GC.KeepAlive(change_destination_script);
600 GC.KeepAlive(feerate_sat_per_1000_weight);
601 GC.KeepAlive(locktime);
602 if (ret >= 0 && ret <= 4096) { return null; }
603 Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ ret_hu_conv = Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ.constr_from_ptr(ret);
604 foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(descriptors_conv_27); }; };
605 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(locktime); };
610 * Returns whether `tlv_type` corresponds to a TLV record for Offers.
612 public static bool OffersMessage_is_known_type(long tlv_type) {
613 bool ret = bindings.OffersMessage_is_known_type(tlv_type);
614 GC.KeepAlive(tlv_type);
619 * Read a PathFailure from a byte array, created by PathFailure_write
621 public static Result_COption_PathFailureZDecodeErrorZ PathFailure_read(byte[] ser) {
622 long ret = bindings.PathFailure_read(ser);
624 if (ret >= 0 && ret <= 4096) { return null; }
625 Result_COption_PathFailureZDecodeErrorZ ret_hu_conv = Result_COption_PathFailureZDecodeErrorZ.constr_from_ptr(ret);
630 * Read a ClosureReason from a byte array, created by ClosureReason_write
632 public static Result_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(byte[] ser) {
633 long ret = bindings.ClosureReason_read(ser);
635 if (ret >= 0 && ret <= 4096) { return null; }
636 Result_COption_ClosureReasonZDecodeErrorZ ret_hu_conv = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
641 * Read a HTLCDestination from a byte array, created by HTLCDestination_write
643 public static Result_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(byte[] ser) {
644 long ret = bindings.HTLCDestination_read(ser);
646 if (ret >= 0 && ret <= 4096) { return null; }
647 Result_COption_HTLCDestinationZDecodeErrorZ ret_hu_conv = Result_COption_HTLCDestinationZDecodeErrorZ.constr_from_ptr(ret);
652 * Read a Event from a byte array, created by Event_write
654 public static Result_COption_EventZDecodeErrorZ Event_read(byte[] ser) {
655 long ret = bindings.Event_read(ser);
657 if (ret >= 0 && ret <= 4096) { return null; }
658 Result_COption_EventZDecodeErrorZ ret_hu_conv = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
663 * Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`].
665 * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
666 * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
667 * with the same [`PaymentHash`] is never sent.
669 * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
671 public static Result_PaymentIdPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
672 long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
673 GC.KeepAlive(invoice);
674 GC.KeepAlive(retry_strategy);
675 GC.KeepAlive(channelmanager);
676 if (ret >= 0 && ret <= 4096) { return null; }
677 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
678 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
679 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
680 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
685 * Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on
688 * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
689 * payment completes or fails, no idempotency guarantees are made.
691 * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
692 * [`PaymentHash`] has never been paid before.
694 * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
696 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) {
697 long ret = bindings.pay_invoice_with_id(invoice == null ? 0 : invoice.ptr, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
698 GC.KeepAlive(invoice);
699 GC.KeepAlive(payment_id);
700 GC.KeepAlive(retry_strategy);
701 GC.KeepAlive(channelmanager);
702 if (ret >= 0 && ret <= 4096) { return null; }
703 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
704 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
705 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
706 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
711 * Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on
714 * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long
715 * as the payment is still pending. If the payment succeeds, you must ensure that a second payment
716 * with the same [`PaymentHash`] is never sent.
718 * If you wish to use a different payment idempotency token, see
719 * [`pay_zero_value_invoice_with_id`].
721 public static Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) {
722 long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
723 GC.KeepAlive(invoice);
724 GC.KeepAlive(amount_msats);
725 GC.KeepAlive(retry_strategy);
726 GC.KeepAlive(channelmanager);
727 if (ret >= 0 && ret <= 4096) { return null; }
728 Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
729 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
730 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
731 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
736 * Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key,
737 * retrying if needed based on [`Retry`].
739 * Note that idempotency is only guaranteed as long as the payment is still pending. Once the
740 * payment completes or fails, no idempotency guarantees are made.
742 * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same
743 * [`PaymentHash`] has never been paid before.
745 * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
748 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) {
749 long ret = bindings.pay_zero_value_invoice_with_id(invoice == null ? 0 : invoice.ptr, amount_msats, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr);
750 GC.KeepAlive(invoice);
751 GC.KeepAlive(amount_msats);
752 GC.KeepAlive(payment_id);
753 GC.KeepAlive(retry_strategy);
754 GC.KeepAlive(channelmanager);
755 if (ret >= 0 && ret <= 4096) { return null; }
756 Result_NonePaymentErrorZ ret_hu_conv = Result_NonePaymentErrorZ.constr_from_ptr(ret);
757 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(invoice); };
758 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(retry_strategy); };
759 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
764 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
765 * See [`PhantomKeysManager`] for more information on phantom node payments.
767 * `phantom_route_hints` parameter:
768 * Contains channel info for all nodes participating in the phantom invoice
769 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
771 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
772 * updated when a channel becomes disabled or closes
773 * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
774 * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
777 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
778 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
779 * If `None` is provided for `payment_hash`, then one will be created.
781 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
782 * in excess of the current time.
784 * `duration_since_epoch` is the current time since epoch in seconds.
786 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
787 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3.
788 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
789 * confirmations during routing.
791 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
792 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
795 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
796 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
797 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
798 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
799 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
800 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
802 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
803 * available and the current time is supplied by the caller.
805 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_PaymentHashZ 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) {
806 long ret = bindings.create_phantom_invoice(amt_msat.ptr, payment_hash.ptr, description, invoice_expiry_delta_secs, phantom_route_hints != null ? InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr) : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
807 GC.KeepAlive(amt_msat);
808 GC.KeepAlive(payment_hash);
809 GC.KeepAlive(description);
810 GC.KeepAlive(invoice_expiry_delta_secs);
811 GC.KeepAlive(phantom_route_hints);
812 GC.KeepAlive(entropy_source);
813 GC.KeepAlive(node_signer);
814 GC.KeepAlive(logger);
815 GC.KeepAlive(network);
816 GC.KeepAlive(min_final_cltv_expiry_delta);
817 GC.KeepAlive(duration_since_epoch);
818 if (ret >= 0 && ret <= 4096) { return null; }
819 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
820 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
821 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
822 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); }; };
823 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
824 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
825 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
826 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
831 * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
832 * See [`PhantomKeysManager`] for more information on phantom node payments.
834 * `phantom_route_hints` parameter:
835 * Contains channel info for all nodes participating in the phantom invoice
836 * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
838 * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
839 * updated when a channel becomes disabled or closes
840 * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum
841 * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected
842 * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node
843 * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as
844 * desired, but note that some nodes will be trimmed if more than 3 nodes are provided.
846 * `description_hash` is a SHA-256 hash of the description text
848 * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference
849 * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]).
850 * If `None` is provided for `payment_hash`, then one will be created.
852 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
853 * in excess of the current time.
855 * `duration_since_epoch` is the current time since epoch in seconds.
857 * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom
858 * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
861 * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager
862 * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
863 * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment
864 * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
865 * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
867 * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
868 * available and the current time is supplied by the caller.
870 public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_PaymentHashZ 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) {
871 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, phantom_route_hints != null ? InternalUtils.mapArray(phantom_route_hints, phantom_route_hints_conv_19 => phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr) : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch);
872 GC.KeepAlive(amt_msat);
873 GC.KeepAlive(payment_hash);
874 GC.KeepAlive(invoice_expiry_delta_secs);
875 GC.KeepAlive(description_hash);
876 GC.KeepAlive(phantom_route_hints);
877 GC.KeepAlive(entropy_source);
878 GC.KeepAlive(node_signer);
879 GC.KeepAlive(logger);
880 GC.KeepAlive(network);
881 GC.KeepAlive(min_final_cltv_expiry_delta);
882 GC.KeepAlive(duration_since_epoch);
883 if (ret >= 0 && ret <= 4096) { return null; }
884 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
885 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
886 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
887 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
888 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); }; };
889 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
890 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
891 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
892 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
897 * Utility to construct an invoice. Generally, unless you want to do something like a custom
898 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
899 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
900 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
901 * that the payment secret is valid when the invoice is paid.
903 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
904 * in excess of the current time.
906 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
907 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
908 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
909 * confirmations during routing.
911 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
913 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) {
914 long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr, node_signer.ptr, logger.ptr, network, amt_msat.ptr, description, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
915 GC.KeepAlive(channelmanager);
916 GC.KeepAlive(node_signer);
917 GC.KeepAlive(logger);
918 GC.KeepAlive(network);
919 GC.KeepAlive(amt_msat);
920 GC.KeepAlive(description);
921 GC.KeepAlive(invoice_expiry_delta_secs);
922 GC.KeepAlive(min_final_cltv_expiry_delta);
923 if (ret >= 0 && ret <= 4096) { return null; }
924 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
925 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
926 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
927 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
928 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
929 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
934 * Utility to construct an invoice. Generally, unless you want to do something like a custom
935 * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
936 * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
937 * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
938 * that the payment secret is valid when the invoice is paid.
939 * Use this variant if you want to pass the `description_hash` to the invoice.
941 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
942 * in excess of the current time.
944 * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to
945 * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
946 * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block
947 * confirmations during routing.
949 * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
951 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) {
952 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);
953 GC.KeepAlive(channelmanager);
954 GC.KeepAlive(node_signer);
955 GC.KeepAlive(logger);
956 GC.KeepAlive(network);
957 GC.KeepAlive(amt_msat);
958 GC.KeepAlive(description_hash);
959 GC.KeepAlive(invoice_expiry_delta_secs);
960 GC.KeepAlive(min_final_cltv_expiry_delta);
961 if (ret >= 0 && ret <= 4096) { return null; }
962 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
963 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
964 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
965 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
966 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
967 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
968 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
973 * See [`create_invoice_from_channelmanager_with_description_hash`]
974 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
975 * available and the current time is supplied by the caller.
977 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) {
978 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);
979 GC.KeepAlive(channelmanager);
980 GC.KeepAlive(node_signer);
981 GC.KeepAlive(logger);
982 GC.KeepAlive(network);
983 GC.KeepAlive(amt_msat);
984 GC.KeepAlive(description_hash);
985 GC.KeepAlive(duration_since_epoch);
986 GC.KeepAlive(invoice_expiry_delta_secs);
987 GC.KeepAlive(min_final_cltv_expiry_delta);
988 if (ret >= 0 && ret <= 4096) { return null; }
989 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
990 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
991 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
992 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
993 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
994 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(description_hash); };
995 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1000 * See [`create_invoice_from_channelmanager`]
1001 * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
1002 * available and the current time is supplied by the caller.
1004 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) {
1005 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, description, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1006 GC.KeepAlive(channelmanager);
1007 GC.KeepAlive(node_signer);
1008 GC.KeepAlive(logger);
1009 GC.KeepAlive(network);
1010 GC.KeepAlive(amt_msat);
1011 GC.KeepAlive(description);
1012 GC.KeepAlive(duration_since_epoch);
1013 GC.KeepAlive(invoice_expiry_delta_secs);
1014 GC.KeepAlive(min_final_cltv_expiry_delta);
1015 if (ret >= 0 && ret <= 4096) { return null; }
1016 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1017 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1018 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1019 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1020 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1021 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1026 * See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
1027 * This version allows for providing a custom [`PaymentHash`] for the invoice.
1028 * This may be useful if you're building an on-chain swap or involving another protocol where
1029 * the payment hash is also involved outside the scope of lightning.
1031 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) {
1032 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, description, duration_since_epoch, invoice_expiry_delta_secs, InternalUtils.check_arr_len(payment_hash, 32), min_final_cltv_expiry_delta.ptr);
1033 GC.KeepAlive(channelmanager);
1034 GC.KeepAlive(node_signer);
1035 GC.KeepAlive(logger);
1036 GC.KeepAlive(network);
1037 GC.KeepAlive(amt_msat);
1038 GC.KeepAlive(description);
1039 GC.KeepAlive(duration_since_epoch);
1040 GC.KeepAlive(invoice_expiry_delta_secs);
1041 GC.KeepAlive(payment_hash);
1042 GC.KeepAlive(min_final_cltv_expiry_delta);
1043 if (ret >= 0 && ret <= 4096) { return null; }
1044 Result_Bolt11InvoiceSignOrCreationErrorZ ret_hu_conv = Result_Bolt11InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
1045 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channelmanager); };
1046 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
1047 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
1048 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(amt_msat); };
1049 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(min_final_cltv_expiry_delta); };