X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FUtilMethods.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FUtilMethods.java;h=aa0110f17f5354f449c1aa5af41719e3cfa5c899;hb=07d5d868dfe064aadb28a7f7ca6002c16be9723d;hp=192d004a038ae94c1200e915e020491ee9592e18;hpb=32973ea2749f8efd05b543dd774763513013b38b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/UtilMethods.java b/src/main/java/org/ldk/structs/UtilMethods.java index 192d004a..aa0110f1 100644 --- a/src/main/java/org/ldk/structs/UtilMethods.java +++ b/src/main/java/org/ldk/structs/UtilMethods.java @@ -58,24 +58,24 @@ public class UtilMethods { * 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. * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ - public static Result_StringErrorZ sign(byte[] msg, byte[] sk) { + public static Result_StrSecp256k1ErrorZ sign(byte[] msg, byte[] sk) { long ret = bindings.sign(msg, InternalUtils.check_arr_len(sk, 32)); Reference.reachabilityFence(msg); Reference.reachabilityFence(sk); if (ret >= 0 && ret <= 4096) { return null; } - Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret); + Result_StrSecp256k1ErrorZ ret_hu_conv = Result_StrSecp256k1ErrorZ.constr_from_ptr(ret); return ret_hu_conv; } /** * Recovers the PublicKey of the signer of the message given the message and the signature. */ - public static Result_PublicKeyErrorZ recover_pk(byte[] msg, java.lang.String sig) { + public static Result_PublicKeySecp256k1ErrorZ recover_pk(byte[] msg, java.lang.String sig) { long ret = bindings.recover_pk(msg, sig); Reference.reachabilityFence(msg); Reference.reachabilityFence(sig); if (ret >= 0 && ret <= 4096) { return null; } - Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret); + Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret); return ret_hu_conv; } @@ -101,6 +101,22 @@ public class UtilMethods { return ret; } + /** + * Read previously persisted [`ChannelMonitor`]s from the store. + */ + 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) { + long ret = bindings.read_channel_monitors(kv_store.ptr, entropy_source.ptr, signer_provider.ptr); + Reference.reachabilityFence(kv_store); + Reference.reachabilityFence(entropy_source); + Reference.reachabilityFence(signer_provider); + if (ret >= 0 && ret <= 4096) { return null; } + Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(kv_store); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(signer_provider); }; + return ret_hu_conv; + } + /** * Read a MonitorEvent from a byte array, created by MonitorEvent_write */ @@ -113,15 +129,15 @@ public class UtilMethods { } /** - * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write + * Read a C2Tuple_ThirtyTwoBytesChannelMonitorZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelMonitorZ_write */ - public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) { - long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg_a.ptr, arg_b.ptr); + public static Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(byte[] ser, org.ldk.structs.EntropySource arg_a, org.ldk.structs.SignerProvider arg_b) { + long ret = bindings.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser, arg_a.ptr, arg_b.ptr); Reference.reachabilityFence(ser); Reference.reachabilityFence(arg_a); Reference.reachabilityFence(arg_b); if (ret >= 0 && ret <= 4096) { return null; } - Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret); + Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_a); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_b); }; return ret_hu_conv; @@ -142,10 +158,10 @@ public class UtilMethods { } /** - * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write + * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write */ - 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) { - 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 ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr).toArray() : null)); + 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) { + long ret = bindings.C2Tuple_ThirtyTwoBytesChannelManagerZ_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 ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr).toArray() : null)); Reference.reachabilityFence(ser); Reference.reachabilityFence(arg_entropy_source); Reference.reachabilityFence(arg_node_signer); @@ -158,7 +174,7 @@ public class UtilMethods { Reference.reachabilityFence(arg_default_config); Reference.reachabilityFence(arg_channel_monitors); if (ret >= 0 && ret <= 4096) { return null; } - Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret); + Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_entropy_source); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_node_signer); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg_signer_provider); }; @@ -189,7 +205,7 @@ public class UtilMethods { * [phantom node payments]: crate::sign::PhantomKeysManager * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material */ - 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) { + 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) { 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); Reference.reachabilityFence(keys); Reference.reachabilityFence(min_value_msat); @@ -198,7 +214,7 @@ public class UtilMethods { Reference.reachabilityFence(current_time); Reference.reachabilityFence(min_final_cltv_expiry_delta); if (ret >= 0 && ret <= 4096) { return null; } - Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret); + Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); }; @@ -218,7 +234,7 @@ public class UtilMethods { * * [phantom node payments]: crate::sign::PhantomKeysManager */ - 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) { + 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) { 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); Reference.reachabilityFence(keys); Reference.reachabilityFence(min_value_msat); @@ -227,13 +243,27 @@ public class UtilMethods { Reference.reachabilityFence(current_time); Reference.reachabilityFence(min_final_cltv_expiry_delta); if (ret >= 0 && ret <= 4096) { return null; } - Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret); + Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_value_msat); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(min_final_cltv_expiry_delta); }; return ret_hu_conv; } + /** + * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. + * + * The host part must end with \".onion\". + */ + public static Result_SocketAddressSocketAddressParseErrorZ parse_onion_address(java.lang.String host, short port) { + long ret = bindings.parse_onion_address(host, port); + Reference.reachabilityFence(host); + Reference.reachabilityFence(port); + if (ret >= 0 && ret <= 4096) { return null; } + Result_SocketAddressSocketAddressParseErrorZ ret_hu_conv = Result_SocketAddressSocketAddressParseErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Gets the weight for an HTLC-Success transaction. */ @@ -358,6 +388,17 @@ public class UtilMethods { return ret; } + /** + * Returns the script for the counterparty's output on a holder's commitment transaction based on + * the channel type. + */ + public static byte[] get_counterparty_payment_script(org.ldk.structs.ChannelTypeFeatures channel_type_features, byte[] payment_key) { + byte[] ret = bindings.get_counterparty_payment_script(channel_type_features == null ? 0 : channel_type_features.ptr, InternalUtils.check_arr_len(payment_key, 33)); + Reference.reachabilityFence(channel_type_features); + Reference.reachabilityFence(payment_key); + return ret; + } + /** * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc * does not need to have its previous_output_index filled. @@ -405,7 +446,7 @@ public class UtilMethods { /** * Returns the witness required to satisfy and spend a HTLC input. */ - 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) { + 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) { 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); Reference.reachabilityFence(local_sig); Reference.reachabilityFence(remote_sig); @@ -532,7 +573,7 @@ public class UtilMethods { * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, @Nullable ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.Score scorer, org.ldk.structs.ProbabilisticScoringFeeParameters score_params, byte[] random_seed_bytes) { + public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, org.ldk.structs.RouteParameters route_params, org.ldk.structs.NetworkGraph network_graph, @Nullable ChannelDetails[] first_hops, org.ldk.structs.Logger logger, org.ldk.structs.ScoreLookUp scorer, org.ldk.structs.ProbabilisticScoringFeeParameters score_params, byte[] random_seed_bytes) { 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 ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr).toArray() : null, logger.ptr, scorer.ptr, score_params == null ? 0 : score_params.ptr, InternalUtils.check_arr_len(random_seed_bytes, 32)); Reference.reachabilityFence(our_node_pubkey); Reference.reachabilityFence(route_params); @@ -593,7 +634,7 @@ public class UtilMethods { * * We do not enforce that outputs meet the dust limit or that any output scripts are standard. */ - 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) { + public static Result_C2Tuple_CVec_u8ZusizeZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_u32Z locktime) { long ret = bindings.SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors != null ? Arrays.stream(descriptors).mapToLong(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray() : null, outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_7 -> outputs_conv_7.ptr).toArray() : null, change_destination_script, feerate_sat_per_1000_weight, locktime.ptr); Reference.reachabilityFence(descriptors); Reference.reachabilityFence(outputs); @@ -601,12 +642,35 @@ public class UtilMethods { Reference.reachabilityFence(feerate_sat_per_1000_weight); Reference.reachabilityFence(locktime); if (ret >= 0 && ret <= 4096) { return null; } - Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ ret_hu_conv = Result_C2Tuple_PartiallySignedTransactionusizeZNoneZ.constr_from_ptr(ret); + Result_C2Tuple_CVec_u8ZusizeZNoneZ ret_hu_conv = Result_C2Tuple_CVec_u8ZusizeZNoneZ.constr_from_ptr(ret); for (SpendableOutputDescriptor descriptors_conv_27: descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(descriptors_conv_27); }; }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(locktime); }; return ret_hu_conv; } + /** + * Create an onion message with contents `message` to the destination of `path`. + * Returns (introduction_node_id, onion_msg) + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public static Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ create_onion_message(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.OnionMessagePath path, org.ldk.structs.OnionMessageContents message, @Nullable org.ldk.structs.BlindedPath reply_path) { + long ret = bindings.create_onion_message(entropy_source.ptr, node_signer.ptr, path == null ? 0 : path.ptr, message.ptr, reply_path == null ? 0 : reply_path.ptr); + Reference.reachabilityFence(entropy_source); + Reference.reachabilityFence(node_signer); + Reference.reachabilityFence(path); + Reference.reachabilityFence(message); + Reference.reachabilityFence(reply_path); + if (ret >= 0 && ret <= 4096) { return null; } + Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ ret_hu_conv = Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(path); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(message); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(reply_path); }; + return ret_hu_conv; + } + /** * Returns whether `tlv_type` corresponds to a TLV record for Offers. */ @@ -616,6 +680,21 @@ public class UtilMethods { return ret; } + /** + * Create a one-hop blinded path for a payment. + */ + public static Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(byte[] payee_node_id, org.ldk.structs.ReceiveTlvs payee_tlvs, org.ldk.structs.EntropySource entropy_source) { + long ret = bindings.BlindedPath_one_hop_for_payment(InternalUtils.check_arr_len(payee_node_id, 33), payee_tlvs == null ? 0 : payee_tlvs.ptr, entropy_source.ptr); + Reference.reachabilityFence(payee_node_id); + Reference.reachabilityFence(payee_tlvs); + Reference.reachabilityFence(entropy_source); + if (ret >= 0 && ret <= 4096) { return null; } + Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ ret_hu_conv = Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payee_tlvs); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); }; + return ret_hu_conv; + } + /** * Read a PathFailure from a byte array, created by PathFailure_write */ @@ -669,13 +748,13 @@ public class UtilMethods { * * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`]. */ - public static Result_PaymentIdPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) { + public static Result_ThirtyTwoBytesPaymentErrorZ pay_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) { long ret = bindings.pay_invoice(invoice == null ? 0 : invoice.ptr, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr); Reference.reachabilityFence(invoice); Reference.reachabilityFence(retry_strategy); Reference.reachabilityFence(channelmanager); if (ret >= 0 && ret <= 4096) { return null; } - Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret); + Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); }; @@ -719,14 +798,14 @@ public class UtilMethods { * If you wish to use a different payment idempotency token, see * [`pay_zero_value_invoice_with_id`]. */ - 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) { + public static Result_ThirtyTwoBytesPaymentErrorZ pay_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msats, org.ldk.structs.Retry retry_strategy, org.ldk.structs.ChannelManager channelmanager) { long ret = bindings.pay_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msats, retry_strategy.ptr, channelmanager == null ? 0 : channelmanager.ptr); Reference.reachabilityFence(invoice); Reference.reachabilityFence(amount_msats); Reference.reachabilityFence(retry_strategy); Reference.reachabilityFence(channelmanager); if (ret >= 0 && ret <= 4096) { return null; } - Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret); + Result_ThirtyTwoBytesPaymentErrorZ ret_hu_conv = Result_ThirtyTwoBytesPaymentErrorZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(retry_strategy); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); }; @@ -761,6 +840,44 @@ public class UtilMethods { return ret_hu_conv; } + /** + * Sends payment probes over all paths of a route that would be used to pay the given invoice. + * + * See [`ChannelManager::send_preflight_probes`] for more information. + */ + public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_invoice(org.ldk.structs.Bolt11Invoice invoice, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) { + long ret = bindings.preflight_probe_invoice(invoice == null ? 0 : invoice.ptr, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr); + Reference.reachabilityFence(invoice); + Reference.reachabilityFence(channelmanager); + Reference.reachabilityFence(liquidity_limit_multiplier); + if (ret >= 0 && ret <= 4096) { return null; } + Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(liquidity_limit_multiplier); }; + return ret_hu_conv; + } + + /** + * Sends payment probes over all paths of a route that would be used to pay the given zero-value + * invoice using the given amount. + * + * See [`ChannelManager::send_preflight_probes`] for more information. + */ + public static Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ preflight_probe_zero_value_invoice(org.ldk.structs.Bolt11Invoice invoice, long amount_msat, org.ldk.structs.ChannelManager channelmanager, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) { + long ret = bindings.preflight_probe_zero_value_invoice(invoice == null ? 0 : invoice.ptr, amount_msat, channelmanager == null ? 0 : channelmanager.ptr, liquidity_limit_multiplier.ptr); + Reference.reachabilityFence(invoice); + Reference.reachabilityFence(amount_msat); + Reference.reachabilityFence(channelmanager); + Reference.reachabilityFence(liquidity_limit_multiplier); + if (ret >= 0 && ret <= 4096) { return null; } + Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(invoice); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channelmanager); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(liquidity_limit_multiplier); }; + return ret_hu_conv; + } + /** * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" * See [`PhantomKeysManager`] for more information on phantom node payments. @@ -803,7 +920,7 @@ public class UtilMethods { * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. */ - public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_PaymentHashZ payment_hash, java.lang.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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) { + public static Result_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(org.ldk.structs.Option_u64Z amt_msat, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash, java.lang.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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) { long ret = bindings.create_phantom_invoice(amt_msat.ptr, payment_hash.ptr, description, invoice_expiry_delta_secs, phantom_route_hints != null ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch); Reference.reachabilityFence(amt_msat); Reference.reachabilityFence(payment_hash); @@ -868,7 +985,7 @@ public class UtilMethods { * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. */ - 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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) { + 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, org.ldk.enums.Currency network, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta, long duration_since_epoch) { 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 ? Arrays.stream(phantom_route_hints).mapToLong(phantom_route_hints_conv_19 -> phantom_route_hints_conv_19 == null ? 0 : phantom_route_hints_conv_19.ptr).toArray() : null, entropy_source.ptr, node_signer.ptr, logger.ptr, network, min_final_cltv_expiry_delta.ptr, duration_since_epoch); Reference.reachabilityFence(amt_msat); Reference.reachabilityFence(payment_hash);