From a7653cf8717b1f9df4d3f4c4bd0b1f50f3bbc230 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 24 Sep 2021 03:14:18 +0000 Subject: [PATCH] Update auto-generated bindings to 0.0.101 --- pom.xml | 2 +- .../java/org/ldk/enums/SemanticError.java | 2 + src/main/java/org/ldk/impl/bindings.java | 638 ++- .../org/ldk/structs/BackgroundProcessor.java | 51 +- src/main/java/org/ldk/structs/Balance.java | 168 + src/main/java/org/ldk/structs/BaseSign.java | 74 +- .../java/org/ldk/structs/ChainMonitor.java | 31 +- .../org/ldk/structs/ChannelCounterparty.java | 39 + .../java/org/ldk/structs/ChannelFeatures.java | 9 + .../java/org/ldk/structs/ChannelManager.java | 1 - .../ldk/structs/ChannelManagerReadArgs.java | 2 +- .../java/org/ldk/structs/ChannelMonitor.java | 30 +- .../org/ldk/structs/ClosingTransaction.java | 102 + .../java/org/ldk/structs/ClosureReason.java | 192 + .../ldk/structs/CommitmentTransaction.java | 4 +- .../org/ldk/structs/CommitmentUpdate.java | 76 +- src/main/java/org/ldk/structs/Confirm.java | 1 - .../structs/CounterpartyForwardingInfo.java | 93 + .../org/ldk/structs/CustomMessageHandler.java | 107 + .../org/ldk/structs/CustomMessageReader.java | 61 + .../java/org/ldk/structs/Description.java | 30 +- src/main/java/org/ldk/structs/Event.java | 84 +- .../java/org/ldk/structs/EventHandler.java | 4 +- src/main/java/org/ldk/structs/ExpiryTime.java | 30 +- src/main/java/org/ldk/structs/Fallback.java | 8 + .../java/org/ldk/structs/FundingCreated.java | 4 +- .../java/org/ldk/structs/FundingSigned.java | 4 +- .../ldk/structs/GossipTimestampFilter.java | 16 +- .../ldk/structs/HTLCFailChannelUpdate.java | 128 - .../ldk/structs/IgnoringMessageHandler.java | 24 + .../java/org/ldk/structs/InitFeatures.java | 9 + src/main/java/org/ldk/structs/Invoice.java | 18 +- .../java/org/ldk/structs/InvoiceFeatures.java | 9 + .../org/ldk/structs/InvoiceSignature.java | 22 +- .../java/org/ldk/structs/KeysManager.java | 2 - .../org/ldk/structs/LockedNetworkGraph.java | 33 - .../org/ldk/structs/MessageSendEvent.java | 27 - .../structs/MessageSendEventsProvider.java | 1 - .../org/ldk/structs/MinFinalCltvExpiry.java | 30 +- .../java/org/ldk/structs/MonitorEvent.java | 24 +- .../org/ldk/structs/NetGraphMsgHandler.java | 72 +- .../java/org/ldk/structs/NetworkGraph.java | 43 +- .../java/org/ldk/structs/NetworkUpdate.java | 136 + .../org/ldk/structs/NodeAnnouncementInfo.java | 2 - .../java/org/ldk/structs/NodeFeatures.java | 9 + .../java/org/ldk/structs/Option_AccessZ.java | 70 + .../java/org/ldk/structs/Option_FilterZ.java | 70 + .../ldk/structs/Option_NetworkUpdateZ.java | 81 + .../java/org/ldk/structs/Option_TypeZ.java | 82 + .../java/org/ldk/structs/PayeePubKey.java | 30 +- .../org/ldk/structs/PaymentSendFailure.java | 3 - .../java/org/ldk/structs/PeerManager.java | 8 +- .../java/org/ldk/structs/PrivateRoute.java | 30 +- .../org/ldk/structs/QueryChannelRange.java | 16 +- .../org/ldk/structs/ReadOnlyNetworkGraph.java | 22 + .../ldk/structs/ReplyShortChannelIdsEnd.java | 16 +- .../Result_COption_TypeZDecodeErrorZ.java | 76 + ...Tuple_BlockHashChannelMonitorZZErrorZ.java | 2 +- .../Result_NetworkGraphDecodeErrorZ.java | 16 +- .../org/ldk/structs/Result_NoneNoneZ.java | 65 + ...Result_TrustedClosingTransactionNoneZ.java | 68 + src/main/java/org/ldk/structs/Route.java | 67 +- src/main/java/org/ldk/structs/RouteHint.java | 30 +- .../java/org/ldk/structs/RouteHintHop.java | 30 +- src/main/java/org/ldk/structs/RouteHop.java | 19 + .../java/org/ldk/structs/RoutingFees.java | 8 + .../ldk/structs/RoutingMessageHandler.java | 20 +- src/main/java/org/ldk/structs/Sha256.java | 30 +- .../java/org/ldk/structs/ShutdownScript.java | 5 +- .../structs/TrustedClosingTransaction.java | 54 + src/main/java/org/ldk/structs/Type.java | 96 + .../ldk/structs/UnsignedNodeAnnouncement.java | 1 - .../java/org/ldk/structs/UtilMethods.java | 19 +- src/main/java/org/ldk/structs/Watch.java | 1 - src/main/jni/bindings.c | 3884 +++++++++++++---- src/main/jni/bindings.c.body | 3884 +++++++++++++---- src/main/jni/org_ldk_impl_bindings.h | 1836 ++++++-- .../jni/org_ldk_impl_bindings_LDKBalance.h | 21 + ...org_ldk_impl_bindings_LDKCOption_AccessZ.h | 21 + ...org_ldk_impl_bindings_LDKCOption_FilterZ.h | 21 + ..._impl_bindings_LDKCOption_NetworkUpdateZ.h | 21 + .../org_ldk_impl_bindings_LDKCOption_TypeZ.h | 21 + .../org_ldk_impl_bindings_LDKClosureReason.h | 21 + ...k_impl_bindings_LDKHTLCFailChannelUpdate.h | 21 - .../org_ldk_impl_bindings_LDKNetworkUpdate.h | 21 + ts/bindings.c | 3004 ++++++++++--- ts/bindings.c.body | 3004 ++++++++++--- ts/bindings.ts | 1816 ++++++-- ts/enums/SemanticError.ts | 2 + ts/structs/BackgroundProcessor.ts | 5 +- ts/structs/Balance.ts | 104 + ts/structs/BaseSign.ts | 40 +- ts/structs/ChainMonitor.ts | 18 +- ts/structs/ChannelCounterparty.ts | 21 + ts/structs/ChannelFeatures.ts | 5 + ts/structs/ChannelManager.ts | 1 - ts/structs/ChannelManagerReadArgs.ts | 2 +- ts/structs/ChannelMonitor.ts | 14 +- ts/structs/ClosingTransaction.ts | 63 + ts/structs/ClosureReason.ts | 138 + ts/structs/CommitmentUpdate.ts | 64 +- ts/structs/Confirm.ts | 1 - ts/structs/CounterpartyForwardingInfo.ts | 62 + ts/structs/CustomMessageHandler.ts | 91 + ts/structs/CustomMessageReader.ts | 61 + ts/structs/Description.ts | 17 +- ts/structs/Event.ts | 53 +- ts/structs/EventHandler.ts | 4 +- ts/structs/ExpiryTime.ts | 17 +- ts/structs/Fallback.ts | 5 + ts/structs/GossipTimestampFilter.ts | 10 +- ts/structs/HTLCFailChannelUpdate.ts | 83 - ts/structs/IgnoringMessageHandler.ts | 14 + ts/structs/InitFeatures.ts | 5 + ts/structs/InvoiceFeatures.ts | 5 + ts/structs/InvoiceSignature.ts | 12 +- ts/structs/KeysManager.ts | 2 - ts/structs/LockedNetworkGraph.ts | 27 - ts/structs/MessageSendEvent.ts | 20 - ts/structs/MessageSendEventsProvider.ts | 1 - ts/structs/MinFinalCltvExpiry.ts | 17 +- ts/structs/MonitorEvent.ts | 22 +- ts/structs/NetGraphMsgHandler.ts | 39 +- ts/structs/NetworkGraph.ts | 28 +- ts/structs/NetworkUpdate.ts | 88 + ts/structs/NodeAnnouncementInfo.ts | 2 - ts/structs/NodeFeatures.ts | 5 + ts/structs/Option_AccessZ.ts | 53 + ts/structs/Option_FilterZ.ts | 53 + ts/structs/Option_NetworkUpdateZ.ts | 59 + ts/structs/Option_TypeZ.ts | 60 + ts/structs/PayeePubKey.ts | 17 +- ts/structs/PaymentSendFailure.ts | 3 - ts/structs/PeerManager.ts | 5 +- ts/structs/PrivateRoute.ts | 17 +- ts/structs/QueryChannelRange.ts | 10 +- ts/structs/ReadOnlyNetworkGraph.ts | 21 + ts/structs/ReplyShortChannelIdsEnd.ts | 10 +- .../Result_COption_TypeZDecodeErrorZ.ts | 59 + ...C2Tuple_BlockHashChannelMonitorZZErrorZ.ts | 2 +- ts/structs/Result_NetworkGraphDecodeErrorZ.ts | 11 +- ts/structs/Result_NoneNoneZ.ts | 48 + .../Result_TrustedClosingTransactionNoneZ.ts | 56 + ts/structs/Route.ts | 42 +- ts/structs/RouteHint.ts | 17 +- ts/structs/RouteHintHop.ts | 17 +- ts/structs/RouteHop.ts | 11 + ts/structs/RoutingFees.ts | 5 + ts/structs/RoutingMessageHandler.ts | 15 +- ts/structs/Sha256.ts | 17 +- ts/structs/TrustedClosingTransaction.ts | 36 + ts/structs/Type.ts | 88 + ts/structs/UnsignedNodeAnnouncement.ts | 1 - ts/structs/UtilMethods.ts | 16 +- ts/structs/Watch.ts | 1 - 155 files changed, 18007 insertions(+), 4994 deletions(-) create mode 100644 src/main/java/org/ldk/structs/Balance.java create mode 100644 src/main/java/org/ldk/structs/ClosingTransaction.java create mode 100644 src/main/java/org/ldk/structs/ClosureReason.java create mode 100644 src/main/java/org/ldk/structs/CounterpartyForwardingInfo.java create mode 100644 src/main/java/org/ldk/structs/CustomMessageHandler.java create mode 100644 src/main/java/org/ldk/structs/CustomMessageReader.java delete mode 100644 src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java delete mode 100644 src/main/java/org/ldk/structs/LockedNetworkGraph.java create mode 100644 src/main/java/org/ldk/structs/NetworkUpdate.java create mode 100644 src/main/java/org/ldk/structs/Option_AccessZ.java create mode 100644 src/main/java/org/ldk/structs/Option_FilterZ.java create mode 100644 src/main/java/org/ldk/structs/Option_NetworkUpdateZ.java create mode 100644 src/main/java/org/ldk/structs/Option_TypeZ.java create mode 100644 src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java create mode 100644 src/main/java/org/ldk/structs/Result_COption_TypeZDecodeErrorZ.java create mode 100644 src/main/java/org/ldk/structs/Result_NoneNoneZ.java create mode 100644 src/main/java/org/ldk/structs/Result_TrustedClosingTransactionNoneZ.java create mode 100644 src/main/java/org/ldk/structs/TrustedClosingTransaction.java create mode 100644 src/main/java/org/ldk/structs/Type.java create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKBalance.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKCOption_AccessZ.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKCOption_FilterZ.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKCOption_TypeZ.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKClosureReason.h delete mode 100644 src/main/jni/org_ldk_impl_bindings_LDKHTLCFailChannelUpdate.h create mode 100644 src/main/jni/org_ldk_impl_bindings_LDKNetworkUpdate.h create mode 100644 ts/structs/Balance.ts create mode 100644 ts/structs/ClosingTransaction.ts create mode 100644 ts/structs/ClosureReason.ts create mode 100644 ts/structs/CounterpartyForwardingInfo.ts create mode 100644 ts/structs/CustomMessageHandler.ts create mode 100644 ts/structs/CustomMessageReader.ts delete mode 100644 ts/structs/HTLCFailChannelUpdate.ts delete mode 100644 ts/structs/LockedNetworkGraph.ts create mode 100644 ts/structs/NetworkUpdate.ts create mode 100644 ts/structs/Option_AccessZ.ts create mode 100644 ts/structs/Option_FilterZ.ts create mode 100644 ts/structs/Option_NetworkUpdateZ.ts create mode 100644 ts/structs/Option_TypeZ.ts create mode 100644 ts/structs/ReadOnlyNetworkGraph.ts create mode 100644 ts/structs/Result_COption_TypeZDecodeErrorZ.ts create mode 100644 ts/structs/Result_NoneNoneZ.ts create mode 100644 ts/structs/Result_TrustedClosingTransactionNoneZ.ts create mode 100644 ts/structs/TrustedClosingTransaction.ts create mode 100644 ts/structs/Type.ts diff --git a/pom.xml b/pom.xml index ad3302b9..833b75e9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.lightningdevkit ldk-java - 0.0.100.2 + 0.0.101.0 LDK Java Bindings and Binaries LDK Java Bindings and Release Binaries diff --git a/src/main/java/org/ldk/enums/SemanticError.java b/src/main/java/org/ldk/enums/SemanticError.java index f9ccd5d6..96023bd2 100644 --- a/src/main/java/org/ldk/enums/SemanticError.java +++ b/src/main/java/org/ldk/enums/SemanticError.java @@ -9,10 +9,12 @@ public enum SemanticError { LDKSemanticError_MultiplePaymentHashes, LDKSemanticError_NoDescription, LDKSemanticError_MultipleDescriptions, + LDKSemanticError_NoPaymentSecret, LDKSemanticError_MultiplePaymentSecrets, LDKSemanticError_InvalidFeatures, LDKSemanticError_InvalidRecoveryId, LDKSemanticError_InvalidSignature, + LDKSemanticError_ImpreciseAmount, ; static native void init(); static { init(); } } \ No newline at end of file diff --git a/src/main/java/org/ldk/impl/bindings.java b/src/main/java/org/ldk/impl/bindings.java index 7dabbeba..bf41b875 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -20,7 +20,7 @@ public class bindings { try { // Try to load natively first, this works on Android and in testing. System.loadLibrary("lightningjni"); - } catch (UnsatisfiedLinkError _ignored) { + } catch (UnsatisfiedLinkError system_load_err) { // Otherwise try to load from the library jar. File tmpdir = new File(System.getProperty("java.io.tmpdir"), "ldk-java-nativelib"); tmpdir.mkdir(); // If it fails to create, assume it was there already @@ -32,6 +32,9 @@ public class bindings { Files.copy(is, libpath, StandardCopyOption.REPLACE_EXISTING); Runtime.getRuntime().load(libpath.toString()); } catch (IOException e) { + System.err.println("Failed to load LDK native library."); + System.err.println("System LDK native library load failed with: " + system_load_err); + System.err.println("Resource-based LDK native library load failed with: " + e); throw new IllegalArgumentException(e); } } @@ -48,7 +51,7 @@ public class bindings { static native String get_lib_version_string(); public static String get_ldk_java_bindings_version() { - return "v0.0.100.2"; + return "v0.0.101.0"; } public static native String get_ldk_c_bindings_version(); public static native String get_ldk_version(); @@ -124,6 +127,9 @@ public class bindings { public static native boolean LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_TrustedClosingTransactionNoneZ_result_ok(long arg); + public static native long LDKCResult_TrustedClosingTransactionNoneZ_get_ok(long arg); + public static native void LDKCResult_TrustedClosingTransactionNoneZ_get_err(long arg); public static native boolean LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(long arg); @@ -183,9 +189,9 @@ public class bindings { public long htlc_event; HTLCEvent(long htlc_event) { this.htlc_event = htlc_event; } } - public final static class CommitmentTxBroadcasted extends LDKMonitorEvent { - public long commitment_tx_broadcasted; - CommitmentTxBroadcasted(long commitment_tx_broadcasted) { this.commitment_tx_broadcasted = commitment_tx_broadcasted; } + public final static class CommitmentTxConfirmed extends LDKMonitorEvent { + public long commitment_tx_confirmed; + CommitmentTxConfirmed(long commitment_tx_confirmed) { this.commitment_tx_confirmed = commitment_tx_confirmed; } } static native void init(); } @@ -205,6 +211,39 @@ public class bindings { } static { LDKCOption_C2Tuple_usizeTransactionZZ.init(); } public static native LDKCOption_C2Tuple_usizeTransactionZZ LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(long ptr); + public static class LDKNetworkUpdate { + private LDKNetworkUpdate() {} + public final static class ChannelUpdateMessage extends LDKNetworkUpdate { + public long msg; + ChannelUpdateMessage(long msg) { this.msg = msg; } + } + public final static class ChannelClosed extends LDKNetworkUpdate { + public long short_channel_id; + public boolean is_permanent; + ChannelClosed(long short_channel_id, boolean is_permanent) { this.short_channel_id = short_channel_id; this.is_permanent = is_permanent; } + } + public final static class NodeFailure extends LDKNetworkUpdate { + public byte[] node_id; + public boolean is_permanent; + NodeFailure(byte[] node_id, boolean is_permanent) { this.node_id = node_id; this.is_permanent = is_permanent; } + } + static native void init(); + } + static { LDKNetworkUpdate.init(); } + public static native LDKNetworkUpdate LDKNetworkUpdate_ref_from_ptr(long ptr); + public static class LDKCOption_NetworkUpdateZ { + private LDKCOption_NetworkUpdateZ() {} + public final static class Some extends LDKCOption_NetworkUpdateZ { + public long some; + Some(long some) { this.some = some; } + } + public final static class None extends LDKCOption_NetworkUpdateZ { + None() { } + } + static native void init(); + } + static { LDKCOption_NetworkUpdateZ.init(); } + public static native LDKCOption_NetworkUpdateZ LDKCOption_NetworkUpdateZ_ref_from_ptr(long ptr); public static class LDKSpendableOutputDescriptor { private LDKSpendableOutputDescriptor() {} public final static class StaticOutput extends LDKSpendableOutputDescriptor { @@ -246,26 +285,6 @@ public class bindings { } static { LDKErrorAction.init(); } public static native LDKErrorAction LDKErrorAction_ref_from_ptr(long ptr); - public static class LDKHTLCFailChannelUpdate { - private LDKHTLCFailChannelUpdate() {} - public final static class ChannelUpdateMessage extends LDKHTLCFailChannelUpdate { - public long msg; - ChannelUpdateMessage(long msg) { this.msg = msg; } - } - public final static class ChannelClosed extends LDKHTLCFailChannelUpdate { - public long short_channel_id; - public boolean is_permanent; - ChannelClosed(long short_channel_id, boolean is_permanent) { this.short_channel_id = short_channel_id; this.is_permanent = is_permanent; } - } - public final static class NodeFailure extends LDKHTLCFailChannelUpdate { - public byte[] node_id; - public boolean is_permanent; - NodeFailure(byte[] node_id, boolean is_permanent) { this.node_id = node_id; this.is_permanent = is_permanent; } - } - static native void init(); - } - static { LDKHTLCFailChannelUpdate.init(); } - public static native LDKHTLCFailChannelUpdate LDKHTLCFailChannelUpdate_ref_from_ptr(long ptr); public static class LDKMessageSendEvent { private LDKMessageSendEvent() {} public final static class SendAcceptChannel extends LDKMessageSendEvent { @@ -346,10 +365,6 @@ public class bindings { public long action; HandleError(byte[] node_id, long action) { this.node_id = node_id; this.action = action; } } - public final static class PaymentFailureNetworkUpdate extends LDKMessageSendEvent { - public long update; - PaymentFailureNetworkUpdate(long update) { this.update = update; } - } public final static class SendChannelRangeQuery extends LDKMessageSendEvent { public byte[] node_id; public long msg; @@ -391,6 +406,9 @@ public class bindings { public static native boolean LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_NoneNoneZ_result_ok(long arg); + public static native void LDKCResult_NoneNoneZ_get_ok(long arg); + public static native void LDKCResult_NoneNoneZ_get_err(long arg); public static native long LDKC2Tuple_SignatureCVec_SignatureZZ_new(byte[] a, byte[][] b); public static native byte[] LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(long ptr); public static native byte[][] LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(long ptr); @@ -403,13 +421,15 @@ public class bindings { public interface LDKBaseSign { byte[] get_per_commitment_point(long idx); byte[] release_commitment_secret(long idx); + long validate_holder_commitment(long holder_tx); byte[] channel_keys_id(); long sign_counterparty_commitment(long commitment_tx); + long validate_counterparty_revocation(long idx, byte[] secret); long sign_holder_commitment_and_htlcs(long commitment_tx); long sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key); long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc); long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc); - long sign_closing_transaction(byte[] closing_tx); + long sign_closing_transaction(long closing_tx); long sign_channel_announcement(long msg); void ready_channel(long channel_parameters); } @@ -418,10 +438,14 @@ public class bindings { public static native byte[] BaseSign_get_per_commitment_point(long this_arg, long idx); // LDKThirtyTwoBytes BaseSign_release_commitment_secret LDKBaseSign *NONNULL_PTR this_arg, uint64_t idx public static native byte[] BaseSign_release_commitment_secret(long this_arg, long idx); + // LDKCResult_NoneNoneZ BaseSign_validate_holder_commitment LDKBaseSign *NONNULL_PTR this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx + public static native long BaseSign_validate_holder_commitment(long this_arg, long holder_tx); // LDKThirtyTwoBytes BaseSign_channel_keys_id LDKBaseSign *NONNULL_PTR this_arg public static native byte[] BaseSign_channel_keys_id(long this_arg); // LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign_sign_counterparty_commitment LDKBaseSign *NONNULL_PTR this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx public static native long BaseSign_sign_counterparty_commitment(long this_arg, long commitment_tx); + // LDKCResult_NoneNoneZ BaseSign_validate_counterparty_revocation LDKBaseSign *NONNULL_PTR this_arg, uint64_t idx, const uint8_t (*secret)[32] + public static native long BaseSign_validate_counterparty_revocation(long this_arg, long idx, byte[] secret); // LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign_sign_holder_commitment_and_htlcs LDKBaseSign *NONNULL_PTR this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx public static native long BaseSign_sign_holder_commitment_and_htlcs(long this_arg, long commitment_tx); // LDKCResult_SignatureNoneZ BaseSign_sign_justice_revoked_output LDKBaseSign *NONNULL_PTR this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32] @@ -430,8 +454,8 @@ public class bindings { public static native long BaseSign_sign_justice_revoked_htlc(long this_arg, byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc); // LDKCResult_SignatureNoneZ BaseSign_sign_counterparty_htlc_transaction LDKBaseSign *NONNULL_PTR this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc public static native long BaseSign_sign_counterparty_htlc_transaction(long this_arg, byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc); - // LDKCResult_SignatureNoneZ BaseSign_sign_closing_transaction LDKBaseSign *NONNULL_PTR this_arg, struct LDKTransaction closing_tx - public static native long BaseSign_sign_closing_transaction(long this_arg, byte[] closing_tx); + // LDKCResult_SignatureNoneZ BaseSign_sign_closing_transaction LDKBaseSign *NONNULL_PTR this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx + public static native long BaseSign_sign_closing_transaction(long this_arg, long closing_tx); // LDKCResult_SignatureNoneZ BaseSign_sign_channel_announcement LDKBaseSign *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg public static native long BaseSign_sign_channel_announcement(long this_arg, long msg); // void BaseSign_ready_channel LDKBaseSign *NONNULL_PTR this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters @@ -644,6 +668,34 @@ public class bindings { public static native boolean LDKCResult_OutPointDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_OutPointDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_OutPointDecodeErrorZ_get_err(long arg); + public interface LDKType { + short type_id(); + String debug_str(); + byte[] write(); + } + public static native long LDKType_new(LDKType impl); + // uint16_t Type_type_id LDKType *NONNULL_PTR this_arg + public static native short Type_type_id(long this_arg); + // LDKStr Type_debug_str LDKType *NONNULL_PTR this_arg + public static native String Type_debug_str(long this_arg); + // LDKCVec_u8Z Type_write LDKType *NONNULL_PTR this_arg + public static native byte[] Type_write(long this_arg); + public static class LDKCOption_TypeZ { + private LDKCOption_TypeZ() {} + public final static class Some extends LDKCOption_TypeZ { + public long some; + Some(long some) { this.some = some; } + } + public final static class None extends LDKCOption_TypeZ { + None() { } + } + static native void init(); + } + static { LDKCOption_TypeZ.init(); } + public static native LDKCOption_TypeZ LDKCOption_TypeZ_ref_from_ptr(long ptr); + public static native boolean LDKCResult_COption_TypeZDecodeErrorZ_result_ok(long arg); + public static native long LDKCResult_COption_TypeZDecodeErrorZ_get_ok(long arg); + public static native long LDKCResult_COption_TypeZDecodeErrorZ_get_err(long arg); public static native boolean LDKCResult_SiPrefixNoneZ_result_ok(long arg); public static native SiPrefix LDKCResult_SiPrefixNoneZ_get_ok(long arg); public static native void LDKCResult_SiPrefixNoneZ_get_err(long arg); @@ -718,6 +770,35 @@ public class bindings { } static { LDKPaymentPurpose.init(); } public static native LDKPaymentPurpose LDKPaymentPurpose_ref_from_ptr(long ptr); + public static class LDKClosureReason { + private LDKClosureReason() {} + public final static class CounterpartyForceClosed extends LDKClosureReason { + public String peer_msg; + CounterpartyForceClosed(String peer_msg) { this.peer_msg = peer_msg; } + } + public final static class HolderForceClosed extends LDKClosureReason { + HolderForceClosed() { } + } + public final static class CooperativeClosure extends LDKClosureReason { + CooperativeClosure() { } + } + public final static class CommitmentTxConfirmed extends LDKClosureReason { + CommitmentTxConfirmed() { } + } + public final static class ProcessingError extends LDKClosureReason { + public String err; + ProcessingError(String err) { this.err = err; } + } + public final static class DisconnectedPeer extends LDKClosureReason { + DisconnectedPeer() { } + } + public final static class OutdatedChannelManager extends LDKClosureReason { + OutdatedChannelManager() { } + } + static native void init(); + } + static { LDKClosureReason.init(); } + public static native LDKClosureReason LDKClosureReason_ref_from_ptr(long ptr); public static class LDKEvent { private LDKEvent() {} public final static class FundingGenerationReady extends LDKEvent { @@ -737,10 +818,13 @@ public class bindings { public byte[] payment_preimage; PaymentSent(byte[] payment_preimage) { this.payment_preimage = payment_preimage; } } - public final static class PaymentFailed extends LDKEvent { + public final static class PaymentPathFailed extends LDKEvent { public byte[] payment_hash; public boolean rejected_by_dest; - PaymentFailed(byte[] payment_hash, boolean rejected_by_dest) { this.payment_hash = payment_hash; this.rejected_by_dest = rejected_by_dest; } + public long network_update; + public boolean all_paths_failed; + public long[] path; + PaymentPathFailed(byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path) { this.payment_hash = payment_hash; this.rejected_by_dest = rejected_by_dest; this.network_update = network_update; this.all_paths_failed = all_paths_failed; this.path = path; } } public final static class PendingHTLCsForwardable extends LDKEvent { public long time_forwardable; @@ -755,6 +839,11 @@ public class bindings { public boolean claim_from_onchain_tx; PaymentForwarded(long fee_earned_msat, boolean claim_from_onchain_tx) { this.fee_earned_msat = fee_earned_msat; this.claim_from_onchain_tx = claim_from_onchain_tx; } } + public final static class ChannelClosed extends LDKEvent { + public byte[] channel_id; + public long reason; + ChannelClosed(byte[] channel_id, long reason) { this.channel_id = channel_id; this.reason = reason; } + } static native void init(); } static { LDKEvent.init(); } @@ -768,9 +857,42 @@ public class bindings { public static native byte[] LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(long ptr); public static native long[] LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(long ptr); public static native long LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(long[] elems); + public static class LDKBalance { + private LDKBalance() {} + public final static class ClaimableOnChannelClose extends LDKBalance { + public long claimable_amount_satoshis; + ClaimableOnChannelClose(long claimable_amount_satoshis) { this.claimable_amount_satoshis = claimable_amount_satoshis; } + } + public final static class ClaimableAwaitingConfirmations extends LDKBalance { + public long claimable_amount_satoshis; + public int confirmation_height; + ClaimableAwaitingConfirmations(long claimable_amount_satoshis, int confirmation_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.confirmation_height = confirmation_height; } + } + public final static class ContentiousClaimable extends LDKBalance { + public long claimable_amount_satoshis; + public int timeout_height; + ContentiousClaimable(long claimable_amount_satoshis, int timeout_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.timeout_height = timeout_height; } + } + public final static class MaybeClaimableHTLCAwaitingTimeout extends LDKBalance { + public long claimable_amount_satoshis; + public int claimable_height; + MaybeClaimableHTLCAwaitingTimeout(long claimable_amount_satoshis, int claimable_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.claimable_height = claimable_height; } + } + static native void init(); + } + static { LDKBalance.init(); } + public static native LDKBalance LDKBalance_ref_from_ptr(long ptr); + public static native long LDKCVec_BalanceZ_new(long[] elems); public static native boolean LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_NoneLightningErrorZ_result_ok(long arg); + public static native void LDKCResult_NoneLightningErrorZ_get_ok(long arg); + public static native long LDKCResult_NoneLightningErrorZ_get_err(long arg); + public static native long LDKC2Tuple_PublicKeyTypeZ_new(byte[] a, long b); + public static native byte[] LDKC2Tuple_PublicKeyTypeZ_get_a(long ptr); + public static native long LDKC2Tuple_PublicKeyTypeZ_get_b(long ptr); + public static native long LDKCVec_C2Tuple_PublicKeyTypeZZ_new(long[] elems); public static native boolean LDKCResult_boolLightningErrorZ_result_ok(long arg); public static native boolean LDKCResult_boolLightningErrorZ_get_ok(long arg); public static native long LDKCResult_boolLightningErrorZ_get_err(long arg); @@ -780,9 +902,6 @@ public class bindings { public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(long ptr); public static native long LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(long[] elems); public static native long LDKCVec_NodeAnnouncementZ_new(long[] elems); - public static native boolean LDKCResult_NoneLightningErrorZ_result_ok(long arg); - public static native void LDKCResult_NoneLightningErrorZ_get_ok(long arg); - public static native long LDKCResult_NoneLightningErrorZ_get_err(long arg); public static native boolean LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(long arg); public static native byte[] LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(long arg); public static native long LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(long arg); @@ -792,6 +911,25 @@ public class bindings { public static native boolean LDKCResult_boolPeerHandleErrorZ_result_ok(long arg); public static native boolean LDKCResult_boolPeerHandleErrorZ_get_ok(long arg); public static native long LDKCResult_boolPeerHandleErrorZ_get_err(long arg); + public interface LDKAccess { + long get_utxo(byte[] genesis_hash, long short_channel_id); + } + public static native long LDKAccess_new(LDKAccess impl); + // LDKCResult_TxOutAccessErrorZ Access_get_utxo LDKAccess *NONNULL_PTR this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id + public static native long Access_get_utxo(long this_arg, byte[] genesis_hash, long short_channel_id); + public static class LDKCOption_AccessZ { + private LDKCOption_AccessZ() {} + public final static class Some extends LDKCOption_AccessZ { + public long some; + Some(long some) { this.some = some; } + } + public final static class None extends LDKCOption_AccessZ { + None() { } + } + static native void init(); + } + static { LDKCOption_AccessZ.init(); } + public static native LDKCOption_AccessZ LDKCOption_AccessZ_ref_from_ptr(long ptr); public static native boolean LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(long arg); @@ -936,6 +1074,28 @@ public class bindings { public static native boolean LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(long arg); public static native long LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(long arg); public static native long LDKCResult_InvoiceSignOrCreationErrorZ_get_err(long arg); + public interface LDKFilter { + void register_tx(byte[] txid, byte[] script_pubkey); + long register_output(long output); + } + public static native long LDKFilter_new(LDKFilter impl); + // void Filter_register_tx LDKFilter *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey + public static native void Filter_register_tx(long this_arg, byte[] txid, byte[] script_pubkey); + // LDKCOption_C2Tuple_usizeTransactionZZ Filter_register_output LDKFilter *NONNULL_PTR this_arg, struct LDKWatchedOutput output + public static native long Filter_register_output(long this_arg, long output); + public static class LDKCOption_FilterZ { + private LDKCOption_FilterZ() {} + public final static class Some extends LDKCOption_FilterZ { + public long some; + Some(long some) { this.some = some; } + } + public final static class None extends LDKCOption_FilterZ { + None() { } + } + static native void init(); + } + static { LDKCOption_FilterZ.init(); } + public static native LDKCOption_FilterZ LDKCOption_FilterZ_ref_from_ptr(long ptr); public interface LDKMessageSendEventsProvider { long[] get_and_clear_pending_msg_events(); } @@ -946,7 +1106,7 @@ public class bindings { void handle_event(long event); } public static native long LDKEventHandler_new(LDKEventHandler impl); - // void EventHandler_handle_event LDKEventHandler *NONNULL_PTR this_arg, struct LDKEvent event + // void EventHandler_handle_event LDKEventHandler *NONNULL_PTR this_arg, const struct LDKEvent *NONNULL_PTR event public static native void EventHandler_handle_event(long this_arg, long event); public interface LDKEventsProvider { void process_pending_events(long handler); @@ -954,12 +1114,6 @@ public class bindings { public static native long LDKEventsProvider_new(LDKEventsProvider impl); // void EventsProvider_process_pending_events LDKEventsProvider *NONNULL_PTR this_arg, struct LDKEventHandler handler public static native void EventsProvider_process_pending_events(long this_arg, long handler); - public interface LDKAccess { - long get_utxo(byte[] genesis_hash, long short_channel_id); - } - public static native long LDKAccess_new(LDKAccess impl); - // LDKCResult_TxOutAccessErrorZ Access_get_utxo LDKAccess *NONNULL_PTR this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id - public static native long Access_get_utxo(long this_arg, byte[] genesis_hash, long short_channel_id); public interface LDKListen { void block_connected(byte[] block, int height); void block_disconnected(byte[] header, int height); @@ -984,15 +1138,6 @@ public class bindings { public static native void Confirm_best_block_updated(long this_arg, byte[] header, int height); // LDKCVec_TxidZ Confirm_get_relevant_txids LDKConfirm *NONNULL_PTR this_arg public static native byte[][] Confirm_get_relevant_txids(long this_arg); - public interface LDKFilter { - void register_tx(byte[] txid, byte[] script_pubkey); - long register_output(long output); - } - public static native long LDKFilter_new(LDKFilter impl); - // void Filter_register_tx LDKFilter *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey - public static native void Filter_register_tx(long this_arg, byte[] txid, byte[] script_pubkey); - // LDKCOption_C2Tuple_usizeTransactionZZ Filter_register_output LDKFilter *NONNULL_PTR this_arg, struct LDKWatchedOutput output - public static native long Filter_register_output(long this_arg, long output); public interface LDKPersist { long persist_new_channel(long id, long data); long update_persisted_channel(long id, long update, long data); @@ -1070,7 +1215,6 @@ public class bindings { long handle_node_announcement(long msg); long handle_channel_announcement(long msg); long handle_channel_update(long msg); - void handle_htlc_fail_channel_update(long update); long[] get_next_channel_announcements(long starting_point, byte batch_amount); long[] get_next_node_announcements(byte[] starting_point, byte batch_amount); void sync_routing_table(byte[] their_node_id, long init); @@ -1087,8 +1231,6 @@ public class bindings { public static native long RoutingMessageHandler_handle_channel_announcement(long this_arg, long msg); // LDKCResult_boolLightningErrorZ RoutingMessageHandler_handle_channel_update LDKRoutingMessageHandler *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg public static native long RoutingMessageHandler_handle_channel_update(long this_arg, long msg); - // void RoutingMessageHandler_handle_htlc_fail_channel_update LDKRoutingMessageHandler *NONNULL_PTR this_arg, const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update - public static native void RoutingMessageHandler_handle_htlc_fail_channel_update(long this_arg, long update); // LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler_get_next_channel_announcements LDKRoutingMessageHandler *NONNULL_PTR this_arg, uint64_t starting_point, uint8_t batch_amount public static native long[] RoutingMessageHandler_get_next_channel_announcements(long this_arg, long starting_point, byte batch_amount); // LDKCVec_NodeAnnouncementZ RoutingMessageHandler_get_next_node_announcements LDKRoutingMessageHandler *NONNULL_PTR this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount @@ -1103,6 +1245,22 @@ public class bindings { public static native long RoutingMessageHandler_handle_query_channel_range(long this_arg, byte[] their_node_id, long msg); // LDKCResult_NoneLightningErrorZ RoutingMessageHandler_handle_query_short_channel_ids LDKRoutingMessageHandler *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg public static native long RoutingMessageHandler_handle_query_short_channel_ids(long this_arg, byte[] their_node_id, long msg); + public interface LDKCustomMessageReader { + long read(short message_type, byte[] buffer); + } + public static native long LDKCustomMessageReader_new(LDKCustomMessageReader impl); + // LDKCResult_COption_TypeZDecodeErrorZ CustomMessageReader_read LDKCustomMessageReader *NONNULL_PTR this_arg, uint16_t message_type, struct LDKu8slice buffer + public static native long CustomMessageReader_read(long this_arg, short message_type, byte[] buffer); + public interface LDKCustomMessageHandler { + long handle_custom_message(long msg, byte[] sender_node_id); + long[] get_and_clear_pending_msg(); + } + public static native long LDKCustomMessageHandler_new(LDKCustomMessageHandler impl, LDKCustomMessageReader CustomMessageReader); + public static native long LDKCustomMessageHandler_get_CustomMessageReader(long arg); + // LDKCResult_NoneLightningErrorZ CustomMessageHandler_handle_custom_message LDKCustomMessageHandler *NONNULL_PTR this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id + public static native long CustomMessageHandler_handle_custom_message(long this_arg, long msg, byte[] sender_node_id); + // LDKCVec_C2Tuple_PublicKeyTypeZZ CustomMessageHandler_get_and_clear_pending_msg LDKCustomMessageHandler *NONNULL_PTR this_arg + public static native long[] CustomMessageHandler_get_and_clear_pending_msg(long this_arg); public interface LDKSocketDescriptor { long send_data(byte[] data, boolean resume_read); void disconnect_socket(); @@ -1243,6 +1401,12 @@ public class bindings { public static native void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(long _res); // struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); public static native long CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(long orig); + // struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); + public static native long CResult_TrustedClosingTransactionNoneZ_ok(long o); + // struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); + public static native long CResult_TrustedClosingTransactionNoneZ_err(); + // void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); + public static native void CResult_TrustedClosingTransactionNoneZ_free(long _res); // struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); public static native long CResult_CommitmentTransactionDecodeErrorZ_ok(long o); // struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); @@ -1363,6 +1527,14 @@ public class bindings { public static native void COption_C2Tuple_usizeTransactionZZ_free(long _res); // struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig); public static native long COption_C2Tuple_usizeTransactionZZ_clone(long orig); + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); + public static native long COption_NetworkUpdateZ_some(long o); + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); + public static native long COption_NetworkUpdateZ_none(); + // void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); + public static native void COption_NetworkUpdateZ_free(long _res); + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); + public static native long COption_NetworkUpdateZ_clone(long orig); // void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); public static native void CVec_SpendableOutputDescriptorZ_free(long[] _res); // void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); @@ -1415,6 +1587,14 @@ public class bindings { public static native void CResult_SpendableOutputDescriptorDecodeErrorZ_free(long _res); // struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); public static native long CResult_SpendableOutputDescriptorDecodeErrorZ_clone(long orig); + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); + public static native long CResult_NoneNoneZ_ok(); + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); + public static native long CResult_NoneNoneZ_err(); + // void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); + public static native void CResult_NoneNoneZ_free(long _res); + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); + public static native long CResult_NoneNoneZ_clone(long orig); // struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); public static native long C2Tuple_SignatureCVec_SignatureZZ_clone(long orig); // struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); @@ -1575,6 +1755,22 @@ public class bindings { public static native void CResult_OutPointDecodeErrorZ_free(long _res); // struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); public static native long CResult_OutPointDecodeErrorZ_clone(long orig); + // struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); + public static native long COption_TypeZ_some(long o); + // struct LDKCOption_TypeZ COption_TypeZ_none(void); + public static native long COption_TypeZ_none(); + // void COption_TypeZ_free(struct LDKCOption_TypeZ _res); + public static native void COption_TypeZ_free(long _res); + // struct LDKCOption_TypeZ COption_TypeZ_clone(const struct LDKCOption_TypeZ *NONNULL_PTR orig); + public static native long COption_TypeZ_clone(long orig); + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); + public static native long CResult_COption_TypeZDecodeErrorZ_ok(long o); + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); + public static native long CResult_COption_TypeZDecodeErrorZ_err(long e); + // void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); + public static native void CResult_COption_TypeZDecodeErrorZ_free(long _res); + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_clone(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR orig); + public static native long CResult_COption_TypeZDecodeErrorZ_clone(long orig); // struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o); public static native long CResult_SiPrefixNoneZ_ok(SiPrefix o); // struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_err(void); @@ -1735,12 +1931,30 @@ public class bindings { public static native void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(long _res); // void CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res); public static native void CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(long[] _res); + // void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); + public static native void CVec_BalanceZ_free(long[] _res); // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); public static native long CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(long o); // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); public static native long CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(long e); // void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); public static native void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(long _res); + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); + public static native long CResult_NoneLightningErrorZ_ok(); + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); + public static native long CResult_NoneLightningErrorZ_err(long e); + // void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); + public static native void CResult_NoneLightningErrorZ_free(long _res); + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); + public static native long CResult_NoneLightningErrorZ_clone(long orig); + // struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_clone(const struct LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR orig); + public static native long C2Tuple_PublicKeyTypeZ_clone(long orig); + // struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); + public static native long C2Tuple_PublicKeyTypeZ_new(byte[] a, long b); + // void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); + public static native void C2Tuple_PublicKeyTypeZ_free(long _res); + // void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); + public static native void CVec_C2Tuple_PublicKeyTypeZZ_free(long[] _res); // struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); public static native long CResult_boolLightningErrorZ_ok(boolean o); // struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); @@ -1759,14 +1973,6 @@ public class bindings { public static native void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(long[] _res); // void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); public static native void CVec_NodeAnnouncementZ_free(long[] _res); - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); - public static native long CResult_NoneLightningErrorZ_ok(); - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); - public static native long CResult_NoneLightningErrorZ_err(long e); - // void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); - public static native void CResult_NoneLightningErrorZ_free(long _res); - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); - public static native long CResult_NoneLightningErrorZ_clone(long orig); // void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); public static native void CVec_PublicKeyZ_free(byte[][] _res); // struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); @@ -1793,6 +1999,12 @@ public class bindings { public static native void CResult_boolPeerHandleErrorZ_free(long _res); // struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); public static native long CResult_boolPeerHandleErrorZ_clone(long orig); + // struct LDKCOption_AccessZ COption_AccessZ_some(struct LDKAccess o); + public static native long COption_AccessZ_some(long o); + // struct LDKCOption_AccessZ COption_AccessZ_none(void); + public static native long COption_AccessZ_none(); + // void COption_AccessZ_free(struct LDKCOption_AccessZ _res); + public static native void COption_AccessZ_free(long _res); // struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); public static native long CResult_DirectionalChannelInfoDecodeErrorZ_ok(long o); // struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); @@ -1841,8 +2053,6 @@ public class bindings { public static native long CResult_NetworkGraphDecodeErrorZ_err(long e); // void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); public static native void CResult_NetworkGraphDecodeErrorZ_free(long _res); - // struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); - public static native long CResult_NetworkGraphDecodeErrorZ_clone(long orig); // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_ok(struct LDKNetAddress o); public static native long CResult_NetAddressu8Z_ok(long o); // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_err(uint8_t e); @@ -2139,6 +2349,12 @@ public class bindings { public static native void CResult_InvoiceSignOrCreationErrorZ_free(long _res); // struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); public static native long CResult_InvoiceSignOrCreationErrorZ_clone(long orig); + // struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); + public static native long COption_FilterZ_some(long o); + // struct LDKCOption_FilterZ COption_FilterZ_none(void); + public static native long COption_FilterZ_none(); + // void COption_FilterZ_free(struct LDKCOption_FilterZ _res); + public static native void COption_FilterZ_free(long _res); // void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); public static native void PaymentPurpose_free(long this_ptr); // struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); @@ -2147,6 +2363,26 @@ public class bindings { public static native long PaymentPurpose_invoice_payment(byte[] payment_preimage, byte[] payment_secret, long user_payment_id); // struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); public static native long PaymentPurpose_spontaneous_payment(byte[] a); + // void ClosureReason_free(struct LDKClosureReason this_ptr); + public static native void ClosureReason_free(long this_ptr); + // struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); + public static native long ClosureReason_clone(long orig); + // struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg); + public static native long ClosureReason_counterparty_force_closed(String peer_msg); + // struct LDKClosureReason ClosureReason_holder_force_closed(void); + public static native long ClosureReason_holder_force_closed(); + // struct LDKClosureReason ClosureReason_cooperative_closure(void); + public static native long ClosureReason_cooperative_closure(); + // struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); + public static native long ClosureReason_commitment_tx_confirmed(); + // struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); + public static native long ClosureReason_processing_error(String err); + // struct LDKClosureReason ClosureReason_disconnected_peer(void); + public static native long ClosureReason_disconnected_peer(); + // struct LDKClosureReason ClosureReason_outdated_channel_manager(void); + public static native long ClosureReason_outdated_channel_manager(); + // struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); + public static native byte[] ClosureReason_write(long obj); // void Event_free(struct LDKEvent this_ptr); public static native void Event_free(long this_ptr); // struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); @@ -2157,14 +2393,16 @@ public class bindings { public static native long Event_payment_received(byte[] payment_hash, long amt, long purpose); // struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage); public static native long Event_payment_sent(byte[] payment_preimage); - // struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest); - public static native long Event_payment_failed(byte[] payment_hash, boolean rejected_by_dest); + // struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path); + public static native long Event_payment_path_failed(byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path); // struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); public static native long Event_pending_htlcs_forwardable(long time_forwardable); // struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs); public static native long Event_spendable_outputs(long[] outputs); // struct LDKEvent Event_payment_forwarded(struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx); public static native long Event_payment_forwarded(long fee_earned_msat, boolean claim_from_onchain_tx); + // struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKClosureReason reason); + public static native long Event_channel_closed(byte[] channel_id, long reason); // struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); public static native byte[] Event_write(long obj); // void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); @@ -2203,8 +2441,6 @@ public class bindings { public static native long MessageSendEvent_send_channel_update(byte[] node_id, long msg); // struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); public static native long MessageSendEvent_handle_error(byte[] node_id, long action); - // struct LDKMessageSendEvent MessageSendEvent_payment_failure_network_update(struct LDKHTLCFailChannelUpdate update); - public static native long MessageSendEvent_payment_failure_network_update(long update); // struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); public static native long MessageSendEvent_send_channel_range_query(byte[] node_id, long msg); // struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); @@ -2447,8 +2683,10 @@ public class bindings { public static native void FeeEstimator_free(long this_ptr); // void ChainMonitor_free(struct LDKChainMonitor this_obj); public static native void ChainMonitor_free(long this_obj); - // MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); + // MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); public static native long ChainMonitor_new(long chain_source, long broadcaster, long logger, long feeest, long persister); + // MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); + public static native long[] ChainMonitor_get_claimable_balances(long this_arg, long[] ignored_channels); // struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); public static native long ChainMonitor_as_Listen(long this_arg); // struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); @@ -2485,8 +2723,8 @@ public class bindings { public static native long MonitorEvent_clone(long orig); // struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); public static native long MonitorEvent_htlcevent(long a); - // struct LDKMonitorEvent MonitorEvent_commitment_tx_broadcasted(struct LDKOutPoint a); - public static native long MonitorEvent_commitment_tx_broadcasted(long a); + // struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); + public static native long MonitorEvent_commitment_tx_confirmed(long a); // void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); public static native void HTLCUpdate_free(long this_obj); // struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); @@ -2495,6 +2733,20 @@ public class bindings { public static native byte[] HTLCUpdate_write(long obj); // struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); public static native long HTLCUpdate_read(byte[] ser); + // void Balance_free(struct LDKBalance this_ptr); + public static native void Balance_free(long this_ptr); + // struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); + public static native long Balance_clone(long orig); + // struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); + public static native long Balance_claimable_on_channel_close(long claimable_amount_satoshis); + // struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); + public static native long Balance_claimable_awaiting_confirmations(long claimable_amount_satoshis, int confirmation_height); + // struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); + public static native long Balance_contentious_claimable(long claimable_amount_satoshis, int timeout_height); + // struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height); + public static native long Balance_maybe_claimable_htlcawaiting_timeout(long claimable_amount_satoshis, int claimable_height); + // bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); + public static native boolean Balance_eq(long a, long b); // void ChannelMonitor_free(struct LDKChannelMonitor this_obj); public static native void ChannelMonitor_free(long this_obj); // struct LDKChannelMonitor ChannelMonitor_clone(const struct LDKChannelMonitor *NONNULL_PTR orig); @@ -2531,6 +2783,8 @@ public class bindings { public static native byte[][] ChannelMonitor_get_relevant_txids(long this_arg); // MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); public static native long ChannelMonitor_current_best_block(long this_arg); + // MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + public static native long[] ChannelMonitor_get_claimable_balances(long this_arg); // void Persist_free(struct LDKPersist this_ptr); public static native void Persist_free(long this_ptr); // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); @@ -2721,6 +2975,24 @@ public class bindings { public static native long ChainParameters_new(Network network_arg, long best_block_arg); // struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); public static native long ChainParameters_clone(long orig); + // void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); + public static native void CounterpartyForwardingInfo_free(long this_obj); + // uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + public static native int CounterpartyForwardingInfo_get_fee_base_msat(long this_ptr); + // void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + public static native void CounterpartyForwardingInfo_set_fee_base_msat(long this_ptr, int val); + // uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + public static native int CounterpartyForwardingInfo_get_fee_proportional_millionths(long this_ptr); + // void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + public static native void CounterpartyForwardingInfo_set_fee_proportional_millionths(long this_ptr, int val); + // uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + public static native short CounterpartyForwardingInfo_get_cltv_expiry_delta(long this_ptr); + // void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); + public static native void CounterpartyForwardingInfo_set_cltv_expiry_delta(long this_ptr, short val); + // MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); + public static native long CounterpartyForwardingInfo_new(int fee_base_msat_arg, int fee_proportional_millionths_arg, short cltv_expiry_delta_arg); + // struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); + public static native long CounterpartyForwardingInfo_clone(long orig); // void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); public static native void ChannelCounterparty_free(long this_obj); // struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); @@ -2735,6 +3007,12 @@ public class bindings { public static native long ChannelCounterparty_get_unspendable_punishment_reserve(long this_ptr); // void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); public static native void ChannelCounterparty_set_unspendable_punishment_reserve(long this_ptr, long val); + // struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + public static native long ChannelCounterparty_get_forwarding_info(long this_ptr); + // void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); + public static native void ChannelCounterparty_set_forwarding_info(long this_ptr, long val); + // MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg); + public static native long ChannelCounterparty_new(byte[] node_id_arg, long features_arg, long unspendable_punishment_reserve_arg, long forwarding_info_arg); // struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); public static native long ChannelCounterparty_clone(long orig); // void ChannelDetails_free(struct LDKChannelDetails this_obj); @@ -3643,12 +3921,20 @@ public class bindings { public static native long LightningError_clone(long orig); // void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); public static native void CommitmentUpdate_free(long this_obj); + // struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + public static native long[] CommitmentUpdate_get_update_add_htlcs(long this_ptr); // void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); public static native void CommitmentUpdate_set_update_add_htlcs(long this_ptr, long[] val); + // struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + public static native long[] CommitmentUpdate_get_update_fulfill_htlcs(long this_ptr); // void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); public static native void CommitmentUpdate_set_update_fulfill_htlcs(long this_ptr, long[] val); + // struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + public static native long[] CommitmentUpdate_get_update_fail_htlcs(long this_ptr); // void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); public static native void CommitmentUpdate_set_update_fail_htlcs(long this_ptr, long[] val); + // struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + public static native long[] CommitmentUpdate_get_update_fail_malformed_htlcs(long this_ptr); // void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); public static native void CommitmentUpdate_set_update_fail_malformed_htlcs(long this_ptr, long[] val); // struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); @@ -3663,16 +3949,6 @@ public class bindings { public static native long CommitmentUpdate_new(long[] update_add_htlcs_arg, long[] update_fulfill_htlcs_arg, long[] update_fail_htlcs_arg, long[] update_fail_malformed_htlcs_arg, long update_fee_arg, long commitment_signed_arg); // struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); public static native long CommitmentUpdate_clone(long orig); - // void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); - public static native void HTLCFailChannelUpdate_free(long this_ptr); - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig); - public static native long HTLCFailChannelUpdate_clone(long orig); - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_update_message(struct LDKChannelUpdate msg); - public static native long HTLCFailChannelUpdate_channel_update_message(long msg); - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent); - public static native long HTLCFailChannelUpdate_channel_closed(long short_channel_id, boolean is_permanent); - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); - public static native long HTLCFailChannelUpdate_node_failure(byte[] node_id, boolean is_permanent); // void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); public static native void ChannelMessageHandler_free(long this_ptr); // void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); @@ -3789,24 +4065,26 @@ public class bindings { public static native long QueryShortChannelIds_read(byte[] ser); // struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); public static native byte[] QueryShortChannelIds_write(long obj); - // struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); - public static native long ReplyShortChannelIdsEnd_read(byte[] ser); // struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); public static native byte[] ReplyShortChannelIdsEnd_write(long obj); + // struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); + public static native long ReplyShortChannelIdsEnd_read(byte[] ser); // MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); public static native int QueryChannelRange_end_blocknum(long this_arg); - // struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); - public static native long QueryChannelRange_read(byte[] ser); // struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); public static native byte[] QueryChannelRange_write(long obj); + // struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); + public static native long QueryChannelRange_read(byte[] ser); // struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); public static native long ReplyChannelRange_read(byte[] ser); // struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); public static native byte[] ReplyChannelRange_write(long obj); - // struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); - public static native long GossipTimestampFilter_read(byte[] ser); // struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); public static native byte[] GossipTimestampFilter_write(long obj); + // struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); + public static native long GossipTimestampFilter_read(byte[] ser); + // void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); + public static native void CustomMessageHandler_free(long this_ptr); // void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); public static native void IgnoringMessageHandler_free(long this_obj); // MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); @@ -3815,6 +4093,10 @@ public class bindings { public static native long IgnoringMessageHandler_as_MessageSendEventsProvider(long this_arg); // struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); public static native long IgnoringMessageHandler_as_RoutingMessageHandler(long this_arg); + // struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + public static native long IgnoringMessageHandler_as_CustomMessageReader(long this_arg); + // struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + public static native long IgnoringMessageHandler_as_CustomMessageHandler(long this_arg); // void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); public static native void ErroringMessageHandler_free(long this_obj); // MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); @@ -3851,8 +4133,8 @@ public class bindings { public static native long PeerHandleError_clone(long orig); // void PeerManager_free(struct LDKPeerManager this_obj); public static native void PeerManager_free(long this_obj); - // MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger); - public static native long PeerManager_new(long message_handler, byte[] our_node_secret, byte[] ephemeral_random_data, long logger); + // MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler); + public static native long PeerManager_new(long message_handler, byte[] our_node_secret, byte[] ephemeral_random_data, long logger, long custom_message_handler); // MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); public static native byte[][] PeerManager_get_peer_node_ids(long this_arg); // MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor); @@ -3873,6 +4155,8 @@ public class bindings { public static native void PeerManager_timer_tick_occurred(long this_arg); // struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); public static native byte[] build_commitment_secret(byte[] commitment_seed, long idx); + // struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); + public static native byte[] build_closing_transaction(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, long funding_outpoint); // struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); public static native long derive_private_key(byte[] per_commitment_point, byte[] base_secret); // struct LDKCResult_PublicKeyErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); @@ -4087,6 +4371,30 @@ public class bindings { public static native byte[] BuiltCommitmentTransaction_get_sighash_all(long this_arg, byte[] funding_redeemscript, long channel_value_satoshis); // MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); public static native byte[] BuiltCommitmentTransaction_sign(long this_arg, byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis); + // void ClosingTransaction_free(struct LDKClosingTransaction this_obj); + public static native void ClosingTransaction_free(long this_obj); + // MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); + public static native long ClosingTransaction_new(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, long funding_outpoint); + // MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + public static native long ClosingTransaction_trust(long this_arg); + // MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); + public static native long ClosingTransaction_verify(long this_arg, long funding_outpoint); + // MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + public static native long ClosingTransaction_to_holder_value_sat(long this_arg); + // MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + public static native long ClosingTransaction_to_counterparty_value_sat(long this_arg); + // MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + public static native byte[] ClosingTransaction_to_holder_script(long this_arg); + // MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + public static native byte[] ClosingTransaction_to_counterparty_script(long this_arg); + // void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); + public static native void TrustedClosingTransaction_free(long this_obj); + // MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); + public static native byte[] TrustedClosingTransaction_built_transaction(long this_arg); + // MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + public static native byte[] TrustedClosingTransaction_get_sighash_all(long this_arg, byte[] funding_redeemscript, long channel_value_satoshis); + // MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + public static native byte[] TrustedClosingTransaction_sign(long this_arg, byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis); // void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); public static native void CommitmentTransaction_free(long this_obj); // struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); @@ -4147,18 +4455,26 @@ public class bindings { public static native long InitFeatures_empty(); // MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); public static native long InitFeatures_known(); + // MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); + public static native boolean InitFeatures_requires_unknown_bits(long this_arg); // MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); public static native long NodeFeatures_empty(); // MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); public static native long NodeFeatures_known(); + // MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); + public static native boolean NodeFeatures_requires_unknown_bits(long this_arg); // MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); public static native long ChannelFeatures_empty(); // MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); public static native long ChannelFeatures_known(); + // MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); + public static native boolean ChannelFeatures_requires_unknown_bits(long this_arg); // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); public static native long InvoiceFeatures_empty(); // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); public static native long InvoiceFeatures_known(); + // MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + public static native boolean InvoiceFeatures_requires_unknown_bits(long this_arg); // MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); public static native boolean InitFeatures_supports_payment_secret(long this_arg); // MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); @@ -4213,6 +4529,12 @@ public class bindings { public static native byte[] ShutdownScript_as_legacy_pubkey(long this_arg); // MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); public static native boolean ShutdownScript_is_compatible(long this_arg, long features); + // void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); + public static native void CustomMessageReader_free(long this_ptr); + // struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); + public static native long Type_clone(long orig); + // void Type_free(struct LDKType this_ptr); + public static native void Type_free(long this_ptr); // void RouteHop_free(struct LDKRouteHop this_obj); public static native void RouteHop_free(long this_obj); // struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); @@ -4243,28 +4565,44 @@ public class bindings { public static native long RouteHop_new(byte[] pubkey_arg, long node_features_arg, long short_channel_id_arg, long channel_features_arg, long fee_msat_arg, int cltv_expiry_delta_arg); // struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); public static native long RouteHop_clone(long orig); + // uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); + public static native long RouteHop_hash(long o); + // bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); + public static native boolean RouteHop_eq(long a, long b); // struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); public static native byte[] RouteHop_write(long obj); // struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); public static native long RouteHop_read(byte[] ser); // void Route_free(struct LDKRoute this_obj); public static native void Route_free(long this_obj); + // struct LDKCVec_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); + public static native long[][] Route_get_paths(long this_ptr); // void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); public static native void Route_set_paths(long this_ptr, long[][] val); // MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg); public static native long Route_new(long[][] paths_arg); // struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); public static native long Route_clone(long orig); + // uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); + public static native long Route_hash(long o); + // bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); + public static native boolean Route_eq(long a, long b); + // MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); + public static native long Route_get_total_fees(long this_arg); + // MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); + public static native long Route_get_total_amount(long this_arg); // struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); public static native byte[] Route_write(long obj); // struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); public static native long Route_read(byte[] ser); // void RouteHint_free(struct LDKRouteHint this_obj); public static native void RouteHint_free(long this_obj); - // bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); - public static native boolean RouteHint_eq(long a, long b); // struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); public static native long RouteHint_clone(long orig); + // uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); + public static native long RouteHint_hash(long o); + // bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); + public static native boolean RouteHint_eq(long a, long b); // void RouteHintHop_free(struct LDKRouteHintHop this_obj); public static native void RouteHintHop_free(long this_obj); // struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); @@ -4293,32 +4631,44 @@ public class bindings { public static native void RouteHintHop_set_htlc_maximum_msat(long this_ptr, long val); // MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); public static native long RouteHintHop_new(byte[] src_node_id_arg, long short_channel_id_arg, long fees_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg); - // bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); - public static native boolean RouteHintHop_eq(long a, long b); // struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); public static native long RouteHintHop_clone(long orig); + // uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); + public static native long RouteHintHop_hash(long o); + // bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); + public static native boolean RouteHintHop_eq(long a, long b); // struct LDKCResult_RouteLightningErrorZ get_keysend_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); public static native long get_keysend_route(byte[] our_node_id, long network, byte[] payee, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger); // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); public static native long get_route(byte[] our_node_id, long network, byte[] payee, long payee_features, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger); // void NetworkGraph_free(struct LDKNetworkGraph this_obj); public static native void NetworkGraph_free(long this_obj); - // struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); - public static native long NetworkGraph_clone(long orig); - // void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj); - public static native void LockedNetworkGraph_free(long this_obj); + // void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); + public static native void ReadOnlyNetworkGraph_free(long this_obj); + // void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); + public static native void NetworkUpdate_free(long this_ptr); + // struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); + public static native long NetworkUpdate_clone(long orig); + // struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); + public static native long NetworkUpdate_channel_update_message(long msg); + // struct LDKNetworkUpdate NetworkUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent); + public static native long NetworkUpdate_channel_closed(long short_channel_id, boolean is_permanent); + // struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); + public static native long NetworkUpdate_node_failure(byte[] node_id, boolean is_permanent); + // struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); + public static native byte[] NetworkUpdate_write(long obj); + // struct LDKEventHandler NetGraphMsgHandler_as_EventHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); + public static native long NetGraphMsgHandler_as_EventHandler(long this_arg); // void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); public static native void NetGraphMsgHandler_free(long this_obj); - // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger); - public static native long NetGraphMsgHandler_new(byte[] genesis_hash, long chain_access, long logger); - // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph); - public static native long NetGraphMsgHandler_from_net_graph(long chain_access, long logger, long network_graph); - // void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access); + // struct LDKNetworkGraph NetGraphMsgHandler_get_network_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr); + public static native long NetGraphMsgHandler_get_network_graph(long this_ptr); + // void NetGraphMsgHandler_set_network_graph(struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr, struct LDKNetworkGraph val); + public static native void NetGraphMsgHandler_set_network_graph(long this_ptr, long val); + // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKNetworkGraph network_graph, struct LDKCOption_AccessZ chain_access, struct LDKLogger logger); + public static native long NetGraphMsgHandler_new(long network_graph, long chain_access, long logger); + // void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKCOption_AccessZ chain_access); public static native void NetGraphMsgHandler_add_chain_access(long this_arg, long chain_access); - // MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); - public static native long NetGraphMsgHandler_read_locked_graph(long this_arg); - // MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg); - public static native long LockedNetworkGraph_graph(long this_arg); // struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); public static native long NetGraphMsgHandler_as_RoutingMessageHandler(long this_arg); // struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); @@ -4415,6 +4765,8 @@ public class bindings { public static native boolean RoutingFees_eq(long a, long b); // struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); public static native long RoutingFees_clone(long orig); + // uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); + public static native long RoutingFees_hash(long o); // struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); public static native byte[] RoutingFees_write(long obj); // struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); @@ -4477,19 +4829,23 @@ public class bindings { public static native long NetworkGraph_read(byte[] ser); // MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash); public static native long NetworkGraph_new(byte[] genesis_hash); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + // MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); + public static native long NetworkGraph_read_only(long this_arg); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); public static native long NetworkGraph_update_node_from_announcement(long this_arg, long msg); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); public static native long NetworkGraph_update_node_from_unsigned_announcement(long this_arg, long msg); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_AccessZ chain_access); public static native long NetworkGraph_update_channel_from_announcement(long this_arg, long msg, long chain_access); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_AccessZ chain_access); public static native long NetworkGraph_update_channel_from_unsigned_announcement(long this_arg, long msg, long chain_access); - // void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); + // void NetworkGraph_close_channel_from_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); public static native void NetworkGraph_close_channel_from_update(long this_arg, long short_channel_id, boolean is_permanent); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + // void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent); + public static native void NetworkGraph_fail_node(long this_arg, byte[] _node_id, boolean is_permanent); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); public static native long NetworkGraph_update_channel(long this_arg, long msg); - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); public static native long NetworkGraph_update_channel_unsigned(long this_arg, long msg); // void FilesystemPersister_free(struct LDKFilesystemPersister this_obj); public static native void FilesystemPersister_free(long this_obj); @@ -4507,8 +4863,8 @@ public class bindings { public static native void BackgroundProcessor_free(long this_obj); // void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr); public static native void ChannelManagerPersister_free(long this_ptr); - // MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); - public static native long BackgroundProcessor_start(long persister, long event_handler, long chain_monitor, long channel_manager, long peer_manager, long logger); + // MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); + public static native long BackgroundProcessor_start(long persister, long event_handler, long chain_monitor, long channel_manager, long net_graph_msg_handler, long peer_manager, long logger); // MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg); public static native long BackgroundProcessor_join(long this_arg); // MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); @@ -4579,38 +4935,50 @@ public class bindings { public static native Currency Currency_simnet(); // enum LDKCurrency Currency_signet(void); public static native Currency Currency_signet(); + // uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o); + public static native long Currency_hash(long o); // bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *NONNULL_PTR b); public static native boolean Currency_eq(long a, long b); // void Sha256_free(struct LDKSha256 this_obj); public static native void Sha256_free(long this_obj); - // bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); - public static native boolean Sha256_eq(long a, long b); // struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); public static native long Sha256_clone(long orig); + // uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); + public static native long Sha256_hash(long o); + // bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); + public static native boolean Sha256_eq(long a, long b); // void Description_free(struct LDKDescription this_obj); public static native void Description_free(long this_obj); - // bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); - public static native boolean Description_eq(long a, long b); // struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); public static native long Description_clone(long orig); + // uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o); + public static native long Description_hash(long o); + // bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); + public static native boolean Description_eq(long a, long b); // void PayeePubKey_free(struct LDKPayeePubKey this_obj); public static native void PayeePubKey_free(long this_obj); - // bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); - public static native boolean PayeePubKey_eq(long a, long b); // struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); public static native long PayeePubKey_clone(long orig); + // uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o); + public static native long PayeePubKey_hash(long o); + // bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); + public static native boolean PayeePubKey_eq(long a, long b); // void ExpiryTime_free(struct LDKExpiryTime this_obj); public static native void ExpiryTime_free(long this_obj); - // bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); - public static native boolean ExpiryTime_eq(long a, long b); // struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); public static native long ExpiryTime_clone(long orig); + // uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o); + public static native long ExpiryTime_hash(long o); + // bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); + public static native boolean ExpiryTime_eq(long a, long b); // void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj); public static native void MinFinalCltvExpiry_free(long this_obj); - // bool MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b); - public static native boolean MinFinalCltvExpiry_eq(long a, long b); // struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig); public static native long MinFinalCltvExpiry_clone(long orig); + // uint64_t MinFinalCltvExpiry_hash(const struct LDKMinFinalCltvExpiry *NONNULL_PTR o); + public static native long MinFinalCltvExpiry_hash(long o); + // bool MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b); + public static native boolean MinFinalCltvExpiry_eq(long a, long b); // void Fallback_free(struct LDKFallback this_ptr); public static native void Fallback_free(long this_ptr); // struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig); @@ -4621,20 +4989,24 @@ public class bindings { public static native long Fallback_pub_key_hash(byte[] a); // struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a); public static native long Fallback_script_hash(byte[] a); + // uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); + public static native long Fallback_hash(long o); // bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b); public static native boolean Fallback_eq(long a, long b); // void InvoiceSignature_free(struct LDKInvoiceSignature this_obj); public static native void InvoiceSignature_free(long this_obj); - // bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b); - public static native boolean InvoiceSignature_eq(long a, long b); // struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); public static native long InvoiceSignature_clone(long orig); + // bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b); + public static native boolean InvoiceSignature_eq(long a, long b); // void PrivateRoute_free(struct LDKPrivateRoute this_obj); public static native void PrivateRoute_free(long this_obj); - // bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); - public static native boolean PrivateRoute_eq(long a, long b); // struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); public static native long PrivateRoute_clone(long orig); + // uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); + public static native long PrivateRoute_hash(long o); + // bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); + public static native boolean PrivateRoute_eq(long a, long b); // MUST_USE_RES struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ SignedRawInvoice_into_parts(struct LDKSignedRawInvoice this_arg); public static native long SignedRawInvoice_into_parts(long this_arg); // MUST_USE_RES struct LDKRawInvoice SignedRawInvoice_raw_invoice(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); @@ -4749,6 +5121,8 @@ public class bindings { public static native SemanticError SemanticError_no_description(); // enum LDKSemanticError SemanticError_multiple_descriptions(void); public static native SemanticError SemanticError_multiple_descriptions(); + // enum LDKSemanticError SemanticError_no_payment_secret(void); + public static native SemanticError SemanticError_no_payment_secret(); // enum LDKSemanticError SemanticError_multiple_payment_secrets(void); public static native SemanticError SemanticError_multiple_payment_secrets(); // enum LDKSemanticError SemanticError_invalid_features(void); @@ -4757,6 +5131,8 @@ public class bindings { public static native SemanticError SemanticError_invalid_recovery_id(); // enum LDKSemanticError SemanticError_invalid_signature(void); public static native SemanticError SemanticError_invalid_signature(); + // enum LDKSemanticError SemanticError_imprecise_amount(void); + public static native SemanticError SemanticError_imprecise_amount(); // bool SemanticError_eq(const enum LDKSemanticError *NONNULL_PTR a, const enum LDKSemanticError *NONNULL_PTR b); public static native boolean SemanticError_eq(long a, long b); // struct LDKStr SemanticError_to_str(const enum LDKSemanticError *NONNULL_PTR o); diff --git a/src/main/java/org/ldk/structs/BackgroundProcessor.java b/src/main/java/org/ldk/structs/BackgroundProcessor.java index e6ff4511..0333f93d 100644 --- a/src/main/java/org/ldk/structs/BackgroundProcessor.java +++ b/src/main/java/org/ldk/structs/BackgroundProcessor.java @@ -8,20 +8,28 @@ import javax.annotation.Nullable; /** - * BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep + * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep * Rust-Lightning running properly, and (2) either can or should be run in the background. Its * responsibilities are: - * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so, + * Processing [`Event`]s with a user-provided [`EventHandler`]. + * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, * writing it to disk/backups by invoking the callback given to it at startup. - * ChannelManager persistence should be done in the background. - * Calling `ChannelManager::timer_tick_occurred()` and - * `PeerManager::timer_tick_occurred()` every minute (can be done in the - * background). + * [`ChannelManager`] persistence should be done in the background. + * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] + * at the appropriate intervals. * - * Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date, - * then there is a risk of channels force-closing on startup when the manager realizes it's - * outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used - * for unilateral chain closure fees are at risk. + * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied + * upon as doing so may result in high latency. + * + * # Note + * + * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then + * there is a risk of channels force-closing on startup when the manager realizes it's outdated. + * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for + * unilateral chain closure fees are at risk. + * + * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor + * [`Event`]: lightning::util::events::Event * BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays @@ -41,24 +49,36 @@ public class BackgroundProcessor extends CommonBase { * `persist_manager` returns an error. In case of an error, the error is retrieved by calling * either [`join`] or [`stop`]. * - * Typically, users should either implement [`ChannelManagerPersister`] to never return an - * error or call [`join`] and handle any error that may arise. For the latter case, the - * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. + * # Data Persistence * * `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a * [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's * provided implementation. * + * Typically, users should either implement [`ChannelManagerPersister`] to never return an + * error or call [`join`] and handle any error that may arise. For the latter case, + * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. + * + * # Event Handling + * + * `event_handler` is responsible for handling events that users should be notified of (e.g., + * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common + * functionality implemented by other handlers. + * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures. + * * [top-level documentation]: Self * [`join`]: Self::join * [`stop`]: Self::stop * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable * [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager + * [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph + * + * Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public static BackgroundProcessor start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, PeerManager peer_manager, Logger logger) { - long ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr); + public static BackgroundProcessor start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, NetGraphMsgHandler net_graph_msg_handler, PeerManager peer_manager, Logger logger) { + long ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, net_graph_msg_handler == null ? 0 : net_graph_msg_handler.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr); if (ret < 1024) { return null; } BackgroundProcessor ret_hu_conv = new BackgroundProcessor(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); @@ -66,6 +86,7 @@ public class BackgroundProcessor extends CommonBase { ret_hu_conv.ptrs_to.add(event_handler); ret_hu_conv.ptrs_to.add(chain_monitor); ret_hu_conv.ptrs_to.add(channel_manager); + ret_hu_conv.ptrs_to.add(net_graph_msg_handler); ret_hu_conv.ptrs_to.add(peer_manager); ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; diff --git a/src/main/java/org/ldk/structs/Balance.java b/src/main/java/org/ldk/structs/Balance.java new file mode 100644 index 00000000..fb2e5f47 --- /dev/null +++ b/src/main/java/org/ldk/structs/Balance.java @@ -0,0 +1,168 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * Details about the balance(s) available for spending once the channel appears on chain. + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not + * be provided. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Balance extends CommonBase { + private Balance(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.Balance_free(ptr); } + } + static Balance constr_from_ptr(long ptr) { + bindings.LDKBalance raw_val = bindings.LDKBalance_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKBalance.ClaimableOnChannelClose.class) { + return new ClaimableOnChannelClose(ptr, (bindings.LDKBalance.ClaimableOnChannelClose)raw_val); + } + if (raw_val.getClass() == bindings.LDKBalance.ClaimableAwaitingConfirmations.class) { + return new ClaimableAwaitingConfirmations(ptr, (bindings.LDKBalance.ClaimableAwaitingConfirmations)raw_val); + } + if (raw_val.getClass() == bindings.LDKBalance.ContentiousClaimable.class) { + return new ContentiousClaimable(ptr, (bindings.LDKBalance.ContentiousClaimable)raw_val); + } + if (raw_val.getClass() == bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout.class) { + return new MaybeClaimableHTLCAwaitingTimeout(ptr, (bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class ClaimableOnChannelClose extends Balance { + /** + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. + */ + public final long claimable_amount_satoshis; + private ClaimableOnChannelClose(long ptr, bindings.LDKBalance.ClaimableOnChannelClose obj) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + } + } + public final static class ClaimableAwaitingConfirmations extends Balance { + /** + * The amount available to claim, in satoshis, possibly excluding the on-chain fees which + * were spent in broadcasting the transaction. + */ + public final long claimable_amount_satoshis; + /** + * The height at which an [`Event::SpendableOutputs`] event will be generated for this + * amount. + */ + public final int confirmation_height; + private ClaimableAwaitingConfirmations(long ptr, bindings.LDKBalance.ClaimableAwaitingConfirmations obj) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.confirmation_height = obj.confirmation_height; + } + } + public final static class ContentiousClaimable extends Balance { + /** + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. + */ + public final long claimable_amount_satoshis; + /** + * The height at which the counterparty may be able to claim the balance if we have not + * done so. + */ + public final int timeout_height; + private ContentiousClaimable(long ptr, bindings.LDKBalance.ContentiousClaimable obj) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.timeout_height = obj.timeout_height; + } + } + public final static class MaybeClaimableHTLCAwaitingTimeout extends Balance { + /** + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. + */ + public final long claimable_amount_satoshis; + /** + * The height at which we will be able to claim the balance if our counterparty has not + * done so. + */ + public final int claimable_height; + private MaybeClaimableHTLCAwaitingTimeout(long ptr, bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout obj) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.claimable_height = obj.claimable_height; + } + } + /** + * Creates a copy of the Balance + */ + public Balance clone() { + long ret = bindings.Balance_clone(this.ptr); + if (ret < 1024) { return null; } + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ClaimableOnChannelClose-variant Balance + */ + public static Balance claimable_on_channel_close(long claimable_amount_satoshis) { + long ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis); + if (ret < 1024) { return null; } + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance + */ + public static Balance claimable_awaiting_confirmations(long claimable_amount_satoshis, int confirmation_height) { + long ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + if (ret < 1024) { return null; } + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ContentiousClaimable-variant Balance + */ + public static Balance contentious_claimable(long claimable_amount_satoshis, int timeout_height) { + long ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + if (ret < 1024) { return null; } + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance + */ + public static Balance maybe_claimable_htlcawaiting_timeout(long claimable_amount_satoshis, int claimable_height) { + long ret = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + if (ret < 1024) { return null; } + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Checks if two Balances contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ + public boolean eq(Balance b) { + boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + +} diff --git a/src/main/java/org/ldk/structs/BaseSign.java b/src/main/java/org/ldk/structs/BaseSign.java index 71a146ef..8d44de66 100644 --- a/src/main/java/org/ldk/structs/BaseSign.java +++ b/src/main/java/org/ldk/structs/BaseSign.java @@ -58,6 +58,15 @@ public class BaseSign extends CommonBase { * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ byte[] release_commitment_secret(long idx); + /** + * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + * + * This is required in order for the signer to make sure that releasing a commitment + * secret won't leave us without a broadcastable holder transaction. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + */ + Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx); /** * Gets an arbitrary identifier describing the set of keys which are provided back to you in * some SpendableOutputDescriptor types. This should be sufficient to identify this @@ -68,8 +77,18 @@ public class BaseSign extends CommonBase { * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. * * Note that if signing fails or is rejected, the channel will be force-closed. + * + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. */ Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx); + /** + * Validate the counterparty's revocation. + * + * This is required in order for the signer to make sure that the state has moved + * forward and it is safe to sign the next counterparty commitment. + */ + Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret); /** * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. * This will only ever be called with a non-revoked commitment_tx. This will be called with the @@ -147,7 +166,7 @@ public class BaseSign extends CommonBase { * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have * chosen to forgo their output as dust. */ - Result_SignatureNoneZ sign_closing_transaction(byte[] closing_tx); + Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx); /** * Signs a channel announcement message with our funding key, proving it comes from one * of the channel participants. @@ -183,6 +202,12 @@ public class BaseSign extends CommonBase { byte[] ret = arg.release_commitment_secret(idx); return ret; } + @Override public long validate_holder_commitment(long holder_tx) { + HolderCommitmentTransaction holder_tx_hu_conv = new HolderCommitmentTransaction(null, holder_tx); + Result_NoneNoneZ ret = arg.validate_holder_commitment(holder_tx_hu_conv); + long result = ret != null ? ret.ptr : 0; + return result; + } @Override public byte[] channel_keys_id() { byte[] ret = arg.channel_keys_id(); return ret; @@ -193,6 +218,11 @@ public class BaseSign extends CommonBase { long result = ret != null ? ret.ptr : 0; return result; } + @Override public long validate_counterparty_revocation(long idx, byte[] secret) { + Result_NoneNoneZ ret = arg.validate_counterparty_revocation(idx, secret); + long result = ret != null ? ret.ptr : 0; + return result; + } @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) { HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv); @@ -216,8 +246,9 @@ public class BaseSign extends CommonBase { long result = ret != null ? ret.ptr : 0; return result; } - @Override public long sign_closing_transaction(byte[] closing_tx) { - Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx); + @Override public long sign_closing_transaction(long closing_tx) { + ClosingTransaction closing_tx_hu_conv = new ClosingTransaction(null, closing_tx); + Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv); long result = ret != null ? ret.ptr : 0; return result; } @@ -259,6 +290,22 @@ public class BaseSign extends CommonBase { return ret; } + /** + * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + * + * This is required in order for the signer to make sure that releasing a commitment + * secret won't leave us without a broadcastable holder transaction. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + */ + public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx) { + long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr & ~1); + if (ret < 1024) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(holder_tx); + return ret_hu_conv; + } + /** * Gets an arbitrary identifier describing the set of keys which are provided back to you in * some SpendableOutputDescriptor types. This should be sufficient to identify this @@ -273,6 +320,9 @@ public class BaseSign extends CommonBase { * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. * * Note that if signing fails or is rejected, the channel will be force-closed. + * + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. */ public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx) { long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1); @@ -282,6 +332,19 @@ public class BaseSign extends CommonBase { return ret_hu_conv; } + /** + * Validate the counterparty's revocation. + * + * This is required in order for the signer to make sure that the state has moved + * forward and it is safe to sign the next counterparty commitment. + */ + public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) { + long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, secret); + if (ret < 1024) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. * This will only ever be called with a non-revoked commitment_tx. This will be called with the @@ -386,10 +449,11 @@ public class BaseSign extends CommonBase { * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have * chosen to forgo their output as dust. */ - public Result_SignatureNoneZ sign_closing_transaction(byte[] closing_tx) { - long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx); + public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) { + long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr & ~1); if (ret < 1024) { return null; } Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(closing_tx); return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/ChainMonitor.java b/src/main/java/org/ldk/structs/ChainMonitor.java index bed77516..1ed9337d 100644 --- a/src/main/java/org/ldk/structs/ChainMonitor.java +++ b/src/main/java/org/ldk/structs/ChainMonitor.java @@ -35,15 +35,12 @@ public class ChainMonitor extends CommonBase { * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may * always need to fetch full blocks absent another means for determining which blocks contain * transactions relevant to the watched channels. - * - * Note that chain_source (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public static ChainMonitor of(@Nullable Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) { - long ret = bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr); + public static ChainMonitor of(Option_FilterZ chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) { + long ret = bindings.ChainMonitor_new(chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr); if (ret < 1024) { return null; } ChainMonitor ret_hu_conv = new ChainMonitor(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_source); ret_hu_conv.ptrs_to.add(broadcaster); ret_hu_conv.ptrs_to.add(logger); ret_hu_conv.ptrs_to.add(feeest); @@ -51,6 +48,30 @@ public class ChainMonitor extends CommonBase { return ret_hu_conv; } + /** + * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or + * claims which are awaiting confirmation. + * + * Includes the balances from each [`ChannelMonitor`] *except* those included in + * `ignored_channels`, allowing you to filter out balances from channels which are still open + * (and whose balance should likely be pulled from the [`ChannelDetails`]). + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for + * inclusion in the return value. + */ + public Balance[] get_claimable_balances(ChannelDetails[] ignored_channels) { + long[] ret = bindings.ChainMonitor_get_claimable_balances(this.ptr, ignored_channels != null ? Arrays.stream(ignored_channels).mapToLong(ignored_channels_conv_16 -> ignored_channels_conv_16 == null ? 0 : ignored_channels_conv_16.ptr & ~1).toArray() : null); + Balance[] ret_conv_9_arr = new Balance[ret.length]; + for (int j = 0; j < ret.length; j++) { + long ret_conv_9 = ret[j]; + Balance ret_conv_9_hu_conv = Balance.constr_from_ptr(ret_conv_9); + ret_conv_9_hu_conv.ptrs_to.add(this); + ret_conv_9_arr[j] = ret_conv_9_hu_conv; + } + for (ChannelDetails ignored_channels_conv_16: ignored_channels) { this.ptrs_to.add(ignored_channels_conv_16); }; + return ret_conv_9_arr; + } + /** * Constructs a new Listen which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is diff --git a/src/main/java/org/ldk/structs/ChannelCounterparty.java b/src/main/java/org/ldk/structs/ChannelCounterparty.java index 535c6a0a..afbf4478 100644 --- a/src/main/java/org/ldk/structs/ChannelCounterparty.java +++ b/src/main/java/org/ldk/structs/ChannelCounterparty.java @@ -85,6 +85,45 @@ public class ChannelCounterparty extends CommonBase { bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val); } + /** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public CounterpartyForwardingInfo get_forwarding_info() { + long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr); + if (ret < 1024) { return null; } + CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void set_forwarding_info(@Nullable CounterpartyForwardingInfo val) { + bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + + /** + * Constructs a new ChannelCounterparty given each field + */ + public static ChannelCounterparty of(byte[] node_id_arg, InitFeatures features_arg, long unspendable_punishment_reserve_arg, CounterpartyForwardingInfo forwarding_info_arg) { + long ret = bindings.ChannelCounterparty_new(node_id_arg, features_arg == null ? 0 : features_arg.ptr & ~1, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr & ~1); + if (ret < 1024) { return null; } + ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(features_arg); + ret_hu_conv.ptrs_to.add(forwarding_info_arg); + return ret_hu_conv; + } + /** * Creates a copy of the ChannelCounterparty */ diff --git a/src/main/java/org/ldk/structs/ChannelFeatures.java b/src/main/java/org/ldk/structs/ChannelFeatures.java index c0e61d0a..95f2863f 100644 --- a/src/main/java/org/ldk/structs/ChannelFeatures.java +++ b/src/main/java/org/ldk/structs/ChannelFeatures.java @@ -63,6 +63,15 @@ public class ChannelFeatures extends CommonBase { return ret_hu_conv; } + /** + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". + */ + public boolean requires_unknown_bits() { + boolean ret = bindings.ChannelFeatures_requires_unknown_bits(this.ptr); + return ret; + } + /** * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index d8c9065a..6f5e447e 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -360,7 +360,6 @@ public class ChannelManager extends CommonBase { */ public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) { bindings.ChannelManager_broadcast_node_announcement(this.ptr, rgb, alias, addresses != null ? Arrays.stream(addresses).mapToLong(addresses_conv_12 -> addresses_conv_12.ptr).toArray() : null); - /* TODO 2 NetAddress */; } /** diff --git a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java index 5669175e..291deffb 100644 --- a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java +++ b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java @@ -197,7 +197,7 @@ public class ChannelManagerReadArgs extends CommonBase { ret_hu_conv.ptrs_to.add(tx_broadcaster); ret_hu_conv.ptrs_to.add(logger); ret_hu_conv.ptrs_to.add(default_config); - /* TODO 2 ChannelMonitor */; + for (ChannelMonitor channel_monitors_conv_16: channel_monitors) { ret_hu_conv.ptrs_to.add(channel_monitors_conv_16); }; return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/ChannelMonitor.java b/src/main/java/org/ldk/structs/ChannelMonitor.java index 75d8140b..df8456c3 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitor.java +++ b/src/main/java/org/ldk/structs/ChannelMonitor.java @@ -223,7 +223,6 @@ public class ChannelMonitor extends CommonBase { // Warning: We may not free the C tuple object! ret_conv_46_arr[u] = ret_conv_46_conv; } - /* TODO 2 TwoTuple */; this.ptrs_to.add(broadcaster); this.ptrs_to.add(fee_estimator); this.ptrs_to.add(logger); @@ -273,7 +272,6 @@ public class ChannelMonitor extends CommonBase { // Warning: We may not free the C tuple object! ret_conv_46_arr[u] = ret_conv_46_conv; } - /* TODO 2 TwoTuple */; this.ptrs_to.add(broadcaster); this.ptrs_to.add(fee_estimator); this.ptrs_to.add(logger); @@ -353,4 +351,32 @@ public class ChannelMonitor extends CommonBase { return ret_hu_conv; } + /** + * Gets the balances in this channel which are either claimable by us if we were to + * force-close the channel now or which are claimable on-chain (possibly awaiting + * confirmation). + * + * Any balances in the channel which are available on-chain (excluding on-chain fees) are + * included here until an [`Event::SpendableOutputs`] event has been generated for the + * balance, or until our counterparty has claimed the balance and accrued several + * confirmations on the claim transaction. + * + * Note that the balances available when you or your counterparty have broadcasted revoked + * state(s) may not be fully captured here. + * + * See [`Balance`] for additional details on the types of claimable balances which + * may be returned here and their meanings. + */ + public Balance[] get_claimable_balances() { + long[] ret = bindings.ChannelMonitor_get_claimable_balances(this.ptr); + Balance[] ret_conv_9_arr = new Balance[ret.length]; + for (int j = 0; j < ret.length; j++) { + long ret_conv_9 = ret[j]; + Balance ret_conv_9_hu_conv = Balance.constr_from_ptr(ret_conv_9); + ret_conv_9_hu_conv.ptrs_to.add(this); + ret_conv_9_arr[j] = ret_conv_9_hu_conv; + } + return ret_conv_9_arr; + } + } diff --git a/src/main/java/org/ldk/structs/ClosingTransaction.java b/src/main/java/org/ldk/structs/ClosingTransaction.java new file mode 100644 index 00000000..e7b95c2b --- /dev/null +++ b/src/main/java/org/ldk/structs/ClosingTransaction.java @@ -0,0 +1,102 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * This class tracks the per-transaction information needed to build a closing transaction and will + * actually build it and sign. + * + * This class can be used inside a signer implementation to generate a signature given the relevant + * secret key. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class ClosingTransaction extends CommonBase { + ClosingTransaction(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.ClosingTransaction_free(ptr); } + } + + /** + * Construct an object of the class + */ + public static ClosingTransaction of(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, OutPoint funding_outpoint) { + long ret = bindings.ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1); + if (ret < 1024) { return null; } + ClosingTransaction ret_hu_conv = new ClosingTransaction(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(funding_outpoint); + return ret_hu_conv; + } + + /** + * Trust our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. + */ + public TrustedClosingTransaction trust() { + long ret = bindings.ClosingTransaction_trust(this.ptr); + if (ret < 1024) { return null; } + TrustedClosingTransaction ret_hu_conv = new TrustedClosingTransaction(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Verify our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * An external validating signer must call this method before signing + * or using the built transaction. + */ + public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) { + long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1); + if (ret < 1024) { return null; } + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(funding_outpoint); + return ret_hu_conv; + } + + /** + * The value to be sent to the holder, or zero if the output will be omitted + */ + public long to_holder_value_sat() { + long ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr); + return ret; + } + + /** + * The value to be sent to the counterparty, or zero if the output will be omitted + */ + public long to_counterparty_value_sat() { + long ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr); + return ret; + } + + /** + * The destination of the holder's output + */ + public byte[] to_holder_script() { + byte[] ret = bindings.ClosingTransaction_to_holder_script(this.ptr); + return ret; + } + + /** + * The destination of the counterparty's output + */ + public byte[] to_counterparty_script() { + byte[] ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr); + return ret; + } + +} diff --git a/src/main/java/org/ldk/structs/ClosureReason.java b/src/main/java/org/ldk/structs/ClosureReason.java new file mode 100644 index 00000000..495f5ab2 --- /dev/null +++ b/src/main/java/org/ldk/structs/ClosureReason.java @@ -0,0 +1,192 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * The reason the channel was closed. See individual variants more details. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class ClosureReason extends CommonBase { + private ClosureReason(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.ClosureReason_free(ptr); } + } + static ClosureReason constr_from_ptr(long ptr) { + bindings.LDKClosureReason raw_val = bindings.LDKClosureReason_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKClosureReason.CounterpartyForceClosed.class) { + return new CounterpartyForceClosed(ptr, (bindings.LDKClosureReason.CounterpartyForceClosed)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.HolderForceClosed.class) { + return new HolderForceClosed(ptr, (bindings.LDKClosureReason.HolderForceClosed)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.CooperativeClosure.class) { + return new CooperativeClosure(ptr, (bindings.LDKClosureReason.CooperativeClosure)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.CommitmentTxConfirmed.class) { + return new CommitmentTxConfirmed(ptr, (bindings.LDKClosureReason.CommitmentTxConfirmed)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.ProcessingError.class) { + return new ProcessingError(ptr, (bindings.LDKClosureReason.ProcessingError)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.DisconnectedPeer.class) { + return new DisconnectedPeer(ptr, (bindings.LDKClosureReason.DisconnectedPeer)raw_val); + } + if (raw_val.getClass() == bindings.LDKClosureReason.OutdatedChannelManager.class) { + return new OutdatedChannelManager(ptr, (bindings.LDKClosureReason.OutdatedChannelManager)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class CounterpartyForceClosed extends ClosureReason { + /** + * The error which the peer sent us. + * + * The string should be sanitized before it is used (e.g emitted to logs + * or printed to stdout). Otherwise, a well crafted error message may exploit + * a security vulnerability in the terminal emulator or the logging subsystem. + */ + public final String peer_msg; + private CounterpartyForceClosed(long ptr, bindings.LDKClosureReason.CounterpartyForceClosed obj) { + super(null, ptr); + this.peer_msg = obj.peer_msg; + } + } + public final static class HolderForceClosed extends ClosureReason { + private HolderForceClosed(long ptr, bindings.LDKClosureReason.HolderForceClosed obj) { + super(null, ptr); + } + } + public final static class CooperativeClosure extends ClosureReason { + private CooperativeClosure(long ptr, bindings.LDKClosureReason.CooperativeClosure obj) { + super(null, ptr); + } + } + public final static class CommitmentTxConfirmed extends ClosureReason { + private CommitmentTxConfirmed(long ptr, bindings.LDKClosureReason.CommitmentTxConfirmed obj) { + super(null, ptr); + } + } + public final static class ProcessingError extends ClosureReason { + /** + * A developer-readable error message which we generated. + */ + public final String err; + private ProcessingError(long ptr, bindings.LDKClosureReason.ProcessingError obj) { + super(null, ptr); + this.err = obj.err; + } + } + public final static class DisconnectedPeer extends ClosureReason { + private DisconnectedPeer(long ptr, bindings.LDKClosureReason.DisconnectedPeer obj) { + super(null, ptr); + } + } + public final static class OutdatedChannelManager extends ClosureReason { + private OutdatedChannelManager(long ptr, bindings.LDKClosureReason.OutdatedChannelManager obj) { + super(null, ptr); + } + } + /** + * Creates a copy of the ClosureReason + */ + public ClosureReason clone() { + long ret = bindings.ClosureReason_clone(this.ptr); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + */ + public static ClosureReason counterparty_force_closed(java.lang.String peer_msg) { + long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new HolderForceClosed-variant ClosureReason + */ + public static ClosureReason holder_force_closed() { + long ret = bindings.ClosureReason_holder_force_closed(); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new CooperativeClosure-variant ClosureReason + */ + public static ClosureReason cooperative_closure() { + long ret = bindings.ClosureReason_cooperative_closure(); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + */ + public static ClosureReason commitment_tx_confirmed() { + long ret = bindings.ClosureReason_commitment_tx_confirmed(); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ProcessingError-variant ClosureReason + */ + public static ClosureReason processing_error(java.lang.String err) { + long ret = bindings.ClosureReason_processing_error(err); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + */ + public static ClosureReason disconnected_peer() { + long ret = bindings.ClosureReason_disconnected_peer(); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + */ + public static ClosureReason outdated_channel_manager() { + long ret = bindings.ClosureReason_outdated_channel_manager(); + if (ret < 1024) { return null; } + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + */ + public byte[] write() { + byte[] ret = bindings.ClosureReason_write(this.ptr); + return ret; + } + +} diff --git a/src/main/java/org/ldk/structs/CommitmentTransaction.java b/src/main/java/org/ldk/structs/CommitmentTransaction.java index ceb8a799..fb6b54e5 100644 --- a/src/main/java/org/ldk/structs/CommitmentTransaction.java +++ b/src/main/java/org/ldk/structs/CommitmentTransaction.java @@ -8,7 +8,7 @@ import javax.annotation.Nullable; /** - * This class tracks the per-transaction information needed to build a commitment transaction and to + * This class tracks the per-transaction information needed to build a commitment transaction and will * actually build it and sign. It is used for holder transactions that we sign only when needed * and for transactions we sign for the counterparty. * @@ -91,7 +91,7 @@ public class CommitmentTransaction extends CommonBase { * Applies a wrapper which allows access to these fields. * * This should only be used if you fully trust the builder of this object. It should not - * \tbe used by an external signer - instead use the verify function. + * be used by an external signer - instead use the verify function. */ public TrustedCommitmentTransaction trust() { long ret = bindings.CommitmentTransaction_trust(this.ptr); diff --git a/src/main/java/org/ldk/structs/CommitmentUpdate.java b/src/main/java/org/ldk/structs/CommitmentUpdate.java index e59e98a9..049a26c7 100644 --- a/src/main/java/org/ldk/structs/CommitmentUpdate.java +++ b/src/main/java/org/ldk/structs/CommitmentUpdate.java @@ -20,12 +20,42 @@ public class CommitmentUpdate extends CommonBase { if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); } } + /** + * update_add_htlc messages which should be sent + */ + public UpdateAddHTLC[] get_update_add_htlcs() { + long[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr); + UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret.length]; + for (int p = 0; p < ret.length; p++) { + long ret_conv_15 = ret[p]; + UpdateAddHTLC ret_conv_15_hu_conv = new UpdateAddHTLC(null, ret_conv_15); + ret_conv_15_hu_conv.ptrs_to.add(this); + ret_conv_15_arr[p] = ret_conv_15_hu_conv; + } + return ret_conv_15_arr; + } + /** * update_add_htlc messages which should be sent */ public void set_update_add_htlcs(UpdateAddHTLC[] val) { bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray() : null); - /* TODO 2 UpdateAddHTLC */; + for (UpdateAddHTLC val_conv_15: val) { this.ptrs_to.add(val_conv_15); }; + } + + /** + * update_fulfill_htlc messages which should be sent + */ + public UpdateFulfillHTLC[] get_update_fulfill_htlcs() { + long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr); + UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret.length]; + for (int t = 0; t < ret.length; t++) { + long ret_conv_19 = ret[t]; + UpdateFulfillHTLC ret_conv_19_hu_conv = new UpdateFulfillHTLC(null, ret_conv_19); + ret_conv_19_hu_conv.ptrs_to.add(this); + ret_conv_19_arr[t] = ret_conv_19_hu_conv; + } + return ret_conv_19_arr; } /** @@ -33,7 +63,22 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) { bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_19 -> val_conv_19 == null ? 0 : val_conv_19.ptr & ~1).toArray() : null); - /* TODO 2 UpdateFulfillHTLC */; + for (UpdateFulfillHTLC val_conv_19: val) { this.ptrs_to.add(val_conv_19); }; + } + + /** + * update_fail_htlc messages which should be sent + */ + public UpdateFailHTLC[] get_update_fail_htlcs() { + long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr); + UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret.length]; + for (int q = 0; q < ret.length; q++) { + long ret_conv_16 = ret[q]; + UpdateFailHTLC ret_conv_16_hu_conv = new UpdateFailHTLC(null, ret_conv_16); + ret_conv_16_hu_conv.ptrs_to.add(this); + ret_conv_16_arr[q] = ret_conv_16_hu_conv; + } + return ret_conv_16_arr; } /** @@ -41,7 +86,22 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fail_htlcs(UpdateFailHTLC[] val) { bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16 == null ? 0 : val_conv_16.ptr & ~1).toArray() : null); - /* TODO 2 UpdateFailHTLC */; + for (UpdateFailHTLC val_conv_16: val) { this.ptrs_to.add(val_conv_16); }; + } + + /** + * update_fail_malformed_htlc messages which should be sent + */ + public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() { + long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr); + UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret.length]; + for (int z = 0; z < ret.length; z++) { + long ret_conv_25 = ret[z]; + UpdateFailMalformedHTLC ret_conv_25_hu_conv = new UpdateFailMalformedHTLC(null, ret_conv_25); + ret_conv_25_hu_conv.ptrs_to.add(this); + ret_conv_25_arr[z] = ret_conv_25_hu_conv; + } + return ret_conv_25_arr; } /** @@ -49,7 +109,7 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) { bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_25 -> val_conv_25 == null ? 0 : val_conv_25.ptr & ~1).toArray() : null); - /* TODO 2 UpdateFailMalformedHTLC */; + for (UpdateFailMalformedHTLC val_conv_25: val) { this.ptrs_to.add(val_conv_25); }; } /** @@ -103,10 +163,10 @@ public class CommitmentUpdate extends CommonBase { if (ret < 1024) { return null; } CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 UpdateAddHTLC */; - /* TODO 2 UpdateFulfillHTLC */; - /* TODO 2 UpdateFailHTLC */; - /* TODO 2 UpdateFailMalformedHTLC */; + for (UpdateAddHTLC update_add_htlcs_arg_conv_15: update_add_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_add_htlcs_arg_conv_15); }; + for (UpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19: update_fulfill_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fulfill_htlcs_arg_conv_19); }; + for (UpdateFailHTLC update_fail_htlcs_arg_conv_16: update_fail_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_htlcs_arg_conv_16); }; + for (UpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25: update_fail_malformed_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_malformed_htlcs_arg_conv_25); }; ret_hu_conv.ptrs_to.add(update_fee_arg); ret_hu_conv.ptrs_to.add(commitment_signed_arg); return ret_hu_conv; diff --git a/src/main/java/org/ldk/structs/Confirm.java b/src/main/java/org/ldk/structs/Confirm.java index 161d97af..fed45b0e 100644 --- a/src/main/java/org/ldk/structs/Confirm.java +++ b/src/main/java/org/ldk/structs/Confirm.java @@ -153,7 +153,6 @@ public class Confirm extends CommonBase { */ public void transactions_confirmed(byte[] header, TwoTuple[] txdata, int height) { bindings.Confirm_transactions_confirmed(this.ptr, header, txdata != null ? Arrays.stream(txdata).mapToLong(txdata_conv_24 -> bindings.C2Tuple_usizeTransactionZ_new(txdata_conv_24.a, txdata_conv_24.b)).toArray() : null, height); - /* TODO 2 TwoTuple */; } /** diff --git a/src/main/java/org/ldk/structs/CounterpartyForwardingInfo.java b/src/main/java/org/ldk/structs/CounterpartyForwardingInfo.java new file mode 100644 index 00000000..d09b6b5c --- /dev/null +++ b/src/main/java/org/ldk/structs/CounterpartyForwardingInfo.java @@ -0,0 +1,93 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * Information needed for constructing an invoice route hint for this channel. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class CounterpartyForwardingInfo extends CommonBase { + CounterpartyForwardingInfo(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.CounterpartyForwardingInfo_free(ptr); } + } + + /** + * Base routing fee in millisatoshis. + */ + public int get_fee_base_msat() { + int ret = bindings.CounterpartyForwardingInfo_get_fee_base_msat(this.ptr); + return ret; + } + + /** + * Base routing fee in millisatoshis. + */ + public void set_fee_base_msat(int val) { + bindings.CounterpartyForwardingInfo_set_fee_base_msat(this.ptr, val); + } + + /** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ + public int get_fee_proportional_millionths() { + int ret = bindings.CounterpartyForwardingInfo_get_fee_proportional_millionths(this.ptr); + return ret; + } + + /** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ + public void set_fee_proportional_millionths(int val) { + bindings.CounterpartyForwardingInfo_set_fee_proportional_millionths(this.ptr, val); + } + + /** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ + public short get_cltv_expiry_delta() { + short ret = bindings.CounterpartyForwardingInfo_get_cltv_expiry_delta(this.ptr); + return ret; + } + + /** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ + public void set_cltv_expiry_delta(short val) { + bindings.CounterpartyForwardingInfo_set_cltv_expiry_delta(this.ptr, val); + } + + /** + * Constructs a new CounterpartyForwardingInfo given each field + */ + public static CounterpartyForwardingInfo of(int fee_base_msat_arg, int fee_proportional_millionths_arg, short cltv_expiry_delta_arg) { + long ret = bindings.CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + if (ret < 1024) { return null; } + CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a copy of the CounterpartyForwardingInfo + */ + public CounterpartyForwardingInfo clone() { + long ret = bindings.CounterpartyForwardingInfo_clone(this.ptr); + if (ret < 1024) { return null; } + CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/CustomMessageHandler.java b/src/main/java/org/ldk/structs/CustomMessageHandler.java new file mode 100644 index 00000000..fe1a2bb1 --- /dev/null +++ b/src/main/java/org/ldk/structs/CustomMessageHandler.java @@ -0,0 +1,107 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * Handler for BOLT1-compliant messages. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class CustomMessageHandler extends CommonBase { + final bindings.LDKCustomMessageHandler bindings_instance; + CustomMessageHandler(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } + private CustomMessageHandler(bindings.LDKCustomMessageHandler arg, bindings.LDKCustomMessageReader CustomMessageReader) { + super(bindings.LDKCustomMessageHandler_new(arg, CustomMessageReader)); + this.ptrs_to.add(arg); + this.ptrs_to.add(CustomMessageReader); + this.bindings_instance = arg; + } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CustomMessageHandler_free(ptr); } super.finalize(); + } + + public static interface CustomMessageHandlerInterface { + /** + * Called with the message type that was received and the buffer to be read. + * Can return a `MessageHandlingError` if the message could not be handled. + */ + Result_NoneLightningErrorZ handle_custom_message(Type msg, byte[] sender_node_id); + /** + * Gets the list of pending messages which were generated by the custom message + * handler, clearing the list in the process. The first tuple element must + * correspond to the intended recipients node ids. If no connection to one of the + * specified node does not exist, the message is simply not sent to it. + */ + TwoTuple[] get_and_clear_pending_msg(); + } + private static class LDKCustomMessageHandlerHolder { CustomMessageHandler held; } + public static CustomMessageHandler new_impl(CustomMessageHandlerInterface arg, CustomMessageReader.CustomMessageReaderInterface CustomMessageReader_impl) { + final LDKCustomMessageHandlerHolder impl_holder = new LDKCustomMessageHandlerHolder(); + impl_holder.held = new CustomMessageHandler(new bindings.LDKCustomMessageHandler() { + @Override public long handle_custom_message(long msg, byte[] sender_node_id) { + Type ret_hu_conv = new Type(null, msg); + ret_hu_conv.ptrs_to.add(this); + Result_NoneLightningErrorZ ret = arg.handle_custom_message(ret_hu_conv, sender_node_id); + long result = ret != null ? ret.ptr : 0; + return result; + } + @Override public long[] get_and_clear_pending_msg() { + TwoTuple[] ret = arg.get_and_clear_pending_msg(); + long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_24 -> bindings.C2Tuple_PublicKeyTypeZ_new(ret_conv_24.a, ret_conv_24.b == null ? 0 : ret_conv_24.b.ptr)).toArray() : null; + for (TwoTuple ret_conv_24: ret) { impl_holder.held.ptrs_to.add(ret_conv_24.b); }; + return result; + } + }, CustomMessageReader.new_impl(CustomMessageReader_impl).bindings_instance); + return impl_holder.held; + } + + /** + * Gets the underlying CustomMessageReader. + */ + public CustomMessageReader get_custom_message_reader() { + CustomMessageReader res = new CustomMessageReader(null, bindings.LDKCustomMessageHandler_get_CustomMessageReader(this.ptr)); + this.ptrs_to.add(res); + return res; + } + + /** + * Called with the message type that was received and the buffer to be read. + * Can return a `MessageHandlingError` if the message could not be handled. + */ + public Result_NoneLightningErrorZ handle_custom_message(Type msg, byte[] sender_node_id) { + long ret = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg == null ? 0 : msg.ptr, sender_node_id); + if (ret < 1024) { return null; } + Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); + this.ptrs_to.add(msg); + return ret_hu_conv; + } + + /** + * Gets the list of pending messages which were generated by the custom message + * handler, clearing the list in the process. The first tuple element must + * correspond to the intended recipients node ids. If no connection to one of the + * specified node does not exist, the message is simply not sent to it. + */ + public TwoTuple[] get_and_clear_pending_msg() { + long[] ret = bindings.CustomMessageHandler_get_and_clear_pending_msg(this.ptr); + TwoTuple[] ret_conv_24_arr = new TwoTuple[ret.length]; + for (int y = 0; y < ret.length; y++) { + long ret_conv_24 = ret[y]; + byte[] ret_conv_24_a = bindings.LDKC2Tuple_PublicKeyTypeZ_get_a(ret_conv_24); + long ret_conv_24_b = bindings.LDKC2Tuple_PublicKeyTypeZ_get_b(ret_conv_24); + Type ret_hu_conv = new Type(null, ret_conv_24_b); + ret_hu_conv.ptrs_to.add(this);; + TwoTuple ret_conv_24_conv = new TwoTuple(ret_conv_24_a, ret_hu_conv, () -> { + bindings.C2Tuple_PublicKeyTypeZ_free(ret_conv_24); + }); + ret_hu_conv.ptrs_to.add(ret_conv_24_conv); + ret_conv_24_arr[y] = ret_conv_24_conv; + } + return ret_conv_24_arr; + } + +} diff --git a/src/main/java/org/ldk/structs/CustomMessageReader.java b/src/main/java/org/ldk/structs/CustomMessageReader.java new file mode 100644 index 00000000..bfa2e11c --- /dev/null +++ b/src/main/java/org/ldk/structs/CustomMessageReader.java @@ -0,0 +1,61 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) + * decoders. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class CustomMessageReader extends CommonBase { + final bindings.LDKCustomMessageReader bindings_instance; + CustomMessageReader(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } + private CustomMessageReader(bindings.LDKCustomMessageReader arg) { + super(bindings.LDKCustomMessageReader_new(arg)); + this.ptrs_to.add(arg); + this.bindings_instance = arg; + } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CustomMessageReader_free(ptr); } super.finalize(); + } + + public static interface CustomMessageReaderInterface { + /** + * Decodes a custom message to `CustomMessageType`. If the given message type is known to the + * implementation and the message could be decoded, must return `Ok(Some(message))`. If the + * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error + * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + */ + Result_COption_TypeZDecodeErrorZ read(short message_type, byte[] buffer); + } + private static class LDKCustomMessageReaderHolder { CustomMessageReader held; } + public static CustomMessageReader new_impl(CustomMessageReaderInterface arg) { + final LDKCustomMessageReaderHolder impl_holder = new LDKCustomMessageReaderHolder(); + impl_holder.held = new CustomMessageReader(new bindings.LDKCustomMessageReader() { + @Override public long read(short message_type, byte[] buffer) { + Result_COption_TypeZDecodeErrorZ ret = arg.read(message_type, buffer); + long result = ret != null ? ret.ptr : 0; + return result; + } + }); + return impl_holder.held; + } + /** + * Decodes a custom message to `CustomMessageType`. If the given message type is known to the + * implementation and the message could be decoded, must return `Ok(Some(message))`. If the + * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error + * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + */ + public Result_COption_TypeZDecodeErrorZ read(short message_type, byte[] buffer) { + long ret = bindings.CustomMessageReader_read(this.ptr, message_type, buffer); + if (ret < 1024) { return null; } + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Description.java b/src/main/java/org/ldk/structs/Description.java index 6be70625..99082a52 100644 --- a/src/main/java/org/ldk/structs/Description.java +++ b/src/main/java/org/ldk/structs/Description.java @@ -22,17 +22,6 @@ public class Description extends CommonBase { if (ptr != 0) { bindings.Description_free(ptr); } } - /** - * Checks if two Descriptions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(Description b) { - boolean ret = bindings.Description_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the Description */ @@ -44,6 +33,25 @@ public class Description extends CommonBase { return ret_hu_conv; } + /** + * Checks if two Descriptions contain equal inner contents. + */ + public long hash() { + long ret = bindings.Description_hash(this.ptr); + return ret; + } + + /** + * Checks if two Descriptions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(Description b) { + boolean ret = bindings.Description_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + /** * Creates a new `Description` if `description` is at most 1023 __bytes__ long, * returns `CreationError::DescriptionTooLong` otherwise diff --git a/src/main/java/org/ldk/structs/Event.java b/src/main/java/org/ldk/structs/Event.java index 11c852c2..1bbfed01 100644 --- a/src/main/java/org/ldk/structs/Event.java +++ b/src/main/java/org/ldk/structs/Event.java @@ -33,8 +33,8 @@ public class Event extends CommonBase { if (raw_val.getClass() == bindings.LDKEvent.PaymentSent.class) { return new PaymentSent(ptr, (bindings.LDKEvent.PaymentSent)raw_val); } - if (raw_val.getClass() == bindings.LDKEvent.PaymentFailed.class) { - return new PaymentFailed(ptr, (bindings.LDKEvent.PaymentFailed)raw_val); + if (raw_val.getClass() == bindings.LDKEvent.PaymentPathFailed.class) { + return new PaymentPathFailed(ptr, (bindings.LDKEvent.PaymentPathFailed)raw_val); } if (raw_val.getClass() == bindings.LDKEvent.PendingHTLCsForwardable.class) { return new PendingHTLCsForwardable(ptr, (bindings.LDKEvent.PendingHTLCsForwardable)raw_val); @@ -45,6 +45,9 @@ public class Event extends CommonBase { if (raw_val.getClass() == bindings.LDKEvent.PaymentForwarded.class) { return new PaymentForwarded(ptr, (bindings.LDKEvent.PaymentForwarded)raw_val); } + if (raw_val.getClass() == bindings.LDKEvent.ChannelClosed.class) { + return new ChannelClosed(ptr, (bindings.LDKEvent.ChannelClosed)raw_val); + } assert false; return null; // Unreachable without extending the (internal) bindings interface } @@ -112,7 +115,7 @@ public class Event extends CommonBase { this.payment_preimage = obj.payment_preimage; } } - public final static class PaymentFailed extends Event { + public final static class PaymentPathFailed extends Event { /** * The hash which was given to ChannelManager::send_payment. */ @@ -123,10 +126,45 @@ public class Event extends CommonBase { * retry the payment via a different route. */ public final boolean rejected_by_dest; - private PaymentFailed(long ptr, bindings.LDKEvent.PaymentFailed obj) { + /** + * Any failure information conveyed via the Onion return packet by a node along the failed + * payment route. + * + * Should be applied to the [`NetworkGraph`] so that routing decisions can take into + * account the update. [`NetGraphMsgHandler`] is capable of doing this. + * + * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph + * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + */ + public final Option_NetworkUpdateZ network_update; + /** + * For both single-path and multi-path payments, this is set if all paths of the payment have + * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the + * larger MPP payment were still in flight when this event was generated. + */ + public final boolean all_paths_failed; + /** + * The payment path that failed. + */ + public final RouteHop[] path; + private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) { super(null, ptr); this.payment_hash = obj.payment_hash; this.rejected_by_dest = obj.rejected_by_dest; + long network_update = obj.network_update; + Option_NetworkUpdateZ network_update_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(network_update); + network_update_hu_conv.ptrs_to.add(this); + this.network_update = network_update_hu_conv; + this.all_paths_failed = obj.all_paths_failed; + long[] path = obj.path; + RouteHop[] path_conv_10_arr = new RouteHop[path.length]; + for (int k = 0; k < path.length; k++) { + long path_conv_10 = path[k]; + RouteHop path_conv_10_hu_conv = new RouteHop(null, path_conv_10); + path_conv_10_hu_conv.ptrs_to.add(this); + path_conv_10_arr[k] = path_conv_10_hu_conv; + } + this.path = path_conv_10_arr; } } public final static class PendingHTLCsForwardable extends Event { @@ -191,6 +229,25 @@ public class Event extends CommonBase { this.claim_from_onchain_tx = obj.claim_from_onchain_tx; } } + public final static class ChannelClosed extends Event { + /** + * The channel_id of the channel which has been closed. Note that on-chain transactions + * resolving the channel are likely still awaiting confirmation. + */ + public final byte[] channel_id; + /** + * The reason the channel was closed. + */ + public final ClosureReason reason; + private ChannelClosed(long ptr, bindings.LDKEvent.ChannelClosed obj) { + super(null, ptr); + this.channel_id = obj.channel_id; + long reason = obj.reason; + ClosureReason reason_hu_conv = ClosureReason.constr_from_ptr(reason); + reason_hu_conv.ptrs_to.add(this); + this.reason = reason_hu_conv; + } + } /** * Creates a copy of the Event */ @@ -236,13 +293,14 @@ public class Event extends CommonBase { } /** - * Utility method to constructs a new PaymentFailed-variant Event + * Utility method to constructs a new PaymentPathFailed-variant Event */ - public static Event payment_failed(byte[] payment_hash, boolean rejected_by_dest) { - long ret = bindings.Event_payment_failed(payment_hash, rejected_by_dest); + public static Event payment_path_failed(byte[] payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path) { + long ret = bindings.Event_payment_path_failed(payment_hash, rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null); if (ret < 1024) { return null; } Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); + for (RouteHop path_conv_10: path) { ret_hu_conv.ptrs_to.add(path_conv_10); }; return ret_hu_conv; } @@ -265,7 +323,6 @@ public class Event extends CommonBase { if (ret < 1024) { return null; } Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 SpendableOutputDescriptor */; return ret_hu_conv; } @@ -280,6 +337,17 @@ public class Event extends CommonBase { return ret_hu_conv; } + /** + * Utility method to constructs a new ChannelClosed-variant Event + */ + public static Event channel_closed(byte[] channel_id, ClosureReason reason) { + long ret = bindings.Event_channel_closed(channel_id, reason.ptr); + if (ret < 1024) { return null; } + Event ret_hu_conv = Event.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + /** * Serialize the Event object into a byte array which can be read by Event_read */ diff --git a/src/main/java/org/ldk/structs/EventHandler.java b/src/main/java/org/ldk/structs/EventHandler.java index 288e1395..21819ca9 100644 --- a/src/main/java/org/ldk/structs/EventHandler.java +++ b/src/main/java/org/ldk/structs/EventHandler.java @@ -37,7 +37,6 @@ public class EventHandler extends CommonBase { impl_holder.held = new EventHandler(new bindings.LDKEventHandler() { @Override public void handle_event(long event) { Event event_hu_conv = Event.constr_from_ptr(event); - event_hu_conv.ptrs_to.add(this); arg.handle_event(event_hu_conv); } }); @@ -49,7 +48,8 @@ public class EventHandler extends CommonBase { * See [`EventsProvider`] for details that must be considered when implementing this method. */ public void handle_event(Event event) { - bindings.EventHandler_handle_event(this.ptr, event.ptr); + bindings.EventHandler_handle_event(this.ptr, event == null ? 0 : event.ptr & ~1); + this.ptrs_to.add(event); } } diff --git a/src/main/java/org/ldk/structs/ExpiryTime.java b/src/main/java/org/ldk/structs/ExpiryTime.java index e88c1393..4c1c9183 100644 --- a/src/main/java/org/ldk/structs/ExpiryTime.java +++ b/src/main/java/org/ldk/structs/ExpiryTime.java @@ -25,17 +25,6 @@ public class ExpiryTime extends CommonBase { if (ptr != 0) { bindings.ExpiryTime_free(ptr); } } - /** - * Checks if two ExpiryTimes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(ExpiryTime b) { - boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the ExpiryTime */ @@ -47,6 +36,25 @@ public class ExpiryTime extends CommonBase { return ret_hu_conv; } + /** + * Checks if two ExpiryTimes contain equal inner contents. + */ + public long hash() { + long ret = bindings.ExpiryTime_hash(this.ptr); + return ret; + } + + /** + * Checks if two ExpiryTimes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(ExpiryTime b) { + boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + /** * Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would * overflow on adding the `EpiryTime` to it then this function will return a diff --git a/src/main/java/org/ldk/structs/Fallback.java b/src/main/java/org/ldk/structs/Fallback.java index fe2cf61d..10403707 100644 --- a/src/main/java/org/ldk/structs/Fallback.java +++ b/src/main/java/org/ldk/structs/Fallback.java @@ -101,6 +101,14 @@ public class Fallback extends CommonBase { return ret_hu_conv; } + /** + * Checks if two Fallbacks contain equal inner contents. + */ + public long hash() { + long ret = bindings.Fallback_hash(this.ptr); + return ret; + } + /** * Checks if two Fallbacks contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. diff --git a/src/main/java/org/ldk/structs/FundingCreated.java b/src/main/java/org/ldk/structs/FundingCreated.java index 40777425..68abbacf 100644 --- a/src/main/java/org/ldk/structs/FundingCreated.java +++ b/src/main/java/org/ldk/structs/FundingCreated.java @@ -65,7 +65,7 @@ public class FundingCreated extends CommonBase { } /** - * The signature of the channel initiator (funder) on the funding transaction + * The signature of the channel initiator (funder) on the initial commitment transaction */ public byte[] get_signature() { byte[] ret = bindings.FundingCreated_get_signature(this.ptr); @@ -73,7 +73,7 @@ public class FundingCreated extends CommonBase { } /** - * The signature of the channel initiator (funder) on the funding transaction + * The signature of the channel initiator (funder) on the initial commitment transaction */ public void set_signature(byte[] val) { bindings.FundingCreated_set_signature(this.ptr, val); diff --git a/src/main/java/org/ldk/structs/FundingSigned.java b/src/main/java/org/ldk/structs/FundingSigned.java index 67791c52..160e3c5f 100644 --- a/src/main/java/org/ldk/structs/FundingSigned.java +++ b/src/main/java/org/ldk/structs/FundingSigned.java @@ -35,7 +35,7 @@ public class FundingSigned extends CommonBase { } /** - * The signature of the channel acceptor (fundee) on the funding transaction + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ public byte[] get_signature() { byte[] ret = bindings.FundingSigned_get_signature(this.ptr); @@ -43,7 +43,7 @@ public class FundingSigned extends CommonBase { } /** - * The signature of the channel acceptor (fundee) on the funding transaction + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ public void set_signature(byte[] val) { bindings.FundingSigned_set_signature(this.ptr, val); diff --git a/src/main/java/org/ldk/structs/GossipTimestampFilter.java b/src/main/java/org/ldk/structs/GossipTimestampFilter.java index ca697122..07c1e6a7 100644 --- a/src/main/java/org/ldk/structs/GossipTimestampFilter.java +++ b/src/main/java/org/ldk/structs/GossipTimestampFilter.java @@ -88,6 +88,14 @@ public class GossipTimestampFilter extends CommonBase { return ret_hu_conv; } + /** + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + */ + public byte[] write() { + byte[] ret = bindings.GossipTimestampFilter_write(this.ptr); + return ret; + } + /** * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ @@ -98,12 +106,4 @@ public class GossipTimestampFilter extends CommonBase { return ret_hu_conv; } - /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read - */ - public byte[] write() { - byte[] ret = bindings.GossipTimestampFilter_write(this.ptr); - return ret; - } - } diff --git a/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java b/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java deleted file mode 100644 index d2ef7514..00000000 --- a/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.ldk.structs; - -import org.ldk.impl.bindings; -import org.ldk.enums.*; -import org.ldk.util.*; -import java.util.Arrays; -import javax.annotation.Nullable; - - -/** - * The information we received from a peer along the route of a payment we originated. This is - * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into - * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map. - */ -@SuppressWarnings("unchecked") // We correctly assign various generic arrays -public class HTLCFailChannelUpdate extends CommonBase { - private HTLCFailChannelUpdate(Object _dummy, long ptr) { super(ptr); } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - super.finalize(); - if (ptr != 0) { bindings.HTLCFailChannelUpdate_free(ptr); } - } - static HTLCFailChannelUpdate constr_from_ptr(long ptr) { - bindings.LDKHTLCFailChannelUpdate raw_val = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr); - if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage.class) { - return new ChannelUpdateMessage(ptr, (bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage)raw_val); - } - if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelClosed.class) { - return new ChannelClosed(ptr, (bindings.LDKHTLCFailChannelUpdate.ChannelClosed)raw_val); - } - if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.NodeFailure.class) { - return new NodeFailure(ptr, (bindings.LDKHTLCFailChannelUpdate.NodeFailure)raw_val); - } - assert false; return null; // Unreachable without extending the (internal) bindings interface - } - - public final static class ChannelUpdateMessage extends HTLCFailChannelUpdate { - /** - * The unwrapped message we received - */ - public final ChannelUpdate msg; - private ChannelUpdateMessage(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage obj) { - super(null, ptr); - long msg = obj.msg; - ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); - msg_hu_conv.ptrs_to.add(this); - this.msg = msg_hu_conv; - } - } - public final static class ChannelClosed extends HTLCFailChannelUpdate { - /** - * The short_channel_id which has now closed. - */ - public final long short_channel_id; - /** - * when this true, this channel should be permanently removed from the - * consideration. Otherwise, this channel can be restored as new channel_update is received - */ - public final boolean is_permanent; - private ChannelClosed(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelClosed obj) { - super(null, ptr); - this.short_channel_id = obj.short_channel_id; - this.is_permanent = obj.is_permanent; - } - } - public final static class NodeFailure extends HTLCFailChannelUpdate { - /** - * The node_id that has failed. - */ - public final byte[] node_id; - /** - * when this true, node should be permanently removed from the - * consideration. Otherwise, the channels connected to this node can be - * restored as new channel_update is received - */ - public final boolean is_permanent; - private NodeFailure(long ptr, bindings.LDKHTLCFailChannelUpdate.NodeFailure obj) { - super(null, ptr); - this.node_id = obj.node_id; - this.is_permanent = obj.is_permanent; - } - } - /** - * Creates a copy of the HTLCFailChannelUpdate - */ - public HTLCFailChannelUpdate clone() { - long ret = bindings.HTLCFailChannelUpdate_clone(this.ptr); - if (ret < 1024) { return null; } - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - - /** - * Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate - */ - public static HTLCFailChannelUpdate channel_update_message(ChannelUpdate msg) { - long ret = bindings.HTLCFailChannelUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1); - if (ret < 1024) { return null; } - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(msg); - return ret_hu_conv; - } - - /** - * Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate - */ - public static HTLCFailChannelUpdate channel_closed(long short_channel_id, boolean is_permanent) { - long ret = bindings.HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - if (ret < 1024) { return null; } - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - - /** - * Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate - */ - public static HTLCFailChannelUpdate node_failure(byte[] node_id, boolean is_permanent) { - long ret = bindings.HTLCFailChannelUpdate_node_failure(node_id, is_permanent); - if (ret < 1024) { return null; } - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - -} diff --git a/src/main/java/org/ldk/structs/IgnoringMessageHandler.java b/src/main/java/org/ldk/structs/IgnoringMessageHandler.java index 8790d4e5..ddf17fc3 100644 --- a/src/main/java/org/ldk/structs/IgnoringMessageHandler.java +++ b/src/main/java/org/ldk/structs/IgnoringMessageHandler.java @@ -55,4 +55,28 @@ public class IgnoringMessageHandler extends CommonBase { return ret_hu_conv; } + /** + * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is + */ + public CustomMessageReader as_CustomMessageReader() { + long ret = bindings.IgnoringMessageHandler_as_CustomMessageReader(this.ptr); + if (ret < 1024) { return null; } + CustomMessageReader ret_hu_conv = new CustomMessageReader(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is + */ + public CustomMessageHandler as_CustomMessageHandler() { + long ret = bindings.IgnoringMessageHandler_as_CustomMessageHandler(this.ptr); + if (ret < 1024) { return null; } + CustomMessageHandler ret_hu_conv = new CustomMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + } diff --git a/src/main/java/org/ldk/structs/InitFeatures.java b/src/main/java/org/ldk/structs/InitFeatures.java index 4548ae49..6b89bcb0 100644 --- a/src/main/java/org/ldk/structs/InitFeatures.java +++ b/src/main/java/org/ldk/structs/InitFeatures.java @@ -63,6 +63,15 @@ public class InitFeatures extends CommonBase { return ret_hu_conv; } + /** + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". + */ + public boolean requires_unknown_bits() { + boolean ret = bindings.InitFeatures_requires_unknown_bits(this.ptr); + return ret; + } + /** * Returns whether the `payment_secret` feature is supported. */ diff --git a/src/main/java/org/ldk/structs/Invoice.java b/src/main/java/org/ldk/structs/Invoice.java index 452fbb0a..e162d340 100644 --- a/src/main/java/org/ldk/structs/Invoice.java +++ b/src/main/java/org/ldk/structs/Invoice.java @@ -73,10 +73,17 @@ public class Invoice extends CommonBase { * ``` * use lightning_invoice::*; * - * let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\ - * \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\ - * \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\ - * \tky03ylcqca784w\"; + * let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\ + * h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\ + * 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\ + * h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\ + * j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\ + * ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\ + * guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\ + * ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\ + * p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\ + * 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ + * j5r6drg6k6zcqj0fcwg\"; * * let signed = invoice.parse::().unwrap(); * @@ -120,10 +127,7 @@ public class Invoice extends CommonBase { /** * Get the payment secret if one was included in the invoice - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ - @Nullable public byte[] payment_secret() { byte[] ret = bindings.Invoice_payment_secret(this.ptr); return ret; diff --git a/src/main/java/org/ldk/structs/InvoiceFeatures.java b/src/main/java/org/ldk/structs/InvoiceFeatures.java index da08d2fe..be91f813 100644 --- a/src/main/java/org/ldk/structs/InvoiceFeatures.java +++ b/src/main/java/org/ldk/structs/InvoiceFeatures.java @@ -63,6 +63,15 @@ public class InvoiceFeatures extends CommonBase { return ret_hu_conv; } + /** + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". + */ + public boolean requires_unknown_bits() { + boolean ret = bindings.InvoiceFeatures_requires_unknown_bits(this.ptr); + return ret; + } + /** * Returns whether the `payment_secret` feature is supported. */ diff --git a/src/main/java/org/ldk/structs/InvoiceSignature.java b/src/main/java/org/ldk/structs/InvoiceSignature.java index 690787d5..9ebc04d7 100644 --- a/src/main/java/org/ldk/structs/InvoiceSignature.java +++ b/src/main/java/org/ldk/structs/InvoiceSignature.java @@ -19,17 +19,6 @@ public class InvoiceSignature extends CommonBase { if (ptr != 0) { bindings.InvoiceSignature_free(ptr); } } - /** - * Checks if two InvoiceSignatures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(InvoiceSignature b) { - boolean ret = bindings.InvoiceSignature_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the InvoiceSignature */ @@ -41,4 +30,15 @@ public class InvoiceSignature extends CommonBase { return ret_hu_conv; } + /** + * Checks if two InvoiceSignatures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(InvoiceSignature b) { + boolean ret = bindings.InvoiceSignature_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/KeysManager.java b/src/main/java/org/ldk/structs/KeysManager.java index 87b6c48e..6f8684ea 100644 --- a/src/main/java/org/ldk/structs/KeysManager.java +++ b/src/main/java/org/ldk/structs/KeysManager.java @@ -86,8 +86,6 @@ public class KeysManager extends CommonBase { long ret = bindings.KeysManager_spend_spendable_outputs(this.ptr, 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); if (ret < 1024) { return null; } Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret); - /* TODO 2 SpendableOutputDescriptor */; - /* TODO 2 TxOut */; return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/LockedNetworkGraph.java b/src/main/java/org/ldk/structs/LockedNetworkGraph.java deleted file mode 100644 index fabcb4ef..00000000 --- a/src/main/java/org/ldk/structs/LockedNetworkGraph.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.ldk.structs; - -import org.ldk.impl.bindings; -import org.ldk.enums.*; -import org.ldk.util.*; -import java.util.Arrays; -import javax.annotation.Nullable; - - -/** - * A simple newtype for RwLockReadGuard<'a, NetworkGraph>. - * This exists only to make accessing a RwLock possible from - * the C bindings, as it can be done directly in Rust code. - */ -@SuppressWarnings("unchecked") // We correctly assign various generic arrays -public class LockedNetworkGraph extends CommonBase implements AutoCloseable { - LockedNetworkGraph(Object _dummy, long ptr) { super(ptr); } - @Override public void close() { - if (ptr != 0) { bindings.LockedNetworkGraph_free(ptr); } - } - - /** - * Get a reference to the NetworkGraph which this read-lock contains. - */ - public NetworkGraph graph() { - long ret = bindings.LockedNetworkGraph_graph(this.ptr); - if (ret < 1024) { return null; } - NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - -} diff --git a/src/main/java/org/ldk/structs/MessageSendEvent.java b/src/main/java/org/ldk/structs/MessageSendEvent.java index 670c5b42..cd30a1a6 100644 --- a/src/main/java/org/ldk/structs/MessageSendEvent.java +++ b/src/main/java/org/ldk/structs/MessageSendEvent.java @@ -70,9 +70,6 @@ public class MessageSendEvent extends CommonBase { if (raw_val.getClass() == bindings.LDKMessageSendEvent.HandleError.class) { return new HandleError(ptr, (bindings.LDKMessageSendEvent.HandleError)raw_val); } - if (raw_val.getClass() == bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate.class) { - return new PaymentFailureNetworkUpdate(ptr, (bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate)raw_val); - } if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelRangeQuery.class) { return new SendChannelRangeQuery(ptr, (bindings.LDKMessageSendEvent.SendChannelRangeQuery)raw_val); } @@ -366,19 +363,6 @@ public class MessageSendEvent extends CommonBase { this.action = action_hu_conv; } } - public final static class PaymentFailureNetworkUpdate extends MessageSendEvent { - /** - * The channel/node update which should be sent to NetGraphMsgHandler - */ - public final HTLCFailChannelUpdate update; - private PaymentFailureNetworkUpdate(long ptr, bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate obj) { - super(null, ptr); - long update = obj.update; - HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update); - update_hu_conv.ptrs_to.add(this); - this.update = update_hu_conv; - } - } public final static class SendChannelRangeQuery extends MessageSendEvent { /** * The node_id of this message recipient @@ -636,17 +620,6 @@ public class MessageSendEvent extends CommonBase { return ret_hu_conv; } - /** - * Utility method to constructs a new PaymentFailureNetworkUpdate-variant MessageSendEvent - */ - public static MessageSendEvent payment_failure_network_update(HTLCFailChannelUpdate update) { - long ret = bindings.MessageSendEvent_payment_failure_network_update(update.ptr); - if (ret < 1024) { return null; } - MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - /** * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent */ diff --git a/src/main/java/org/ldk/structs/MessageSendEventsProvider.java b/src/main/java/org/ldk/structs/MessageSendEventsProvider.java index 97fe6940..b4c54c2e 100644 --- a/src/main/java/org/ldk/structs/MessageSendEventsProvider.java +++ b/src/main/java/org/ldk/structs/MessageSendEventsProvider.java @@ -37,7 +37,6 @@ public class MessageSendEventsProvider extends CommonBase { @Override public long[] get_and_clear_pending_msg_events() { MessageSendEvent[] ret = arg.get_and_clear_pending_msg_events(); long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_18 -> ret_conv_18.ptr).toArray() : null; - /* TODO 2 MessageSendEvent */; return result; } }); diff --git a/src/main/java/org/ldk/structs/MinFinalCltvExpiry.java b/src/main/java/org/ldk/structs/MinFinalCltvExpiry.java index c06fba18..0556b9ae 100644 --- a/src/main/java/org/ldk/structs/MinFinalCltvExpiry.java +++ b/src/main/java/org/ldk/structs/MinFinalCltvExpiry.java @@ -19,17 +19,6 @@ public class MinFinalCltvExpiry extends CommonBase { if (ptr != 0) { bindings.MinFinalCltvExpiry_free(ptr); } } - /** - * Checks if two MinFinalCltvExpirys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(MinFinalCltvExpiry b) { - boolean ret = bindings.MinFinalCltvExpiry_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the MinFinalCltvExpiry */ @@ -41,4 +30,23 @@ public class MinFinalCltvExpiry extends CommonBase { return ret_hu_conv; } + /** + * Checks if two MinFinalCltvExpirys contain equal inner contents. + */ + public long hash() { + long ret = bindings.MinFinalCltvExpiry_hash(this.ptr); + return ret; + } + + /** + * Checks if two MinFinalCltvExpirys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(MinFinalCltvExpiry b) { + boolean ret = bindings.MinFinalCltvExpiry_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/MonitorEvent.java b/src/main/java/org/ldk/structs/MonitorEvent.java index d93c085a..4dc9a601 100644 --- a/src/main/java/org/ldk/structs/MonitorEvent.java +++ b/src/main/java/org/ldk/structs/MonitorEvent.java @@ -23,8 +23,8 @@ public class MonitorEvent extends CommonBase { if (raw_val.getClass() == bindings.LDKMonitorEvent.HTLCEvent.class) { return new HTLCEvent(ptr, (bindings.LDKMonitorEvent.HTLCEvent)raw_val); } - if (raw_val.getClass() == bindings.LDKMonitorEvent.CommitmentTxBroadcasted.class) { - return new CommitmentTxBroadcasted(ptr, (bindings.LDKMonitorEvent.CommitmentTxBroadcasted)raw_val); + if (raw_val.getClass() == bindings.LDKMonitorEvent.CommitmentTxConfirmed.class) { + return new CommitmentTxConfirmed(ptr, (bindings.LDKMonitorEvent.CommitmentTxConfirmed)raw_val); } assert false; return null; // Unreachable without extending the (internal) bindings interface } @@ -39,14 +39,14 @@ public class MonitorEvent extends CommonBase { this.htlc_event = htlc_event_hu_conv; } } - public final static class CommitmentTxBroadcasted extends MonitorEvent { - public final OutPoint commitment_tx_broadcasted; - private CommitmentTxBroadcasted(long ptr, bindings.LDKMonitorEvent.CommitmentTxBroadcasted obj) { + public final static class CommitmentTxConfirmed extends MonitorEvent { + public final OutPoint commitment_tx_confirmed; + private CommitmentTxConfirmed(long ptr, bindings.LDKMonitorEvent.CommitmentTxConfirmed obj) { super(null, ptr); - long commitment_tx_broadcasted = obj.commitment_tx_broadcasted; - OutPoint commitment_tx_broadcasted_hu_conv = new OutPoint(null, commitment_tx_broadcasted); - commitment_tx_broadcasted_hu_conv.ptrs_to.add(this); - this.commitment_tx_broadcasted = commitment_tx_broadcasted_hu_conv; + long commitment_tx_confirmed = obj.commitment_tx_confirmed; + OutPoint commitment_tx_confirmed_hu_conv = new OutPoint(null, commitment_tx_confirmed); + commitment_tx_confirmed_hu_conv.ptrs_to.add(this); + this.commitment_tx_confirmed = commitment_tx_confirmed_hu_conv; } } /** @@ -73,10 +73,10 @@ public class MonitorEvent extends CommonBase { } /** - * Utility method to constructs a new CommitmentTxBroadcasted-variant MonitorEvent + * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent */ - public static MonitorEvent commitment_tx_broadcasted(OutPoint a) { - long ret = bindings.MonitorEvent_commitment_tx_broadcasted(a == null ? 0 : a.ptr & ~1); + public static MonitorEvent commitment_tx_confirmed(OutPoint a) { + long ret = bindings.MonitorEvent_commitment_tx_confirmed(a == null ? 0 : a.ptr & ~1); if (ret < 1024) { return null; } MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); diff --git a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java index 80225880..cb2d2c51 100644 --- a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java +++ b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java @@ -13,6 +13,9 @@ import javax.annotation.Nullable; * This network graph is then used for routing payments. * Provides interface to help with initial routing sync by * serving historical announcements. + * + * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the + * [`NetworkGraph`]. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NetGraphMsgHandler extends CommonBase { @@ -24,38 +27,48 @@ public class NetGraphMsgHandler extends CommonBase { } /** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming a fresh network graph. - * Chain monitor is used to make sure announced channels exist on-chain, - * channel data is correct, and that the announcement is signed with - * channel owners' keys. - * - * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new EventHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is */ - public static NetGraphMsgHandler of(byte[] genesis_hash, @Nullable Access chain_access, Logger logger) { - long ret = bindings.NetGraphMsgHandler_new(genesis_hash, chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr); + public EventHandler as_EventHandler() { + long ret = bindings.NetGraphMsgHandler_as_EventHandler(this.ptr); if (ret < 1024) { return null; } - NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_access); - ret_hu_conv.ptrs_to.add(logger); + EventHandler ret_hu_conv = new EventHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Representation of the payment channel network + */ + public NetworkGraph get_network_graph() { + long ret = bindings.NetGraphMsgHandler_get_network_graph(this.ptr); + if (ret < 1024) { return null; } + NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); + ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } + /** + * Representation of the payment channel network + */ + public void set_network_graph(byte[] val_genesis_hash) { + bindings.NetGraphMsgHandler_set_network_graph(this.ptr, bindings.NetworkGraph_new(val_genesis_hash)); + } + /** * Creates a new tracker of the actual state of the network of channels and nodes, * assuming an existing Network Graph. - * - * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None + * Chain monitor is used to make sure announced channels exist on-chain, + * channel data is correct, and that the announcement is signed with + * channel owners' keys. */ - public static NetGraphMsgHandler from_net_graph(@Nullable Access chain_access, Logger logger, NetworkGraph network_graph) { - long ret = bindings.NetGraphMsgHandler_from_net_graph(chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr, network_graph == null ? 0 : network_graph.ptr & ~1); + public static NetGraphMsgHandler of(byte[] network_graph_genesis_hash, Option_AccessZ chain_access, Logger logger) { + long ret = bindings.NetGraphMsgHandler_new(bindings.NetworkGraph_new(network_graph_genesis_hash), chain_access.ptr, logger == null ? 0 : logger.ptr); if (ret < 1024) { return null; } NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_access); ret_hu_conv.ptrs_to.add(logger); - ret_hu_conv.ptrs_to.add(network_graph); return ret_hu_conv; } @@ -63,26 +76,9 @@ public class NetGraphMsgHandler extends CommonBase { * Adds a provider used to check new announcements. Does not affect * existing announcements unless they are updated. * Add, update or remove the provider would replace the current one. - * - * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public void add_chain_access(@Nullable Access chain_access) { - bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access == null ? 0 : chain_access.ptr); - this.ptrs_to.add(chain_access); - } - - /** - * Take a read lock on the network_graph and return it in the C-bindings - * newtype helper. This is likely only useful when called via the C - * bindings as you can call `self.network_graph.read().unwrap()` in Rust - * yourself. - */ - public LockedNetworkGraph read_locked_graph() { - long ret = bindings.NetGraphMsgHandler_read_locked_graph(this.ptr); - if (ret < 1024) { return null; } - LockedNetworkGraph ret_hu_conv = new LockedNetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; + public void add_chain_access(Option_AccessZ chain_access) { + bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access.ptr); } /** diff --git a/src/main/java/org/ldk/structs/NetworkGraph.java b/src/main/java/org/ldk/structs/NetworkGraph.java index b010679d..70e666fd 100644 --- a/src/main/java/org/ldk/structs/NetworkGraph.java +++ b/src/main/java/org/ldk/structs/NetworkGraph.java @@ -19,17 +19,6 @@ public class NetworkGraph extends CommonBase { if (ptr != 0) { bindings.NetworkGraph_free(ptr); } } - /** - * Creates a copy of the NetworkGraph - */ - public NetworkGraph clone() { - long ret = bindings.NetworkGraph_clone(this.ptr); - if (ret < 1024) { return null; } - NetworkGraph ret_hu_conv = new NetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - /** * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ @@ -59,6 +48,17 @@ public class NetworkGraph extends CommonBase { return ret_hu_conv; } + /** + * Returns a read-only view of the network graph. + */ + public ReadOnlyNetworkGraph read_only() { + long ret = bindings.NetworkGraph_read_only(this.ptr); + if (ret < 1024) { return null; } + ReadOnlyNetworkGraph ret_hu_conv = new ReadOnlyNetworkGraph(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + /** * For an already known node (from channel announcements), update its stored properties from a * given node announcement. @@ -98,15 +98,12 @@ public class NetworkGraph extends CommonBase { * * If a `chain::Access` object is provided via `chain_access`, it will be called to verify * the corresponding UTXO exists on chain and is correctly-formatted. - * - * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, @Nullable Access chain_access) { - long ret = bindings.NetworkGraph_update_channel_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr); + public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, Option_AccessZ chain_access) { + long ret = bindings.NetworkGraph_update_channel_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access.ptr); if (ret < 1024) { return null; } Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); this.ptrs_to.add(msg); - this.ptrs_to.add(chain_access); return ret_hu_conv; } @@ -117,15 +114,12 @@ public class NetworkGraph extends CommonBase { * * If a `chain::Access` object is provided via `chain_access`, it will be called to verify * the corresponding UTXO exists on chain and is correctly-formatted. - * - * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, @Nullable Access chain_access) { - long ret = bindings.NetworkGraph_update_channel_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr); + public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Option_AccessZ chain_access) { + long ret = bindings.NetworkGraph_update_channel_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access.ptr); if (ret < 1024) { return null; } Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); this.ptrs_to.add(msg); - this.ptrs_to.add(chain_access); return ret_hu_conv; } @@ -139,6 +133,13 @@ public class NetworkGraph extends CommonBase { bindings.NetworkGraph_close_channel_from_update(this.ptr, short_channel_id, is_permanent); } + /** + * Marks a node in the graph as failed. + */ + public void fail_node(byte[] _node_id, boolean is_permanent) { + bindings.NetworkGraph_fail_node(this.ptr, _node_id, is_permanent); + } + /** * For an already known (from announcement) channel, update info about one of the directions * of the channel. diff --git a/src/main/java/org/ldk/structs/NetworkUpdate.java b/src/main/java/org/ldk/structs/NetworkUpdate.java new file mode 100644 index 00000000..25e22024 --- /dev/null +++ b/src/main/java/org/ldk/structs/NetworkUpdate.java @@ -0,0 +1,136 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion + * return packet by a node along the route. See [BOLT #4] for details. + * + * [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class NetworkUpdate extends CommonBase { + private NetworkUpdate(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.NetworkUpdate_free(ptr); } + } + static NetworkUpdate constr_from_ptr(long ptr) { + bindings.LDKNetworkUpdate raw_val = bindings.LDKNetworkUpdate_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKNetworkUpdate.ChannelUpdateMessage.class) { + return new ChannelUpdateMessage(ptr, (bindings.LDKNetworkUpdate.ChannelUpdateMessage)raw_val); + } + if (raw_val.getClass() == bindings.LDKNetworkUpdate.ChannelClosed.class) { + return new ChannelClosed(ptr, (bindings.LDKNetworkUpdate.ChannelClosed)raw_val); + } + if (raw_val.getClass() == bindings.LDKNetworkUpdate.NodeFailure.class) { + return new NodeFailure(ptr, (bindings.LDKNetworkUpdate.NodeFailure)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class ChannelUpdateMessage extends NetworkUpdate { + /** + * The update to apply via [`NetworkGraph::update_channel`]. + */ + public final ChannelUpdate msg; + private ChannelUpdateMessage(long ptr, bindings.LDKNetworkUpdate.ChannelUpdateMessage obj) { + super(null, ptr); + long msg = obj.msg; + ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); + msg_hu_conv.ptrs_to.add(this); + this.msg = msg_hu_conv; + } + } + public final static class ChannelClosed extends NetworkUpdate { + /** + * The short channel id of the closed channel. + */ + public final long short_channel_id; + /** + * Whether the channel should be permanently removed or temporarily disabled until a new + * `channel_update` message is received. + */ + public final boolean is_permanent; + private ChannelClosed(long ptr, bindings.LDKNetworkUpdate.ChannelClosed obj) { + super(null, ptr); + this.short_channel_id = obj.short_channel_id; + this.is_permanent = obj.is_permanent; + } + } + public final static class NodeFailure extends NetworkUpdate { + /** + * The node id of the failed node. + */ + public final byte[] node_id; + /** + * Whether the node should be permanently removed from consideration or can be restored + * when a new `channel_update` message is received. + */ + public final boolean is_permanent; + private NodeFailure(long ptr, bindings.LDKNetworkUpdate.NodeFailure obj) { + super(null, ptr); + this.node_id = obj.node_id; + this.is_permanent = obj.is_permanent; + } + } + /** + * Creates a copy of the NetworkUpdate + */ + public NetworkUpdate clone() { + long ret = bindings.NetworkUpdate_clone(this.ptr); + if (ret < 1024) { return null; } + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate + */ + public static NetworkUpdate channel_update_message(ChannelUpdate msg) { + long ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1); + if (ret < 1024) { return null; } + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(msg); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new ChannelClosed-variant NetworkUpdate + */ + public static NetworkUpdate channel_closed(long short_channel_id, boolean is_permanent) { + long ret = bindings.NetworkUpdate_channel_closed(short_channel_id, is_permanent); + if (ret < 1024) { return null; } + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new NodeFailure-variant NetworkUpdate + */ + public static NetworkUpdate node_failure(byte[] node_id, boolean is_permanent) { + long ret = bindings.NetworkUpdate_node_failure(node_id, is_permanent); + if (ret < 1024) { return null; } + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read + */ + public byte[] write() { + byte[] ret = bindings.NetworkUpdate_write(this.ptr); + return ret; + } + +} diff --git a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java index 26385c85..696815c0 100644 --- a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java +++ b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java @@ -94,7 +94,6 @@ public class NodeAnnouncementInfo extends CommonBase { */ public void set_addresses(NetAddress[] val) { bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null); - /* TODO 2 NetAddress */; } /** @@ -136,7 +135,6 @@ public class NodeAnnouncementInfo extends CommonBase { NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(features_arg); - /* TODO 2 NetAddress */; ret_hu_conv.ptrs_to.add(announcement_message_arg); return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/NodeFeatures.java b/src/main/java/org/ldk/structs/NodeFeatures.java index 9d78059f..75134c92 100644 --- a/src/main/java/org/ldk/structs/NodeFeatures.java +++ b/src/main/java/org/ldk/structs/NodeFeatures.java @@ -63,6 +63,15 @@ public class NodeFeatures extends CommonBase { return ret_hu_conv; } + /** + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". + */ + public boolean requires_unknown_bits() { + boolean ret = bindings.NodeFeatures_requires_unknown_bits(this.ptr); + return ret; + } + /** * Returns whether the `payment_secret` feature is supported. */ diff --git a/src/main/java/org/ldk/structs/Option_AccessZ.java b/src/main/java/org/ldk/structs/Option_AccessZ.java new file mode 100644 index 00000000..3c032cc7 --- /dev/null +++ b/src/main/java/org/ldk/structs/Option_AccessZ.java @@ -0,0 +1,70 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * An enum which can either contain a crate::lightning::chain::Access or not + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Option_AccessZ extends CommonBase { + private Option_AccessZ(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.COption_AccessZ_free(ptr); } + } + static Option_AccessZ constr_from_ptr(long ptr) { + bindings.LDKCOption_AccessZ raw_val = bindings.LDKCOption_AccessZ_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKCOption_AccessZ.Some.class) { + return new Some(ptr, (bindings.LDKCOption_AccessZ.Some)raw_val); + } + if (raw_val.getClass() == bindings.LDKCOption_AccessZ.None.class) { + return new None(ptr, (bindings.LDKCOption_AccessZ.None)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class Some extends Option_AccessZ { + public final Access some; + private Some(long ptr, bindings.LDKCOption_AccessZ.Some obj) { + super(null, ptr); + long some = obj.some; + Access ret_hu_conv = new Access(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } + } + public final static class None extends Option_AccessZ { + private None(long ptr, bindings.LDKCOption_AccessZ.None obj) { + super(null, ptr); + } + } + /** + * Constructs a new COption_AccessZ containing a crate::lightning::chain::Access + */ + public static Option_AccessZ some(Access o) { + long ret = bindings.COption_AccessZ_some(o == null ? 0 : o.ptr); + if (ret < 1024) { return null; } + Option_AccessZ ret_hu_conv = Option_AccessZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + /** + * Constructs a new COption_AccessZ containing nothing + */ + public static Option_AccessZ none() { + long ret = bindings.COption_AccessZ_none(); + if (ret < 1024) { return null; } + Option_AccessZ ret_hu_conv = Option_AccessZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Option_FilterZ.java b/src/main/java/org/ldk/structs/Option_FilterZ.java new file mode 100644 index 00000000..117215e1 --- /dev/null +++ b/src/main/java/org/ldk/structs/Option_FilterZ.java @@ -0,0 +1,70 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * An enum which can either contain a crate::lightning::chain::Filter or not + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Option_FilterZ extends CommonBase { + private Option_FilterZ(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.COption_FilterZ_free(ptr); } + } + static Option_FilterZ constr_from_ptr(long ptr) { + bindings.LDKCOption_FilterZ raw_val = bindings.LDKCOption_FilterZ_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKCOption_FilterZ.Some.class) { + return new Some(ptr, (bindings.LDKCOption_FilterZ.Some)raw_val); + } + if (raw_val.getClass() == bindings.LDKCOption_FilterZ.None.class) { + return new None(ptr, (bindings.LDKCOption_FilterZ.None)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class Some extends Option_FilterZ { + public final Filter some; + private Some(long ptr, bindings.LDKCOption_FilterZ.Some obj) { + super(null, ptr); + long some = obj.some; + Filter ret_hu_conv = new Filter(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } + } + public final static class None extends Option_FilterZ { + private None(long ptr, bindings.LDKCOption_FilterZ.None obj) { + super(null, ptr); + } + } + /** + * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter + */ + public static Option_FilterZ some(Filter o) { + long ret = bindings.COption_FilterZ_some(o == null ? 0 : o.ptr); + if (ret < 1024) { return null; } + Option_FilterZ ret_hu_conv = Option_FilterZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + /** + * Constructs a new COption_FilterZ containing nothing + */ + public static Option_FilterZ none() { + long ret = bindings.COption_FilterZ_none(); + if (ret < 1024) { return null; } + Option_FilterZ ret_hu_conv = Option_FilterZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Option_NetworkUpdateZ.java b/src/main/java/org/ldk/structs/Option_NetworkUpdateZ.java new file mode 100644 index 00000000..248c150c --- /dev/null +++ b/src/main/java/org/ldk/structs/Option_NetworkUpdateZ.java @@ -0,0 +1,81 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * An enum which can either contain a crate::lightning::routing::network_graph::NetworkUpdate or not + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Option_NetworkUpdateZ extends CommonBase { + private Option_NetworkUpdateZ(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.COption_NetworkUpdateZ_free(ptr); } + } + static Option_NetworkUpdateZ constr_from_ptr(long ptr) { + bindings.LDKCOption_NetworkUpdateZ raw_val = bindings.LDKCOption_NetworkUpdateZ_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKCOption_NetworkUpdateZ.Some.class) { + return new Some(ptr, (bindings.LDKCOption_NetworkUpdateZ.Some)raw_val); + } + if (raw_val.getClass() == bindings.LDKCOption_NetworkUpdateZ.None.class) { + return new None(ptr, (bindings.LDKCOption_NetworkUpdateZ.None)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class Some extends Option_NetworkUpdateZ { + public final NetworkUpdate some; + private Some(long ptr, bindings.LDKCOption_NetworkUpdateZ.Some obj) { + super(null, ptr); + long some = obj.some; + NetworkUpdate some_hu_conv = NetworkUpdate.constr_from_ptr(some); + some_hu_conv.ptrs_to.add(this); + this.some = some_hu_conv; + } + } + public final static class None extends Option_NetworkUpdateZ { + private None(long ptr, bindings.LDKCOption_NetworkUpdateZ.None obj) { + super(null, ptr); + } + } + /** + * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate + */ + public static Option_NetworkUpdateZ some(NetworkUpdate o) { + long ret = bindings.COption_NetworkUpdateZ_some(o.ptr); + if (ret < 1024) { return null; } + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Constructs a new COption_NetworkUpdateZ containing nothing + */ + public static Option_NetworkUpdateZ none() { + long ret = bindings.COption_NetworkUpdateZ_none(); + if (ret < 1024) { return null; } + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Option_NetworkUpdateZ clone() { + long ret = bindings.COption_NetworkUpdateZ_clone(this.ptr); + if (ret < 1024) { return null; } + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Option_TypeZ.java b/src/main/java/org/ldk/structs/Option_TypeZ.java new file mode 100644 index 00000000..cb1b3e78 --- /dev/null +++ b/src/main/java/org/ldk/structs/Option_TypeZ.java @@ -0,0 +1,82 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * An enum which can either contain a crate::lightning::ln::wire::Type or not + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Option_TypeZ extends CommonBase { + private Option_TypeZ(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.COption_TypeZ_free(ptr); } + } + static Option_TypeZ constr_from_ptr(long ptr) { + bindings.LDKCOption_TypeZ raw_val = bindings.LDKCOption_TypeZ_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKCOption_TypeZ.Some.class) { + return new Some(ptr, (bindings.LDKCOption_TypeZ.Some)raw_val); + } + if (raw_val.getClass() == bindings.LDKCOption_TypeZ.None.class) { + return new None(ptr, (bindings.LDKCOption_TypeZ.None)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class Some extends Option_TypeZ { + public final Type some; + private Some(long ptr, bindings.LDKCOption_TypeZ.Some obj) { + super(null, ptr); + long some = obj.some; + Type ret_hu_conv = new Type(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } + } + public final static class None extends Option_TypeZ { + private None(long ptr, bindings.LDKCOption_TypeZ.None obj) { + super(null, ptr); + } + } + /** + * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type + */ + public static Option_TypeZ some(Type o) { + long ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr); + if (ret < 1024) { return null; } + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + /** + * Constructs a new COption_TypeZ containing nothing + */ + public static Option_TypeZ none() { + long ret = bindings.COption_TypeZ_none(); + if (ret < 1024) { return null; } + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a new COption_TypeZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Option_TypeZ clone() { + long ret = bindings.COption_TypeZ_clone(this.ptr); + if (ret < 1024) { return null; } + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/PayeePubKey.java b/src/main/java/org/ldk/structs/PayeePubKey.java index efe6a6a7..b6ea267f 100644 --- a/src/main/java/org/ldk/structs/PayeePubKey.java +++ b/src/main/java/org/ldk/structs/PayeePubKey.java @@ -19,17 +19,6 @@ public class PayeePubKey extends CommonBase { if (ptr != 0) { bindings.PayeePubKey_free(ptr); } } - /** - * Checks if two PayeePubKeys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(PayeePubKey b) { - boolean ret = bindings.PayeePubKey_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the PayeePubKey */ @@ -41,4 +30,23 @@ public class PayeePubKey extends CommonBase { return ret_hu_conv; } + /** + * Checks if two PayeePubKeys contain equal inner contents. + */ + public long hash() { + long ret = bindings.PayeePubKey_hash(this.ptr); + return ret; + } + + /** + * Checks if two PayeePubKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(PayeePubKey b) { + boolean ret = bindings.PayeePubKey_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/PaymentSendFailure.java b/src/main/java/org/ldk/structs/PaymentSendFailure.java index c9963b58..ea51eb03 100644 --- a/src/main/java/org/ldk/structs/PaymentSendFailure.java +++ b/src/main/java/org/ldk/structs/PaymentSendFailure.java @@ -120,7 +120,6 @@ public class PaymentSendFailure extends CommonBase { if (ret < 1024) { return null; } PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 Result_NoneAPIErrorZ */; return ret_hu_conv; } @@ -132,7 +131,6 @@ public class PaymentSendFailure extends CommonBase { if (ret < 1024) { return null; } PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 APIError */; return ret_hu_conv; } @@ -144,7 +142,6 @@ public class PaymentSendFailure extends CommonBase { if (ret < 1024) { return null; } PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 Result_NoneAPIErrorZ */; return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/PeerManager.java b/src/main/java/org/ldk/structs/PeerManager.java index 4fa6c771..f5f40db8 100644 --- a/src/main/java/org/ldk/structs/PeerManager.java +++ b/src/main/java/org/ldk/structs/PeerManager.java @@ -42,14 +42,15 @@ public class PeerManager extends CommonBase { * ephemeral_random_data is used to derive per-connection ephemeral keys and must be * cryptographically secure random bytes. */ - public static PeerManager of(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger) { - long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr); + public static PeerManager of(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger, CustomMessageHandler custom_message_handler) { + long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr, custom_message_handler == null ? 0 : custom_message_handler.ptr); if (ret < 1024) { return null; } PeerManager ret_hu_conv = new PeerManager(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(message_handler_chan_handler_arg); ret_hu_conv.ptrs_to.add(message_handler_route_handler_arg); ret_hu_conv.ptrs_to.add(logger); + ret_hu_conv.ptrs_to.add(custom_message_handler); return ret_hu_conv; } @@ -160,6 +161,9 @@ public class PeerManager extends CommonBase { * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy * issues! * + * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] + * or one of the other clients provided in our language bindings. + * * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards * [`send_data`]: SocketDescriptor::send_data diff --git a/src/main/java/org/ldk/structs/PrivateRoute.java b/src/main/java/org/ldk/structs/PrivateRoute.java index be446f1b..ae2872a1 100644 --- a/src/main/java/org/ldk/structs/PrivateRoute.java +++ b/src/main/java/org/ldk/structs/PrivateRoute.java @@ -22,17 +22,6 @@ public class PrivateRoute extends CommonBase { if (ptr != 0) { bindings.PrivateRoute_free(ptr); } } - /** - * Checks if two PrivateRoutes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(PrivateRoute b) { - boolean ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the PrivateRoute */ @@ -44,6 +33,25 @@ public class PrivateRoute extends CommonBase { return ret_hu_conv; } + /** + * Checks if two PrivateRoutes contain equal inner contents. + */ + public long hash() { + long ret = bindings.PrivateRoute_hash(this.ptr); + return ret; + } + + /** + * Checks if two PrivateRoutes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(PrivateRoute b) { + boolean ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + /** * Creates a new (partial) route from a list of hops */ diff --git a/src/main/java/org/ldk/structs/QueryChannelRange.java b/src/main/java/org/ldk/structs/QueryChannelRange.java index 6be4e4ed..3fa87188 100644 --- a/src/main/java/org/ldk/structs/QueryChannelRange.java +++ b/src/main/java/org/ldk/structs/QueryChannelRange.java @@ -97,6 +97,14 @@ public class QueryChannelRange extends CommonBase { return ret; } + /** + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + */ + public byte[] write() { + byte[] ret = bindings.QueryChannelRange_write(this.ptr); + return ret; + } + /** * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ @@ -107,12 +115,4 @@ public class QueryChannelRange extends CommonBase { return ret_hu_conv; } - /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read - */ - public byte[] write() { - byte[] ret = bindings.QueryChannelRange_write(this.ptr); - return ret; - } - } diff --git a/src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java b/src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java new file mode 100644 index 00000000..ac1069d5 --- /dev/null +++ b/src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java @@ -0,0 +1,22 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * A read-only view of [`NetworkGraph`]. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class ReadOnlyNetworkGraph extends CommonBase { + ReadOnlyNetworkGraph(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.ReadOnlyNetworkGraph_free(ptr); } + } + +} diff --git a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java index 30edc977..308438c9 100644 --- a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java +++ b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java @@ -76,6 +76,14 @@ public class ReplyShortChannelIdsEnd extends CommonBase { return ret_hu_conv; } + /** + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + */ + public byte[] write() { + byte[] ret = bindings.ReplyShortChannelIdsEnd_write(this.ptr); + return ret; + } + /** * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ @@ -86,12 +94,4 @@ public class ReplyShortChannelIdsEnd extends CommonBase { return ret_hu_conv; } - /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read - */ - public byte[] write() { - byte[] ret = bindings.ReplyShortChannelIdsEnd_write(this.ptr); - return ret; - } - } diff --git a/src/main/java/org/ldk/structs/Result_COption_TypeZDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_COption_TypeZDecodeErrorZ.java new file mode 100644 index 00000000..8b7feb82 --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_COption_TypeZDecodeErrorZ.java @@ -0,0 +1,76 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +public class Result_COption_TypeZDecodeErrorZ extends CommonBase { + private Result_COption_TypeZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_COption_TypeZDecodeErrorZ_free(ptr); } super.finalize(); + } + + static Result_COption_TypeZDecodeErrorZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_COption_TypeZDecodeErrorZ_result_ok(ptr)) { + return new Result_COption_TypeZDecodeErrorZ_OK(null, ptr); + } else { + return new Result_COption_TypeZDecodeErrorZ_Err(null, ptr); + } + } + public static final class Result_COption_TypeZDecodeErrorZ_OK extends Result_COption_TypeZDecodeErrorZ { + public final Option_TypeZ res; + private Result_COption_TypeZDecodeErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_COption_TypeZDecodeErrorZ_get_ok(ptr); + Option_TypeZ res_hu_conv = Option_TypeZ.constr_from_ptr(res); + res_hu_conv.ptrs_to.add(this); + this.res = res_hu_conv; + } + } + + public static final class Result_COption_TypeZDecodeErrorZ_Err extends Result_COption_TypeZDecodeErrorZ { + public final DecodeError err; + private Result_COption_TypeZDecodeErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + long err = bindings.LDKCResult_COption_TypeZDecodeErrorZ_get_err(ptr); + DecodeError err_hu_conv = new DecodeError(null, err); + err_hu_conv.ptrs_to.add(this); + this.err = err_hu_conv; + } + } + + /** + * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. + */ + public static Result_COption_TypeZDecodeErrorZ ok(Option_TypeZ o) { + long ret = bindings.CResult_COption_TypeZDecodeErrorZ_ok(o.ptr); + if (ret < 1024) { return null; } + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + /** + * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. + */ + public static Result_COption_TypeZDecodeErrorZ err(DecodeError e) { + long ret = bindings.CResult_COption_TypeZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1); + if (ret < 1024) { return null; } + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(e); + return ret_hu_conv; + } + + /** + * Creates a new CResult_COption_TypeZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Result_COption_TypeZDecodeErrorZ clone() { + long ret = bindings.CResult_COption_TypeZDecodeErrorZ_clone(this.ptr); + if (ret < 1024) { return null; } + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.java b/src/main/java/org/ldk/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.java index d7a654d8..ecb812ab 100644 --- a/src/main/java/org/ldk/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.java +++ b/src/main/java/org/ldk/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.java @@ -56,7 +56,7 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ extends CommonB long ret = bindings.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o != null ? Arrays.stream(o).mapToLong(o_conv_34 -> bindings.C2Tuple_BlockHashChannelMonitorZ_new(o_conv_34.a, o_conv_34.b == null ? 0 : o_conv_34.b.ptr & ~1)).toArray() : null); if (ret < 1024) { return null; } Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret); - /* TODO 2 TwoTuple */; + for (TwoTuple o_conv_34: o) { ret_hu_conv.ptrs_to.add(o_conv_34.b); }; return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/Result_NetworkGraphDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_NetworkGraphDecodeErrorZ.java index ee85fbc3..cc81f5ce 100644 --- a/src/main/java/org/ldk/structs/Result_NetworkGraphDecodeErrorZ.java +++ b/src/main/java/org/ldk/structs/Result_NetworkGraphDecodeErrorZ.java @@ -44,11 +44,10 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { /** * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. */ - public static Result_NetworkGraphDecodeErrorZ ok(NetworkGraph o) { - long ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1); + public static Result_NetworkGraphDecodeErrorZ ok(byte[] o_genesis_hash) { + long ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(bindings.NetworkGraph_new(o_genesis_hash)); if (ret < 1024) { return null; } Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(o); return ret_hu_conv; } @@ -63,15 +62,4 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { return ret_hu_conv; } - /** - * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ - public Result_NetworkGraphDecodeErrorZ clone() { - long ret = bindings.CResult_NetworkGraphDecodeErrorZ_clone(this.ptr); - if (ret < 1024) { return null; } - Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret); - return ret_hu_conv; - } - } diff --git a/src/main/java/org/ldk/structs/Result_NoneNoneZ.java b/src/main/java/org/ldk/structs/Result_NoneNoneZ.java new file mode 100644 index 00000000..d1f1e14f --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_NoneNoneZ.java @@ -0,0 +1,65 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +public class Result_NoneNoneZ extends CommonBase { + private Result_NoneNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_NoneNoneZ_free(ptr); } super.finalize(); + } + + static Result_NoneNoneZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_NoneNoneZ_result_ok(ptr)) { + return new Result_NoneNoneZ_OK(null, ptr); + } else { + return new Result_NoneNoneZ_Err(null, ptr); + } + } + public static final class Result_NoneNoneZ_OK extends Result_NoneNoneZ { + private Result_NoneNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + public static final class Result_NoneNoneZ_Err extends Result_NoneNoneZ { + private Result_NoneNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + /** + * Creates a new CResult_NoneNoneZ in the success state. + */ + public static Result_NoneNoneZ ok() { + long ret = bindings.CResult_NoneNoneZ_ok(); + if (ret < 1024) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + /** + * Creates a new CResult_NoneNoneZ in the error state. + */ + public static Result_NoneNoneZ err() { + long ret = bindings.CResult_NoneNoneZ_err(); + if (ret < 1024) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + /** + * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Result_NoneNoneZ clone() { + long ret = bindings.CResult_NoneNoneZ_clone(this.ptr); + if (ret < 1024) { return null; } + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Result_TrustedClosingTransactionNoneZ.java b/src/main/java/org/ldk/structs/Result_TrustedClosingTransactionNoneZ.java new file mode 100644 index 00000000..08c6b9bb --- /dev/null +++ b/src/main/java/org/ldk/structs/Result_TrustedClosingTransactionNoneZ.java @@ -0,0 +1,68 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +public class Result_TrustedClosingTransactionNoneZ extends CommonBase { + private Result_TrustedClosingTransactionNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_TrustedClosingTransactionNoneZ_free(ptr); } super.finalize(); + } + + static Result_TrustedClosingTransactionNoneZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_TrustedClosingTransactionNoneZ_result_ok(ptr)) { + return new Result_TrustedClosingTransactionNoneZ_OK(null, ptr); + } else { + return new Result_TrustedClosingTransactionNoneZ_Err(null, ptr); + } + } + public static final class Result_TrustedClosingTransactionNoneZ_OK extends Result_TrustedClosingTransactionNoneZ { + public final TrustedClosingTransaction res; + private Result_TrustedClosingTransactionNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + long res = bindings.LDKCResult_TrustedClosingTransactionNoneZ_get_ok(ptr); + TrustedClosingTransaction res_hu_conv = new TrustedClosingTransaction(null, res); + res_hu_conv.ptrs_to.add(this); + this.res = res_hu_conv; + } + } + + public static final class Result_TrustedClosingTransactionNoneZ_Err extends Result_TrustedClosingTransactionNoneZ { + private Result_TrustedClosingTransactionNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + /** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + */ + public static Result_TrustedClosingTransactionNoneZ ok(TrustedClosingTransaction o) { + long ret = bindings.CResult_TrustedClosingTransactionNoneZ_ok(o == null ? 0 : o.ptr & ~1); + if (ret < 1024) { return null; } + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(o); + // Due to rust's strict-ownership memory model, in some cases we need to "move" + // an object to pass exclusive ownership to the function being called. + // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object + // at the FFI layer, creating a new object which Rust can claim ownership of + // However, in some cases (eg here), there is no way to clone an object, and thus + // we actually have to pass full ownership to Rust. + // Thus, after ret_hu_conv call, o is reset to null and is now a dummy object. + o.ptr = 0; + return ret_hu_conv; + } + + /** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + */ + public static Result_TrustedClosingTransactionNoneZ err() { + long ret = bindings.CResult_TrustedClosingTransactionNoneZ_err(); + if (ret < 1024) { return null; } + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/Route.java b/src/main/java/org/ldk/structs/Route.java index 5d051553..769f3eb2 100644 --- a/src/main/java/org/ldk/structs/Route.java +++ b/src/main/java/org/ldk/structs/Route.java @@ -20,6 +20,31 @@ public class Route extends CommonBase { if (ptr != 0) { bindings.Route_free(ptr); } } + /** + * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the + * last RouteHop in each path must be the same. + * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the + * destination. Thus, this must always be at least length one. While the maximum length of any + * given path is variable, keeping the length of any path to less than 20 should currently + * ensure it is viable. + */ + public RouteHop[][] get_paths() { + long[][] ret = bindings.Route_get_paths(this.ptr); + RouteHop[][] ret_conv_12_arr = new RouteHop[ret.length][]; + for (int m = 0; m < ret.length; m++) { + long[] ret_conv_12 = ret[m]; + RouteHop[] ret_conv_12_conv_10_arr = new RouteHop[ret_conv_12.length]; + for (int k = 0; k < ret_conv_12.length; k++) { + long ret_conv_12_conv_10 = ret_conv_12[k]; + RouteHop ret_conv_12_conv_10_hu_conv = new RouteHop(null, ret_conv_12_conv_10); + ret_conv_12_conv_10_hu_conv.ptrs_to.add(this); + ret_conv_12_conv_10_arr[k] = ret_conv_12_conv_10_hu_conv; + } + ret_conv_12_arr[m] = ret_conv_12_conv_10_arr; + } + return ret_conv_12_arr; + } + /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the * last RouteHop in each path must be the same. @@ -30,7 +55,7 @@ public class Route extends CommonBase { */ public void set_paths(RouteHop[][] val) { bindings.Route_set_paths(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12 != null ? Arrays.stream(val_conv_12).mapToLong(val_conv_12_conv_10 -> val_conv_12_conv_10 == null ? 0 : val_conv_12_conv_10.ptr & ~1).toArray() : null).toArray(long[][]::new) : null); - /* TODO 2 RouteHop[] */; + for (RouteHop[] val_conv_12: val) { for (RouteHop val_conv_12_conv_10: val_conv_12) { this.ptrs_to.add(val_conv_12_conv_10); }; }; } /** @@ -41,7 +66,7 @@ public class Route extends CommonBase { if (ret < 1024) { return null; } Route ret_hu_conv = new Route(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 RouteHop[] */; + for (RouteHop[] paths_arg_conv_12: paths_arg) { for (RouteHop paths_arg_conv_12_conv_10: paths_arg_conv_12) { ret_hu_conv.ptrs_to.add(paths_arg_conv_12_conv_10); }; }; return ret_hu_conv; } @@ -56,6 +81,44 @@ public class Route extends CommonBase { return ret_hu_conv; } + /** + * Checks if two Routes contain equal inner contents. + */ + public long hash() { + long ret = bindings.Route_hash(this.ptr); + return ret; + } + + /** + * Checks if two Routes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(Route b) { + boolean ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + + /** + * Returns the total amount of fees paid on this [`Route`]. + * + * This doesn't include any extra payment made to the recipient, which can happen in excess of + * the amount passed to [`get_route`]'s `final_value_msat`. + */ + public long get_total_fees() { + long ret = bindings.Route_get_total_fees(this.ptr); + return ret; + } + + /** + * Returns the total amount paid on this [`Route`], excluding the fees. + */ + public long get_total_amount() { + long ret = bindings.Route_get_total_amount(this.ptr); + return ret; + } + /** * Serialize the Route object into a byte array which can be read by Route_read */ diff --git a/src/main/java/org/ldk/structs/RouteHint.java b/src/main/java/org/ldk/structs/RouteHint.java index 33753cf8..fda75424 100644 --- a/src/main/java/org/ldk/structs/RouteHint.java +++ b/src/main/java/org/ldk/structs/RouteHint.java @@ -19,17 +19,6 @@ public class RouteHint extends CommonBase { if (ptr != 0) { bindings.RouteHint_free(ptr); } } - /** - * Checks if two RouteHints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(RouteHint b) { - boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the RouteHint */ @@ -41,4 +30,23 @@ public class RouteHint extends CommonBase { return ret_hu_conv; } + /** + * Checks if two RouteHints contain equal inner contents. + */ + public long hash() { + long ret = bindings.RouteHint_hash(this.ptr); + return ret; + } + + /** + * Checks if two RouteHints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(RouteHint b) { + boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/RouteHintHop.java b/src/main/java/org/ldk/structs/RouteHintHop.java index 26030859..744871ef 100644 --- a/src/main/java/org/ldk/structs/RouteHintHop.java +++ b/src/main/java/org/ldk/structs/RouteHintHop.java @@ -131,17 +131,6 @@ public class RouteHintHop extends CommonBase { return ret_hu_conv; } - /** - * Checks if two RouteHintHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(RouteHintHop b) { - boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the RouteHintHop */ @@ -153,4 +142,23 @@ public class RouteHintHop extends CommonBase { return ret_hu_conv; } + /** + * Checks if two RouteHintHops contain equal inner contents. + */ + public long hash() { + long ret = bindings.RouteHintHop_hash(this.ptr); + return ret; + } + + /** + * Checks if two RouteHintHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(RouteHintHop b) { + boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/RouteHop.java b/src/main/java/org/ldk/structs/RouteHop.java index 94345540..5d130ff2 100644 --- a/src/main/java/org/ldk/structs/RouteHop.java +++ b/src/main/java/org/ldk/structs/RouteHop.java @@ -151,6 +151,25 @@ public class RouteHop extends CommonBase { return ret_hu_conv; } + /** + * Checks if two RouteHops contain equal inner contents. + */ + public long hash() { + long ret = bindings.RouteHop_hash(this.ptr); + return ret; + } + + /** + * Checks if two RouteHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(RouteHop b) { + boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + /** * Serialize the RouteHop object into a byte array which can be read by RouteHop_read */ diff --git a/src/main/java/org/ldk/structs/RoutingFees.java b/src/main/java/org/ldk/structs/RoutingFees.java index f1afc840..d26f518f 100644 --- a/src/main/java/org/ldk/structs/RoutingFees.java +++ b/src/main/java/org/ldk/structs/RoutingFees.java @@ -84,6 +84,14 @@ public class RoutingFees extends CommonBase { return ret_hu_conv; } + /** + * Checks if two RoutingFeess contain equal inner contents. + */ + public long hash() { + long ret = bindings.RoutingFees_hash(this.ptr); + return ret; + } + /** * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ diff --git a/src/main/java/org/ldk/structs/RoutingMessageHandler.java b/src/main/java/org/ldk/structs/RoutingMessageHandler.java index 7b1ea66a..358644dd 100644 --- a/src/main/java/org/ldk/structs/RoutingMessageHandler.java +++ b/src/main/java/org/ldk/structs/RoutingMessageHandler.java @@ -46,10 +46,6 @@ public class RoutingMessageHandler extends CommonBase { * false or returning an Err otherwise. */ Result_boolLightningErrorZ handle_channel_update(ChannelUpdate msg); - /** - * Handle some updates to the route graph that we learned due to an outbound failed payment. - */ - void handle_htlc_fail_channel_update(HTLCFailChannelUpdate update); /** * Gets a subset of the channel announcements and updates required to dump our routing table * to a remote node, starting at the short_channel_id indicated by starting_point and @@ -117,20 +113,16 @@ public class RoutingMessageHandler extends CommonBase { long result = ret != null ? ret.ptr : 0; return result; } - @Override public void handle_htlc_fail_channel_update(long update) { - HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update); - arg.handle_htlc_fail_channel_update(update_hu_conv); - } @Override public long[] get_next_channel_announcements(long starting_point, byte batch_amount) { ThreeTuple[] ret = arg.get_next_channel_announcements(starting_point, batch_amount); long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_63 -> bindings.C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(ret_conv_63.a == null ? 0 : ret_conv_63.a.ptr & ~1, ret_conv_63.b == null ? 0 : ret_conv_63.b.ptr & ~1, ret_conv_63.c == null ? 0 : ret_conv_63.c.ptr & ~1)).toArray() : null; - /* TODO 2 ThreeTuple */; + for (ThreeTuple ret_conv_63: ret) { impl_holder.held.ptrs_to.add(ret_conv_63.a); impl_holder.held.ptrs_to.add(ret_conv_63.b); impl_holder.held.ptrs_to.add(ret_conv_63.c); }; return result; } @Override public long[] get_next_node_announcements(byte[] starting_point, byte batch_amount) { NodeAnnouncement[] ret = arg.get_next_node_announcements(starting_point, batch_amount); long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_18 -> ret_conv_18 == null ? 0 : ret_conv_18.ptr & ~1).toArray() : null; - /* TODO 2 NodeAnnouncement */; + for (NodeAnnouncement ret_conv_18: ret) { impl_holder.held.ptrs_to.add(ret_conv_18); }; return result; } @Override public void sync_routing_table(byte[] their_node_id, long init) { @@ -214,14 +206,6 @@ public class RoutingMessageHandler extends CommonBase { return ret_hu_conv; } - /** - * Handle some updates to the route graph that we learned due to an outbound failed payment. - */ - public void handle_htlc_fail_channel_update(HTLCFailChannelUpdate update) { - bindings.RoutingMessageHandler_handle_htlc_fail_channel_update(this.ptr, update == null ? 0 : update.ptr & ~1); - this.ptrs_to.add(update); - } - /** * Gets a subset of the channel announcements and updates required to dump our routing table * to a remote node, starting at the short_channel_id indicated by starting_point and diff --git a/src/main/java/org/ldk/structs/Sha256.java b/src/main/java/org/ldk/structs/Sha256.java index 76c110a7..8eae3932 100644 --- a/src/main/java/org/ldk/structs/Sha256.java +++ b/src/main/java/org/ldk/structs/Sha256.java @@ -19,17 +19,6 @@ public class Sha256 extends CommonBase { if (ptr != 0) { bindings.Sha256_free(ptr); } } - /** - * Checks if two Sha256s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(Sha256 b) { - boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - /** * Creates a copy of the Sha256 */ @@ -41,4 +30,23 @@ public class Sha256 extends CommonBase { return ret_hu_conv; } + /** + * Checks if two Sha256s contain equal inner contents. + */ + public long hash() { + long ret = bindings.Sha256_hash(this.ptr); + return ret; + } + + /** + * Checks if two Sha256s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(Sha256 b) { + boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/src/main/java/org/ldk/structs/ShutdownScript.java b/src/main/java/org/ldk/structs/ShutdownScript.java index 3d4a8eb8..d97b4f60 100644 --- a/src/main/java/org/ldk/structs/ShutdownScript.java +++ b/src/main/java/org/ldk/structs/ShutdownScript.java @@ -95,7 +95,10 @@ public class ShutdownScript extends CommonBase { } /** - * Generates a P2WSH script pubkey from the given segwit version and program. + * Generates a witness script pubkey from the given segwit version and program. + * + * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or + * [`ShutdownScript::new_p2wsh`] instead. * * # Errors * diff --git a/src/main/java/org/ldk/structs/TrustedClosingTransaction.java b/src/main/java/org/ldk/structs/TrustedClosingTransaction.java new file mode 100644 index 00000000..027f9cd6 --- /dev/null +++ b/src/main/java/org/ldk/structs/TrustedClosingTransaction.java @@ -0,0 +1,54 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * A wrapper on ClosingTransaction indicating that the built bitcoin + * transaction is trusted. + * + * See trust() and verify() functions on CommitmentTransaction. + * + * This structure implements Deref. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class TrustedClosingTransaction extends CommonBase { + TrustedClosingTransaction(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.TrustedClosingTransaction_free(ptr); } + } + + /** + * The pre-built Bitcoin commitment transaction + */ + public byte[] built_transaction() { + byte[] ret = bindings.TrustedClosingTransaction_built_transaction(this.ptr); + return ret; + } + + /** + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. + */ + public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) { + byte[] ret = bindings.TrustedClosingTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis); + return ret; + } + + /** + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. + */ + public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) { + byte[] ret = bindings.TrustedClosingTransaction_sign(this.ptr, funding_key, funding_redeemscript, channel_value_satoshis); + return ret; + } + +} diff --git a/src/main/java/org/ldk/structs/Type.java b/src/main/java/org/ldk/structs/Type.java new file mode 100644 index 00000000..4afa8fb5 --- /dev/null +++ b/src/main/java/org/ldk/structs/Type.java @@ -0,0 +1,96 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * Defines a type identifier for sending messages over the wire. + * + * Messages implementing this trait specify a type and must be [`Writeable`]. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Type extends CommonBase { + final bindings.LDKType bindings_instance; + Type(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } + private Type(bindings.LDKType arg) { + super(bindings.LDKType_new(arg)); + this.ptrs_to.add(arg); + this.bindings_instance = arg; + } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.Type_free(ptr); } super.finalize(); + } + + public static interface TypeInterface { + /** + * Returns the type identifying the message payload. + */ + short type_id(); + /** + * Return a human-readable "debug" string describing this object + */ + String debug_str(); + /** + * Serialize the object into a byte array + */ + byte[] write(); + } + private static class LDKTypeHolder { Type held; } + public static Type new_impl(TypeInterface arg) { + final LDKTypeHolder impl_holder = new LDKTypeHolder(); + impl_holder.held = new Type(new bindings.LDKType() { + @Override public short type_id() { + short ret = arg.type_id(); + return ret; + } + @Override public String debug_str() { + String ret = arg.debug_str(); + return ret; + } + @Override public byte[] write() { + byte[] ret = arg.write(); + return ret; + } + }); + return impl_holder.held; + } + /** + * Returns the type identifying the message payload. + */ + public short type_id() { + short ret = bindings.Type_type_id(this.ptr); + return ret; + } + + /** + * Return a human-readable "debug" string describing this object + */ + public String debug_str() { + String ret = bindings.Type_debug_str(this.ptr); + return ret; + } + + /** + * Serialize the object into a byte array + */ + public byte[] write() { + byte[] ret = bindings.Type_write(this.ptr); + return ret; + } + + /** + * Creates a copy of a Type + */ + public Type clone() { + long ret = bindings.Type_clone(this.ptr); + if (ret < 1024) { return null; } + Type ret_hu_conv = new Type(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java index 237e4010..037957ee 100644 --- a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java @@ -107,7 +107,6 @@ public class UnsignedNodeAnnouncement extends CommonBase { */ public void set_addresses(NetAddress[] val) { bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null); - /* TODO 2 NetAddress */; } /** diff --git a/src/main/java/org/ldk/structs/UtilMethods.java b/src/main/java/org/ldk/structs/UtilMethods.java index e7ea1861..863cce7f 100644 --- a/src/main/java/org/ldk/structs/UtilMethods.java +++ b/src/main/java/org/ldk/structs/UtilMethods.java @@ -60,7 +60,7 @@ public class UtilMethods { ret_hu_conv.ptrs_to.add(arg_tx_broadcaster); ret_hu_conv.ptrs_to.add(arg_logger); ret_hu_conv.ptrs_to.add(arg_default_config); - /* TODO 2 ChannelMonitor */; + for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); }; return ret_hu_conv; } @@ -72,6 +72,15 @@ public class UtilMethods { return ret; } + /** + * Build a closing transaction + */ + public static byte[] build_closing_transaction(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, OutPoint funding_outpoint) { + 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 & ~1); + // this.ptrs_to.add(funding_outpoint); + return ret; + } + /** * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) * from the base secret and the per_commitment_point. @@ -209,8 +218,8 @@ public class UtilMethods { if (ret < 1024) { return null; } Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(network); - /* TODO 2 ChannelDetails */; - /* TODO 2 RouteHint */; + for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); }; + for (RouteHint last_hops_conv_11: last_hops) { ret_hu_conv.ptrs_to.add(last_hops_conv_11); }; ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; } @@ -245,8 +254,8 @@ public class UtilMethods { Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(network); ret_hu_conv.ptrs_to.add(payee_features); - /* TODO 2 ChannelDetails */; - /* TODO 2 RouteHint */; + for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); }; + for (RouteHint last_hops_conv_11: last_hops) { ret_hu_conv.ptrs_to.add(last_hops_conv_11); }; ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; } diff --git a/src/main/java/org/ldk/structs/Watch.java b/src/main/java/org/ldk/structs/Watch.java index 015f7e4f..0e51ba74 100644 --- a/src/main/java/org/ldk/structs/Watch.java +++ b/src/main/java/org/ldk/structs/Watch.java @@ -97,7 +97,6 @@ public class Watch extends CommonBase { @Override public long[] release_pending_monitor_events() { MonitorEvent[] ret = arg.release_pending_monitor_events(); long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_14 -> ret_conv_14.ptr).toArray() : null; - /* TODO 2 MonitorEvent */; return result; } }); diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 6e7e23ff..9e11672d 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -133,7 +133,7 @@ static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) { } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) { - return str_ref_to_java(env, "v0.0.100.2", strlen("v0.0.100.2")); + return str_ref_to_java(env, "v0.0.101.0", strlen("v0.0.101.0")); } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) { return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version())); @@ -614,10 +614,12 @@ static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass cl case 1: return LDKSemanticError_MultiplePaymentHashes; case 2: return LDKSemanticError_NoDescription; case 3: return LDKSemanticError_MultipleDescriptions; - case 4: return LDKSemanticError_MultiplePaymentSecrets; - case 5: return LDKSemanticError_InvalidFeatures; - case 6: return LDKSemanticError_InvalidRecoveryId; - case 7: return LDKSemanticError_InvalidSignature; + case 4: return LDKSemanticError_NoPaymentSecret; + case 5: return LDKSemanticError_MultiplePaymentSecrets; + case 6: return LDKSemanticError_InvalidFeatures; + case 7: return LDKSemanticError_InvalidRecoveryId; + case 8: return LDKSemanticError_InvalidSignature; + case 9: return LDKSemanticError_ImpreciseAmount; } abort(); } @@ -626,10 +628,12 @@ static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL; static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL; static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL; static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL; +static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL; static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL; +static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL; JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) { SemanticError_class = (*env)->NewGlobalRef(env, clz); CHECK(SemanticError_class != NULL); @@ -641,6 +645,8 @@ JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclas CHECK(SemanticError_LDKSemanticError_NoDescription != NULL); SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL); + SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;"); + CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL); SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL); SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;"); @@ -649,6 +655,8 @@ JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclas CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL); SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL); + SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;"); + CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL); } static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) { switch (val) { @@ -660,6 +668,8 @@ static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription); case LDKSemanticError_MultipleDescriptions: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions); + case LDKSemanticError_NoPaymentSecret: + return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret); case LDKSemanticError_MultiplePaymentSecrets: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets); case LDKSemanticError_InvalidFeatures: @@ -668,6 +678,8 @@ static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId); case LDKSemanticError_InvalidSignature: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature); + case LDKSemanticError_ImpreciseAmount: + return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount); default: abort(); } } @@ -972,6 +984,23 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitment uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(val->result_ok); + LDKTrustedClosingTransaction res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok; } @@ -1351,19 +1380,19 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonit } static jclass LDKMonitorEvent_HTLCEvent_class = NULL; static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL; -static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL; -static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL; +static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL; +static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) { LDKMonitorEvent_HTLCEvent_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;")); CHECK(LDKMonitorEvent_HTLCEvent_class != NULL); LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "", "(J)V"); CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL); - LDKMonitorEvent_CommitmentTxBroadcasted_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;")); - CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL); - LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "", "(J)V"); - CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL); + LDKMonitorEvent_CommitmentTxConfirmed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;")); + CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL); + LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "", "(J)V"); + CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL); } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1); @@ -1375,12 +1404,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_ uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1; return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref); } - case LDKMonitorEvent_CommitmentTxBroadcasted: { - LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted; - CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1; - return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref); + case LDKMonitorEvent_CommitmentTxConfirmed: { + LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed; + CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1; + return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref); } default: abort(); } @@ -1439,6 +1468,79 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeT default: abort(); } } +static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL; +static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL; +static jclass LDKNetworkUpdate_ChannelClosed_class = NULL; +static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL; +static jclass LDKNetworkUpdate_NodeFailure_class = NULL; +static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) { + LDKNetworkUpdate_ChannelUpdateMessage_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;")); + CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL); + LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "", "(J)V"); + CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL); + LDKNetworkUpdate_ChannelClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;")); + CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL); + LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "", "(JZ)V"); + CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL); + LDKNetworkUpdate_NodeFailure_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;")); + CHECK(LDKNetworkUpdate_NodeFailure_class != NULL); + LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "", "([BZ)V"); + CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1); + switch(obj->tag) { + case LDKNetworkUpdate_ChannelUpdateMessage: { + LDKChannelUpdate msg_var = obj->channel_update_message.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref); + } + case LDKNetworkUpdate_ChannelClosed: { + return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent); + } + case LDKNetworkUpdate_NodeFailure: { + int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form); + return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent); + } + default: abort(); + } +} +static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL; +static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL; +static jclass LDKCOption_NetworkUpdateZ_None_class = NULL; +static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) { + LDKCOption_NetworkUpdateZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;")); + CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL); + LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL); + LDKCOption_NetworkUpdateZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;")); + CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL); + LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "", "()V"); + CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_NetworkUpdateZ_Some: { + uint64_t some_ref = ((uint64_t)&obj->some) | 1; + return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref); + } + case LDKCOption_NetworkUpdateZ_None: { + return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth); + } + default: abort(); + } +} static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL; static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL; static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL; @@ -1572,50 +1674,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1 default: abort(); } } -static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL; -static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL; -static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL; -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) { - LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;")); - CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL); - LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "", "(J)V"); - CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL); - LDKHTLCFailChannelUpdate_ChannelClosed_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;")); - CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL); - LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "", "(JZ)V"); - CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL); - LDKHTLCFailChannelUpdate_NodeFailure_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;")); - CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL); - LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "", "([BZ)V"); - CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL); -} -JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { - LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1); - switch(obj->tag) { - case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: { - LDKChannelUpdate msg_var = obj->channel_update_message.msg; - CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref); - } - case LDKHTLCFailChannelUpdate_ChannelClosed: { - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent); - } - case LDKHTLCFailChannelUpdate_NodeFailure: { - int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); - (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form); - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent); - } - default: abort(); - } -} static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL; static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL; static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL; @@ -1648,8 +1706,6 @@ static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL; static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL; static jclass LDKMessageSendEvent_HandleError_class = NULL; static jmethodID LDKMessageSendEvent_HandleError_meth = NULL; -static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL; -static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL; static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL; static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL; static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL; @@ -1737,11 +1793,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init CHECK(LDKMessageSendEvent_HandleError_class != NULL); LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "", "([BJ)V"); CHECK(LDKMessageSendEvent_HandleError_meth != NULL); - LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;")); - CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL); - LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "", "(J)V"); - CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL); LDKMessageSendEvent_SendChannelRangeQuery_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;")); CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL); @@ -1900,10 +1951,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1; return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref); } - case LDKMessageSendEvent_PaymentFailureNetworkUpdate: { - uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1; - return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref); - } case LDKMessageSendEvent_SendChannelRangeQuery: { int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form); @@ -2103,6 +2150,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutput uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_NoneNoneZ*)arg)->result_ok; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) { LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); LDKSignature a_ref; @@ -2178,8 +2238,10 @@ typedef struct LDKBaseSign_JCalls { jweak o; jmethodID get_per_commitment_point_meth; jmethodID release_commitment_secret_meth; + jmethodID validate_holder_commitment_meth; jmethodID channel_keys_id_meth; jmethodID sign_counterparty_commitment_meth; + jmethodID validate_counterparty_revocation_meth; jmethodID sign_holder_commitment_and_htlcs_meth; jmethodID sign_justice_revoked_output_meth; jmethodID sign_justice_revoked_htlc_meth; @@ -2253,6 +2315,37 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a } return ret_ref; } +LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKHolderCommitmentTransaction holder_tx_var = *holder_tx; + holder_tx_var = HolderCommitmentTransaction_clone(holder_tx); + CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner; + if (holder_tx_var.is_owned) { + holder_tx_ref |= 1; + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception."); + } + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; @@ -2308,6 +2401,31 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L } return ret_conv; } +LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + int8_tArray secret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception."); + } + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; @@ -2442,7 +2560,7 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c } return ret_conv; } -LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) { +LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -2451,13 +2569,17 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKTransaction closing_tx_var = closing_tx; - int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen); - (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data); - Transaction_free(closing_tx_var); + LDKClosingTransaction closing_tx_var = *closing_tx; + // Warning: we may need a move here but no clone is available for LDKClosingTransaction + CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner; + if (closing_tx_var.is_owned) { + closing_tx_ref |= 1; + } jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception."); @@ -2539,10 +2661,14 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, CHECK(calls->get_per_commitment_point_meth != NULL); calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B"); CHECK(calls->release_commitment_secret_meth != NULL); + calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J"); + CHECK(calls->validate_holder_commitment_meth != NULL); calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B"); CHECK(calls->channel_keys_id_meth != NULL); calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J"); CHECK(calls->sign_counterparty_commitment_meth != NULL); + calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J"); + CHECK(calls->validate_counterparty_revocation_meth != NULL); calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J"); CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL); calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J"); @@ -2551,7 +2677,7 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, CHECK(calls->sign_justice_revoked_htlc_meth != NULL); calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J"); CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL); - calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J"); + calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J"); CHECK(calls->sign_closing_transaction_meth != NULL); calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J"); CHECK(calls->sign_channel_announcement_meth != NULL); @@ -2567,8 +2693,10 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, .this_arg = (void*) calls, .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall, .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall, + .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall, .channel_keys_id = channel_keys_id_LDKBaseSign_jcall, .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall, + .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall, .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall, .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall, .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall, @@ -2601,6 +2729,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1comm return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + LDKHolderCommitmentTransaction holder_tx_conv; + holder_tx_conv.inner = (void*)(holder_tx & (~1)); + holder_tx_conv.is_owned = false; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); int8_tArray ret_arr = (*env)->NewByteArray(env, 32); @@ -2618,6 +2756,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + unsigned char secret_arr[32]; + CHECK((*env)->GetArrayLength(env, secret) == 32); + (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr); + unsigned char (*secret_ref)[32] = &secret_arr; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); LDKHolderCommitmentTransaction commitment_tx_conv; @@ -2681,15 +2830,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart return (uint64_t)ret_conv; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); - LDKTransaction closing_tx_ref; - closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx); - closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes"); - (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data); - closing_tx_ref.data_is_owned = true; + LDKClosingTransaction closing_tx_conv; + closing_tx_conv.inner = (void*)(closing_tx & (~1)); + closing_tx_conv.is_owned = false; LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); - *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref); + *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv); return (uint64_t)ret_conv; } @@ -2833,9 +2980,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErro JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); CHECK(val->result_ok); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(&(*val->contents.result)); - return (uint64_t)ret; + LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *res_ret = Sign_clone(&(*val->contents.result)); + return (uint64_t)res_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); @@ -4018,9 +4165,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdow JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) { @@ -4288,6 +4435,203 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeE uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKType_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID type_id_meth; + jmethodID debug_str_meth; + jmethodID write_meth; +} LDKType_JCalls; +static void LDKType_JCalls_free(void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +uint16_t type_id_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception."); + } + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret; +} +LDKStr debug_str_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception."); + } + LDKStr ret_conv = java_to_owned_str(env, ret); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception."); + } + LDKCVec_u8Z ret_ref; + ret_ref.datalen = (*env)->GetArrayLength(env, ret); + ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_ref; +} +static void LDKType_JCalls_cloned(LDKType* new_obj) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S"); + CHECK(calls->type_id_meth != NULL); + calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;"); + CHECK(calls->debug_str_meth != NULL); + calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B"); + CHECK(calls->write_meth != NULL); + + LDKType ret = { + .this_arg = (void*) calls, + .type_id = type_id_LDKType_jcall, + .debug_str = debug_str_LDKType_jcall, + .write = write_LDKType_jcall, + .cloned = LDKType_JCalls_cloned, + .free = LDKType_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) { + LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType"); + *res_ptr = LDKType_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg); + return ret_val; +} + +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg); + jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len); + Str_free(ret_str); + return ret_conv; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +static jclass LDKCOption_TypeZ_Some_class = NULL; +static jmethodID LDKCOption_TypeZ_Some_meth = NULL; +static jclass LDKCOption_TypeZ_None_class = NULL; +static jmethodID LDKCOption_TypeZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) { + LDKCOption_TypeZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;")); + CHECK(LDKCOption_TypeZ_Some_class != NULL); + LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_TypeZ_Some_meth != NULL); + LDKCOption_TypeZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;")); + CHECK(LDKCOption_TypeZ_None_class != NULL); + LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "", "()V"); + CHECK(LDKCOption_TypeZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_TypeZ_Some: { + LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType"); + *some_ret = Type_clone(&obj->some); + return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_TypeZ_None: { + return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth); + } + default: abort(); + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1; + return res_ref; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok; } @@ -4775,20 +5119,104 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1fro default: abort(); } } +static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL; +static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL; +static jclass LDKClosureReason_HolderForceClosed_class = NULL; +static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL; +static jclass LDKClosureReason_CooperativeClosure_class = NULL; +static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL; +static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL; +static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL; +static jclass LDKClosureReason_ProcessingError_class = NULL; +static jmethodID LDKClosureReason_ProcessingError_meth = NULL; +static jclass LDKClosureReason_DisconnectedPeer_class = NULL; +static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL; +static jclass LDKClosureReason_OutdatedChannelManager_class = NULL; +static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) { + LDKClosureReason_CounterpartyForceClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;")); + CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL); + LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "", "(Ljava/lang/String;)V"); + CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL); + LDKClosureReason_HolderForceClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;")); + CHECK(LDKClosureReason_HolderForceClosed_class != NULL); + LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "", "()V"); + CHECK(LDKClosureReason_HolderForceClosed_meth != NULL); + LDKClosureReason_CooperativeClosure_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;")); + CHECK(LDKClosureReason_CooperativeClosure_class != NULL); + LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "", "()V"); + CHECK(LDKClosureReason_CooperativeClosure_meth != NULL); + LDKClosureReason_CommitmentTxConfirmed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;")); + CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL); + LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "", "()V"); + CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL); + LDKClosureReason_ProcessingError_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;")); + CHECK(LDKClosureReason_ProcessingError_class != NULL); + LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "", "(Ljava/lang/String;)V"); + CHECK(LDKClosureReason_ProcessingError_meth != NULL); + LDKClosureReason_DisconnectedPeer_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;")); + CHECK(LDKClosureReason_DisconnectedPeer_class != NULL); + LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "", "()V"); + CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL); + LDKClosureReason_OutdatedChannelManager_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;")); + CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL); + LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "", "()V"); + CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1); + switch(obj->tag) { + case LDKClosureReason_CounterpartyForceClosed: { + LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg; + jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len); + return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv); + } + case LDKClosureReason_HolderForceClosed: { + return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth); + } + case LDKClosureReason_CooperativeClosure: { + return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth); + } + case LDKClosureReason_CommitmentTxConfirmed: { + return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth); + } + case LDKClosureReason_ProcessingError: { + LDKStr err_str = obj->processing_error.err; + jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len); + return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv); + } + case LDKClosureReason_DisconnectedPeer: { + return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth); + } + case LDKClosureReason_OutdatedChannelManager: { + return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth); + } + default: abort(); + } +} static jclass LDKEvent_FundingGenerationReady_class = NULL; static jmethodID LDKEvent_FundingGenerationReady_meth = NULL; static jclass LDKEvent_PaymentReceived_class = NULL; static jmethodID LDKEvent_PaymentReceived_meth = NULL; static jclass LDKEvent_PaymentSent_class = NULL; static jmethodID LDKEvent_PaymentSent_meth = NULL; -static jclass LDKEvent_PaymentFailed_class = NULL; -static jmethodID LDKEvent_PaymentFailed_meth = NULL; +static jclass LDKEvent_PaymentPathFailed_class = NULL; +static jmethodID LDKEvent_PaymentPathFailed_meth = NULL; static jclass LDKEvent_PendingHTLCsForwardable_class = NULL; static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL; static jclass LDKEvent_SpendableOutputs_class = NULL; static jmethodID LDKEvent_SpendableOutputs_meth = NULL; static jclass LDKEvent_PaymentForwarded_class = NULL; static jmethodID LDKEvent_PaymentForwarded_meth = NULL; +static jclass LDKEvent_ChannelClosed_class = NULL; +static jmethodID LDKEvent_ChannelClosed_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) { LDKEvent_FundingGenerationReady_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;")); @@ -4805,11 +5233,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en CHECK(LDKEvent_PaymentSent_class != NULL); LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "", "([B)V"); CHECK(LDKEvent_PaymentSent_meth != NULL); - LDKEvent_PaymentFailed_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;")); - CHECK(LDKEvent_PaymentFailed_class != NULL); - LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "", "([BZ)V"); - CHECK(LDKEvent_PaymentFailed_meth != NULL); + LDKEvent_PaymentPathFailed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;")); + CHECK(LDKEvent_PaymentPathFailed_class != NULL); + LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "", "([BZJZ[J)V"); + CHECK(LDKEvent_PaymentPathFailed_meth != NULL); LDKEvent_PendingHTLCsForwardable_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;")); CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL); @@ -4825,6 +5253,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en CHECK(LDKEvent_PaymentForwarded_class != NULL); LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "", "(JZ)V"); CHECK(LDKEvent_PaymentForwarded_meth != NULL); + LDKEvent_ChannelClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;")); + CHECK(LDKEvent_ChannelClosed_class != NULL); + LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "", "([BJ)V"); + CHECK(LDKEvent_ChannelClosed_meth != NULL); } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { LDKEvent *obj = (LDKEvent*)(ptr & ~1); @@ -4848,10 +5281,22 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data); return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr); } - case LDKEvent_PaymentFailed: { + case LDKEvent_PaymentPathFailed: { int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data); - return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest); + (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data); + uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1; + LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path; + int64_tArray path_arr = (*env)->NewLongArray(env, path_var.datalen); + int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL); + for (size_t k = 0; k < path_var.datalen; k++) { + LDKRouteHop path_conv_10_var = path_var.data[k]; + CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1; + path_arr_ptr[k] = path_conv_10_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0); + return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr); } case LDKEvent_PendingHTLCsForwardable: { return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable); @@ -4871,6 +5316,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1; return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx); } + case LDKEvent_ChannelClosed: { + int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data); + uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1; + return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, reason_ref); + } default: abort(); } } @@ -5007,24 +5458,162 @@ static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVe } return ret; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { - return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); - CHECK(val->result_ok); - uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1; - return res_ref; +static jclass LDKBalance_ClaimableOnChannelClose_class = NULL; +static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL; +static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL; +static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL; +static jclass LDKBalance_ContentiousClaimable_class = NULL; +static jmethodID LDKBalance_ContentiousClaimable_meth = NULL; +static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL; +static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) { + LDKBalance_ClaimableOnChannelClose_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;")); + CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL); + LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "", "(J)V"); + CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL); + LDKBalance_ClaimableAwaitingConfirmations_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;")); + CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL); + LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "", "(JI)V"); + CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL); + LDKBalance_ContentiousClaimable_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;")); + CHECK(LDKBalance_ContentiousClaimable_class != NULL); + LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "", "(JI)V"); + CHECK(LDKBalance_ContentiousClaimable_meth != NULL); + LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;")); + CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL); + LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "", "(JI)V"); + CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKBalance *obj = (LDKBalance*)(ptr & ~1); + switch(obj->tag) { + case LDKBalance_ClaimableOnChannelClose: { + return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis); + } + case LDKBalance_ClaimableAwaitingConfirmations: { + return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height); + } + case LDKBalance_ContentiousClaimable: { + return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height); + } + case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: { + return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height); + } + default: abort(); + } } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKDecodeError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) { + LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ"); + ret->datalen = (*env)->GetArrayLength(env, elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data"); + int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL); + for (size_t i = 0; i < ret->datalen; i++) { + int64_t arr_elem = java_elems[i]; + LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0); + } + return (uint64_t)ret; +} +static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) { + LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = Balance_clone(&orig->data[i]); + } + return ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1; + return res_ref; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKLightningError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) { + LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + LDKPublicKey a_ref; + CHECK((*env)->GetArrayLength(env, a) == 33); + (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form); + ret->a = a_ref; + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + b_conv = Type_clone(&b_conv); + ret->b = b_conv; + return (uint64_t)ret; +} +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + int8_tArray a_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, a_arr, 0, 33, tuple->a.compressed_form); + return a_arr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + LDKType* b_ret =MALLOC(sizeof(LDKType), "LDKType"); + *b_ret = Type_clone(&tuple->b); + return (uint64_t)b_ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) { + LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ"); + ret->datalen = (*env)->GetArrayLength(env, elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data"); + int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL); + for (size_t i = 0; i < ret->datalen; i++) { + int64_t arr_elem = java_elems[i]; + LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0); + } + return (uint64_t)ret; +} +static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) { + LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]); + } + return ret; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok; } @@ -5137,23 +5726,6 @@ static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCV } return ret; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { - return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; -} -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(val->result_ok); - return *val->contents.result; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKLightningError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t err_ref = (uint64_t)err_var.inner & ~1; - return err_ref; -} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; } @@ -5208,6 +5780,126 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleE uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKAccess_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID get_utxo_meth; +} LDKAccess_JCalls; +static void LDKAccess_JCalls_free(void* this_arg) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception."); + } + LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); + CHECK(calls->get_utxo_meth != NULL); + + LDKAccess ret = { + .this_arg = (void*) calls, + .get_utxo = get_utxo_LDKAccess_jcall, + .free = LDKAccess_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) { + LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); + *res_ptr = LDKAccess_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { + LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); + unsigned char genesis_hash_arr[32]; + CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); + (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr); + unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; + LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); + *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); + return (uint64_t)ret_conv; +} + +static jclass LDKCOption_AccessZ_Some_class = NULL; +static jmethodID LDKCOption_AccessZ_Some_meth = NULL; +static jclass LDKCOption_AccessZ_None_class = NULL; +static jmethodID LDKCOption_AccessZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) { + LDKCOption_AccessZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;")); + CHECK(LDKCOption_AccessZ_Some_class != NULL); + LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_AccessZ_Some_meth != NULL); + LDKCOption_AccessZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;")); + CHECK(LDKCOption_AccessZ_None_class != NULL); + LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "", "()V"); + CHECK(LDKCOption_AccessZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_AccessZ_Some: { + LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + if ((*some_ret).free == LDKAccess_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKAccess_JCalls_cloned(&(*some_ret)); + } + return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_AccessZ_None: { + return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth); + } + default: abort(); + } +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; } @@ -6233,14 +6925,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCr uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; return err_ref; } -typedef struct LDKMessageSendEventsProvider_JCalls { +typedef struct LDKFilter_JCalls { atomic_size_t refcnt; JavaVM *vm; jweak o; - jmethodID get_and_clear_pending_msg_events_meth; -} LDKMessageSendEventsProvider_JCalls; -static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + jmethodID register_tx_meth; + jmethodID register_output_meth; +} LDKFilter_JCalls; +static void LDKFilter_JCalls_free(void* this_arg) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -6256,8 +6949,8 @@ static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { FREE(j_calls); } } -LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; +void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); if (get_jenv_res == JNI_EDETACHED) { @@ -6265,40 +6958,207 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP } else { DO_ASSERT(get_jenv_res == JNI_OK); } + int8_tArray txid_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid); + LDKu8slice script_pubkey_var = script_pubkey; + int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen); + (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data); jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth); + (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception."); + (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception."); } - LDKCVec_MessageSendEventZ ret_constr; - ret_constr.datalen = (*env)->GetArrayLength(env, ret); - if (ret_constr.datalen > 0) - ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); - else - ret_constr.data = NULL; - int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); - for (size_t s = 0; s < ret_constr.datalen; s++) { - int64_t ret_conv_18 = ret_vals[s]; - LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1); - ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1)); - ret_constr.data[s] = ret_conv_18_conv; + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); } - (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); +} +LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKWatchedOutput output_var = output; + CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t output_ref = (uint64_t)output_var.inner; + if (output_var.is_owned) { + output_ref |= 1; + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception."); + } + LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); + ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); if (get_jenv_res == JNI_EDETACHED) { DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); } - return ret_constr; + return ret_conv; } -static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg; +static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); } -static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) { +static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) { jclass c = (*env)->GetObjectClass(env, o); CHECK(c != NULL); - LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); + LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V"); + CHECK(calls->register_tx_meth != NULL); + calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J"); + CHECK(calls->register_output_meth != NULL); + + LDKFilter ret = { + .this_arg = (void*) calls, + .register_tx = register_tx_LDKFilter_jcall, + .register_output = register_output_LDKFilter_jcall, + .free = LDKFilter_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) { + LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); + *res_ptr = LDKFilter_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + unsigned char txid_arr[32]; + CHECK((*env)->GetArrayLength(env, txid) == 32); + (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr); + unsigned char (*txid_ref)[32] = &txid_arr; + LDKu8slice script_pubkey_ref; + script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey); + script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL); + (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); + (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + LDKWatchedOutput output_conv; + output_conv.inner = (void*)(output & (~1)); + output_conv.is_owned = (output & 1) || (output == 0); + output_conv = WatchedOutput_clone(&output_conv); + LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); + *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +static jclass LDKCOption_FilterZ_Some_class = NULL; +static jmethodID LDKCOption_FilterZ_Some_meth = NULL; +static jclass LDKCOption_FilterZ_None_class = NULL; +static jmethodID LDKCOption_FilterZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) { + LDKCOption_FilterZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;")); + CHECK(LDKCOption_FilterZ_Some_class != NULL); + LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_FilterZ_Some_meth != NULL); + LDKCOption_FilterZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;")); + CHECK(LDKCOption_FilterZ_None_class != NULL); + LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "", "()V"); + CHECK(LDKCOption_FilterZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_FilterZ_Some: { + LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + if ((*some_ret).free == LDKFilter_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKFilter_JCalls_cloned(&(*some_ret)); + } + return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_FilterZ_None: { + return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth); + } + default: abort(); + } +} +typedef struct LDKMessageSendEventsProvider_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID get_and_clear_pending_msg_events_meth; +} LDKMessageSendEventsProvider_JCalls; +static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception."); + } + LDKCVec_MessageSendEventZ ret_constr; + ret_constr.datalen = (*env)->GetArrayLength(env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); + else + ret_constr.data = NULL; + int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); + for (size_t s = 0; s < ret_constr.datalen; s++) { + int64_t ret_conv_18 = ret_vals[s]; + LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1); + ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1)); + ret_constr.data[s] = ret_conv_18_conv; + } + (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_constr; +} +static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); atomic_init(&calls->refcnt, 1); DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewWeakGlobalRef(env, o); @@ -6356,7 +7216,7 @@ static void LDKEventHandler_JCalls_free(void* this_arg) { FREE(j_calls); } } -void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { +void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -6365,12 +7225,11 @@ void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *event_copy = event; - uint64_t event_ref = (uint64_t)event_copy; + LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion"); + *ret_event = Event_clone(event); jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref); + (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception."); @@ -6407,7 +7266,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) { LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1); - LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1); + LDKEvent* event_conv = (LDKEvent*)event; (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv); } @@ -6443,11 +7302,11 @@ void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEve } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); - *ret = handler; + LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *handler_ret = handler; jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret); + (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception."); @@ -6492,91 +7351,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pendi (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv); } -typedef struct LDKAccess_JCalls { - atomic_size_t refcnt; - JavaVM *vm; - jweak o; - jmethodID get_utxo_meth; -} LDKAccess_JCalls; -static void LDKAccess_JCalls_free(void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - (*env)->DeleteWeakGlobalRef(env, j_calls->o); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - FREE(j_calls); - } -} -LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash); - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception."); - } - LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - return ret_conv; -} -static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); - CHECK(calls->get_utxo_meth != NULL); - - LDKAccess ret = { - .this_arg = (void*) calls, - .get_utxo = get_utxo_LDKAccess_jcall, - .free = LDKAccess_JCalls_free, - }; - return ret; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) { - LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *res_ptr = LDKAccess_init(env, clz, o); - return (uint64_t)res_ptr; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { - LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); - unsigned char genesis_hash_arr[32]; - CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); - (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr); - unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; - LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); - *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); - return (uint64_t)ret_conv; -} - typedef struct LDKListen_JCalls { atomic_size_t refcnt; JavaVM *vm; @@ -6905,151 +7679,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated( (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height); } -JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1); - LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg); - jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL); - ; - for (size_t i = 0; i < ret_var.datalen; i++) { - int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data); - (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr); - } - FREE(ret_var.data); - return ret_arr; -} - -typedef struct LDKFilter_JCalls { - atomic_size_t refcnt; - JavaVM *vm; - jweak o; - jmethodID register_tx_meth; - jmethodID register_output_meth; -} LDKFilter_JCalls; -static void LDKFilter_JCalls_free(void* this_arg) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - (*env)->DeleteWeakGlobalRef(env, j_calls->o); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - FREE(j_calls); - } -} -void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - int8_tArray txid_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid); - LDKu8slice script_pubkey_var = script_pubkey; - int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen); - (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data); - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception."); - } - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } -} -LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - LDKWatchedOutput output_var = output; - CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t output_ref = (uint64_t)output_var.inner; - if (output_var.is_owned) { - output_ref |= 1; - } - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception."); - } - LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); - ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - return ret_conv; -} -static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V"); - CHECK(calls->register_tx_meth != NULL); - calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J"); - CHECK(calls->register_output_meth != NULL); - - LDKFilter ret = { - .this_arg = (void*) calls, - .register_tx = register_tx_LDKFilter_jcall, - .register_output = register_output_LDKFilter_jcall, - .free = LDKFilter_JCalls_free, - }; - return ret; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) { - LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *res_ptr = LDKFilter_init(env, clz, o); - return (uint64_t)res_ptr; -} -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - unsigned char txid_arr[32]; - CHECK((*env)->GetArrayLength(env, txid) == 32); - (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr); - unsigned char (*txid_ref)[32] = &txid_arr; - LDKu8slice script_pubkey_ref; - script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey); - script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL); - (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); - (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - LDKWatchedOutput output_conv; - output_conv.inner = (void*)(output & (~1)); - output_conv.is_owned = (output & 1) || (output == 0); - output_conv = WatchedOutput_clone(&output_conv); - LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); - *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1); + LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg); + jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL); + ; + for (size_t i = 0; i < ret_var.datalen; i++) { + int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data); + (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr); + } + FREE(ret_var.data); + return ret_arr; } typedef struct LDKPersist_JCalls { @@ -8205,7 +8846,6 @@ typedef struct LDKRoutingMessageHandler_JCalls { jmethodID handle_node_announcement_meth; jmethodID handle_channel_announcement_meth; jmethodID handle_channel_update_meth; - jmethodID handle_htlc_fail_channel_update_meth; jmethodID get_next_channel_announcements_meth; jmethodID get_next_node_announcements_meth; jmethodID sync_routing_table_meth; @@ -8324,27 +8964,6 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc } return ret_conv; } -void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) { - LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - uint64_t ret_update = (uint64_t)update; - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception."); - } - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *env; @@ -8595,8 +9214,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *en CHECK(calls->handle_channel_announcement_meth != NULL); calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J"); CHECK(calls->handle_channel_update_meth != NULL); - calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V"); - CHECK(calls->handle_htlc_fail_channel_update_meth != NULL); calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J"); CHECK(calls->get_next_channel_announcements_meth != NULL); calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J"); @@ -8617,7 +9234,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *en .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall, - .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall, .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall, .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall, .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall, @@ -8661,128 +9277,363 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv); return (uint64_t)ret_conv; } - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = false; - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv); - return (uint64_t)ret_conv; + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = false; + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t l = 0; l < ret_var.datalen; l++) { + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); + *ret_conv_63_ref = ret_var.data[l]; + ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey starting_point_ref; + CHECK((*env)->GetArrayLength(env, starting_point) == 33); + (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form); + LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t s = 0; s < ret_var.datalen; s++) { + LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s]; + CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner; + if (ret_conv_18_var.is_owned) { + ret_conv_18_ref |= 1; + } + ret_arr_ptr[s] = ret_conv_18_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKInit init_conv; + init_conv.inner = (void*)(init & (~1)); + init_conv.is_owned = false; + (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKReplyChannelRange msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ReplyChannelRange_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKReplyShortChannelIdsEnd msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKQueryChannelRange msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = QueryChannelRange_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKQueryShortChannelIds msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = QueryShortChannelIds_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageReader_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID read_meth; +} LDKCustomMessageReader_JCalls; +static void LDKCustomMessageReader_JCalls_free(void* this_arg) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKu8slice buffer_var = buffer; + int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen); + (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception."); + } + LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J"); + CHECK(calls->read_meth != NULL); + + LDKCustomMessageReader ret = { + .this_arg = (void*) calls, + .read = read_LDKCustomMessageReader_jcall, + .free = LDKCustomMessageReader_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) { + LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *res_ptr = LDKCustomMessageReader_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) { + LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1); + LDKu8slice buffer_ref; + buffer_ref.datalen = (*env)->GetArrayLength(env, buffer); + buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref); + (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageHandler_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + LDKCustomMessageReader_JCalls* CustomMessageReader; + jmethodID handle_custom_message_meth; + jmethodID get_and_clear_pending_msg_meth; +} LDKCustomMessageHandler_JCalls; +static void LDKCustomMessageHandler_JCalls_free(void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType"); + *msg_ret = msg; + int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception."); + } + LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception."); + } + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr; + ret_constr.datalen = (*env)->GetArrayLength(env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + ret_constr.data = NULL; + int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); + for (size_t y = 0; y < ret_constr.datalen; y++) { + int64_t ret_conv_24 = ret_vals[y]; + LDKC2Tuple_PublicKeyTypeZ ret_conv_24_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_24) & ~1); + ret_conv_24_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_24) & ~1)); + ret_constr.data[y] = ret_conv_24_conv; + } + (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_constr; +} +static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); + atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release); } +static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J"); + CHECK(calls->handle_custom_message_meth != NULL); + calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J"); + CHECK(calls->get_and_clear_pending_msg_meth != NULL); -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update; - (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv); + LDKCustomMessageHandler ret = { + .this_arg = (void*) calls, + .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall, + .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall, + .free = LDKCustomMessageHandler_JCalls_free, + .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader), + }; + calls->CustomMessageReader = ret.CustomMessageReader.this_arg; + return ret; } - -JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); - int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); - int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); - for (size_t l = 0; l < ret_var.datalen; l++) { - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); - *ret_conv_63_ref = ret_var.data[l]; - ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref; +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) { + LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) { + LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1); + uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader; + DO_ASSERT((res_ptr & 1) == 0); + return (int64_t)(res_ptr | 1); +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1); + if (msg_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&msg_conv); } - (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); - FREE(ret_var.data); - return ret_arr; + LDKPublicKey sender_node_id_ref; + CHECK((*env)->GetArrayLength(env, sender_node_id) == 33); + (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref); + return (uint64_t)ret_conv; } -JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey starting_point_ref; - CHECK((*env)->GetArrayLength(env, starting_point) == 33); - (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form); - LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg); int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); - for (size_t s = 0; s < ret_var.datalen; s++) { - LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s]; - CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner; - if (ret_conv_18_var.is_owned) { - ret_conv_18_ref |= 1; - } - ret_arr_ptr[s] = ret_conv_18_ref; + for (size_t y = 0; y < ret_var.datalen; y++) { + LDKC2Tuple_PublicKeyTypeZ* ret_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_conv_24_ref = ret_var.data[y]; + ret_arr_ptr[y] = (uint64_t)ret_conv_24_ref; } (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); FREE(ret_var.data); return ret_arr; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKInit init_conv; - init_conv.inner = (void*)(init & (~1)); - init_conv.is_owned = false; - (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKReplyChannelRange msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ReplyChannelRange_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKReplyShortChannelIdsEnd msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKQueryChannelRange msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = QueryChannelRange_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKQueryShortChannelIds msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = QueryShortChannelIds_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - typedef struct LDKSocketDescriptor_JCalls { atomic_size_t refcnt; JavaVM *vm; @@ -9510,6 +10361,29 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTra return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) { + LDKTrustedClosingTransaction o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) { + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_err(); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_TrustedClosingTransactionNoneZ_free(_res_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKCommitmentTransaction o_conv; o_conv.inner = (void*)(o & (~1)); @@ -9913,6 +10787,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErro JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1); + o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1)); LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10046,6 +10921,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIE JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1)); LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -10074,6 +10950,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1); + o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1)); + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_NetworkUpdateZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig; + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { LDKCVec_SpendableOutputDescriptorZ _res_constr; _res_constr.datalen = (*env)->GetArrayLength(env, _res); @@ -10288,6 +11195,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutpu JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1); + o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1)); LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ"); *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10317,6 +11225,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDes return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_ok(); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_err(); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneNoneZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1); + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1); LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); @@ -10355,6 +11289,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1Signat JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1)); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10731,6 +11666,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok( JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10794,6 +11730,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFai JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ"); *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -10824,6 +11761,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPayment JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -10898,6 +11836,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIEr JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10958,6 +11897,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManag JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -11048,6 +11988,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&o_conv); + } + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_TypeZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig; + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { + LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1); + o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1)); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { + LDKDecodeError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = DecodeError_clone(&e_conv); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_COption_TypeZDecodeErrorZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) { LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o); LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ"); @@ -11688,6 +12694,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) { LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1); + b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1)); LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ"); *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv); return (uint64_t)ret_ref; @@ -11773,8 +12780,27 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr); } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { + LDKCVec_BalanceZ _res_constr; + _res_constr.datalen = (*env)->GetArrayLength(env, _res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements"); + else + _res_constr.data = NULL; + int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL); + for (size_t j = 0; j < _res_constr.datalen; j++) { + int64_t _res_conv_9 = _res_vals[j]; + LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1); + FREE((void*)_res_conv_9); + _res_constr.data[j] = _res_conv_9_conv; + } + (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0); + CVec_BalanceZ_free(_res_constr); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -11797,6 +12823,82 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashCha CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) { + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_ok(); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { + LDKLightningError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = LightningError_clone(&e_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneLightningErrorZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_clone(orig_conv); + return (uint64_t)ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) { + LDKPublicKey a_ref; + CHECK((*env)->GetArrayLength(env, a) == 33); + (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form); + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + if (b_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&b_conv); + } + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv); + return (uint64_t)ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + C2Tuple_PublicKeyTypeZ_free(_res_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { + LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr; + _res_constr.datalen = (*env)->GetArrayLength(env, _res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + _res_constr.data = NULL; + int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL); + for (size_t y = 0; y < _res_constr.datalen; y++) { + int64_t _res_conv_24 = _res_vals[y]; + LDKC2Tuple_PublicKeyTypeZ _res_conv_24_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_24) & ~1); + FREE((void*)_res_conv_24); + _res_constr.data[y] = _res_conv_24_conv; + } + (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0); + CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) { LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); *ret_conv = CResult_boolLightningErrorZ_ok(o); @@ -11896,36 +12998,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free( CVec_NodeAnnouncementZ_free(_res_constr); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) { - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_ok(); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { - LDKLightningError e_conv; - e_conv.inner = (void*)(e & (~1)); - e_conv.is_owned = (e & 1) || (e == 0); - e_conv = LightningError_clone(&e_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { - if ((_res & 1) != 0) return; - LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); - FREE((void*)_res); - CResult_NoneLightningErrorZ_free(_res_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) { LDKCVec_PublicKeyZ _res_constr; _res_constr.datalen = (*env)->GetArrayLength(env, _res); @@ -12037,6 +13109,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErro return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKAccess_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKAccess_JCalls_cloned(&o_conv); + } + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_AccessZ_free(_res_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKDirectionalChannelInfo o_conv; o_conv.inner = (void*)(o & (~1)); @@ -12227,7 +13325,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecode LDKNetworkGraph o_conv; o_conv.inner = (void*)(o & (~1)); o_conv.is_owned = (o & 1) || (o == 0); - o_conv = NetworkGraph_clone(&o_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -12250,15 +13348,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErr CResult_NetworkGraphDecodeErrorZ_free(_res_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1); - LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); - *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z"); *ret_conv = CResult_NetAddressu8Z_ok(o_conv); return (uint64_t)ret_conv; @@ -12286,6 +13378,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clo JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1); + o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1)); LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ"); *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -12317,6 +13410,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddres JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ"); *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -13522,6 +14616,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1); + e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1)); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -13541,6 +14636,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKFilter_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKFilter_JCalls_cloned(&o_conv); + } + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_FilterZ_free(_res_conv); +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1); @@ -13579,6 +14700,81 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + ClosureReason_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKClosureReason* orig_conv = (LDKClosureReason*)orig; + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) { + LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_holder_force_closed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_cooperative_closure(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_commitment_tx_confirmed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) { + LDKStr err_conv = java_to_owned_str(env, err); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_processing_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_disconnected_peer(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_outdated_channel_manager(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKClosureReason* obj_conv = (LDKClosureReason*)obj; + LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1); @@ -13613,6 +14809,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1); + purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -13629,12 +14826,30 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path) { LDKThirtyTwoBytes payment_hash_ref; CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); + LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1); + network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1)); + LDKCVec_RouteHopZ path_constr; + path_constr.datalen = (*env)->GetArrayLength(env, path); + if (path_constr.datalen > 0) + path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + path_constr.data = NULL; + int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL); + for (size_t k = 0; k < path_constr.datalen; k++) { + int64_t path_conv_10 = path_vals[k]; + LDKRouteHop path_conv_10_conv; + path_conv_10_conv.inner = (void*)(path_conv_10 & (~1)); + path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0); + path_conv_10_conv = RouteHop_clone(&path_conv_10_conv); + path_constr.data[k] = path_conv_10_conv; + } + (*env)->ReleaseLongArrayElements(env, path, path_vals, 0); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest); + *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -13669,12 +14884,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) { LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1); + fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t reason) { + LDKThirtyTwoBytes channel_id_ref; + CHECK((*env)->GetArrayLength(env, channel_id) == 32); + (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data); + LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1); + reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1)); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_channel_closed(channel_id_ref, reason_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKEvent* obj_conv = (LDKEvent*)obj; LDKCVec_u8Z ret_var = Event_write(obj_conv); @@ -13909,20 +15137,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1e CHECK((*env)->GetArrayLength(env, node_id) == 33); (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1); + action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1)); LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) { - LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1); - LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); - *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) { LDKPublicKey node_id_ref; CHECK((*env)->GetArrayLength(env, node_id) == 33); @@ -14991,16 +16212,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) { - LDKFilter *chain_source_conv_ptr = NULL; - if (chain_source != 0) { - LDKFilter chain_source_conv; - chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1); - if (chain_source_conv.free == LDKFilter_JCalls_free) { + LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ + if (chain_source_conv.tag == LDKCOption_FilterZ_Some) { + // Manually implement clone for Java trait instances + if (chain_source_conv.some.free == LDKFilter_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKFilter_JCalls_cloned(&chain_source_conv); + LDKFilter_JCalls_cloned(&chain_source_conv.some); } - chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *chain_source_conv_ptr = chain_source_conv; } LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1); if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) { @@ -15022,7 +16241,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKPersist_JCalls_cloned(&persister_conv); } - LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv); + LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -15032,40 +16251,74 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e return ret_ref; } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) { + LDKChainMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_ChannelDetailsZ ignored_channels_constr; + ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels); + if (ignored_channels_constr.datalen > 0) + ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + ignored_channels_constr.data = NULL; + int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL); + for (size_t q = 0; q < ignored_channels_constr.datalen; q++) { + int64_t ignored_channels_conv_16 = ignored_channels_vals[q]; + LDKChannelDetails ignored_channels_conv_16_conv; + ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1)); + ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0); + ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv); + ignored_channels_constr.data[q] = ignored_channels_conv_16_conv; + } + (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0); + LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChainMonitor_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChainMonitor_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChainMonitor_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch"); - *ret = ChainMonitor_as_Watch(&this_arg_conv); - return (uint64_t)ret; + LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch"); + *ret_ret = ChainMonitor_as_Watch(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChainMonitor_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -15188,13 +16441,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNI return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) { LDKOutPoint a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); a_conv = OutPoint_clone(&a_conv); LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); - *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv); + *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -15241,6 +16494,56 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *en return (uint64_t)ret_conv; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Balance_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBalance* orig_conv = (LDKBalance*)orig; + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKBalance* a_conv = (LDKBalance*)a; + LDKBalance* b_conv = (LDKBalance*)b; + jboolean ret_val = Balance_eq(a_conv, b_conv); + return ret_val; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelMonitor this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -15603,6 +16906,24 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1be return ret_ref; } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -15810,6 +17131,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -15875,6 +17197,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33); (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKPublicKey revocation_pubkey_arg_ref; CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33); (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form); @@ -15963,6 +17286,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_ this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -16006,6 +17330,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0); outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKThirtyTwoBytes channel_keys_id_arg_ref; CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32); (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data); @@ -16075,6 +17400,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1 outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0); outpoint_conv = OutPoint_clone(&outpoint_conv); LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1); + output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1)); LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -16131,9 +17457,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jc JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(orig_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = Sign_clone(orig_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -16421,18 +17747,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSig LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); - *ret = InMemorySigner_as_BaseSign(&this_arg_conv); - return (uint64_t)ret; + LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); + *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) { LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = InMemorySigner_as_Sign(&this_arg_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = InMemorySigner_as_Sign(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) { @@ -16541,9 +17867,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterf LDKKeysManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); - *ret = KeysManager_as_KeysInterface(&this_arg_conv); - return (uint64_t)ret; + LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); + *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -16631,6 +17957,83 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKCounterpartyForwardingInfo this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + CounterpartyForwardingInfo_free(this_obj_conv); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val); +} + +JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) { + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCounterpartyForwardingInfo orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -16697,6 +18100,53 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unsp ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = CounterpartyForwardingInfo_clone(&val_conv); + ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg) { + LDKPublicKey node_id_arg_ref; + CHECK((*env)->GetArrayLength(env, node_id_arg) == 33); + (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form); + LDKInitFeatures features_arg_conv; + features_arg_conv.inner = (void*)(features_arg & (~1)); + features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0); + features_arg_conv = InitFeatures_clone(&features_arg_conv); + LDKCounterpartyForwardingInfo forwarding_info_arg_conv; + forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1)); + forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0); + forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv); + LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKChannelCounterparty orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -16802,6 +18252,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } @@ -16835,6 +18286,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendab this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } @@ -16898,6 +18350,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmat this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); } @@ -16916,6 +18369,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1cl this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); } @@ -16992,9 +18446,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1)); LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1)); LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1)); LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -17036,6 +18493,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) { LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1); + a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1)); LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); *ret_copy = PaymentSendFailure_parameter_error(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -17407,6 +18865,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ"); *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_ref; @@ -17420,6 +18879,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_conv; @@ -17429,36 +18889,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Message LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChannelManager_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChannelManager_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChannelManager_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChannelManager_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChannelManager_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) { @@ -17494,9 +18954,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Channel LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) { @@ -21321,12 +22781,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JN this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1); + val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1)); LightningError_set_action(&this_ptr_conv, val_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) { LDKStr err_arg_conv = java_to_owned_str(env, err_arg); LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1); + action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1)); LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -21358,6 +22820,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv CommitmentUpdate_free(this_obj_conv); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t p = 0; p < ret_var.datalen; p++) { + LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p]; + CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner; + if (ret_conv_15_var.is_owned) { + ret_conv_15_ref |= 1; + } + ret_arr_ptr[p] = ret_conv_15_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21381,6 +22865,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t t = 0; t < ret_var.datalen; t++) { + LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t]; + CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner; + if (ret_conv_19_var.is_owned) { + ret_conv_19_ref |= 1; + } + ret_arr_ptr[t] = ret_conv_19_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21404,6 +22910,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q]; + CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner; + if (ret_conv_16_var.is_owned) { + ret_conv_16_ref |= 1; + } + ret_arr_ptr[q] = ret_conv_16_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21427,6 +22955,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t z = 0; z < ret_var.datalen; z++) { + LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z]; + CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner; + if (ret_conv_25_var.is_owned) { + ret_conv_25_ref |= 1; + } + ret_arr_ptr[z] = ret_conv_25_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21597,49 +23147,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { - if ((this_ptr & 1) != 0) return; - LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1); - FREE((void*)this_ptr); - HTLCFailChannelUpdate_free(this_ptr_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig; - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_clone(orig_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) { - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ChannelUpdate_clone(&msg_conv); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) { - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) { - LDKPublicKey node_id_ref; - CHECK((*env)->GetArrayLength(env, node_id) == 33); - (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1); @@ -22242,16 +23749,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1w return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); - *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; -} - JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKReplyShortChannelIdsEnd obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22263,6 +23760,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); + *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) { LDKQueryChannelRange this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -22271,16 +23778,6 @@ JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blo return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); - *ret_conv = QueryChannelRange_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; -} - JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKQueryChannelRange obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22292,6 +23789,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1writ return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); + *ret_conv = QueryChannelRange_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = (*env)->GetArrayLength(env, ser); @@ -22313,6 +23820,17 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1writ return ret_arr; } +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKGossipTimestampFilter obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = (*env)->GetArrayLength(env, ser); @@ -22323,15 +23841,11 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read return (uint64_t)ret_conv; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) { - LDKGossipTimestampFilter obj_conv; - obj_conv.inner = (void*)(obj & (~1)); - obj_conv.is_owned = false; - LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv); - int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); - (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); - CVec_u8Z_free(ret_var); - return ret_arr; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageHandler_free(this_ptr_conv); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22356,18 +23870,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_ LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22392,18 +23924,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_ LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22476,9 +24008,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1); - LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); - *ret = SocketDescriptor_clone(orig_conv); - return (uint64_t)ret; + LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); + *ret_ret = SocketDescriptor_clone(orig_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -22542,7 +24074,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, PeerManager_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) { LDKMessageHandler message_handler_conv; message_handler_conv.inner = (void*)(message_handler & (~1)); message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0); @@ -22559,7 +24091,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *en // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv); + LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1); + if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv); + } + LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22682,6 +24219,26 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secr return ret_arr; } +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + Transaction_free(ret_var); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) { LDKPublicKey per_commitment_point_ref; CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33); @@ -23195,6 +24752,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1t this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv); } @@ -23203,6 +24761,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32); (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data); LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1); + transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1)); LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -23851,11 +25410,106 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_ return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKBuiltCommitmentTransaction orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBuiltCommitmentTransaction orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKBuiltCommitmentTransaction obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ"); + *ret_conv = BuiltCommitmentTransaction_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKBuiltCommitmentTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); + funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); + int8_tArray ret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); + (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); + return ret_arr; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKBuiltCommitmentTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + unsigned char funding_key_arr[32]; + CHECK((*env)->GetArrayLength(env, funding_key) == 32); + (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr); + unsigned char (*funding_key_ref)[32] = &funding_key_arr; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); + funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); + int8_tArray ret_arr = (*env)->NewByteArray(env, 64); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); + (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); + return ret_arr; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ClosingTransaction_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23865,42 +25519,88 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_ return ret_ref; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) { - LDKBuiltCommitmentTransaction obj_conv; - obj_conv.inner = (void*)(obj & (~1)); - obj_conv.is_owned = false; - LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv); int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); - CVec_u8Z_free(ret_var); return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ"); - *ret_conv = BuiltCommitmentTransaction_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + return ret_arr; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { - LDKBuiltCommitmentTransaction this_arg_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKTrustedClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + TrustedClosingTransaction_free(this_obj_conv); +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + Transaction_free(ret_var); + return ret_arr; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKu8slice funding_redeemscript_ref; funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); int8_tArray ret_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); return ret_arr; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { - LDKBuiltCommitmentTransaction this_arg_conv; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; unsigned char funding_key_arr[32]; @@ -23911,7 +25611,7 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransact funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); int8_tArray ret_arr = (*env)->NewByteArray(env, 64); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); return ret_arr; } @@ -24243,6 +25943,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKInitFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) { LDKNodeFeatures ret_var = NodeFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24265,6 +25973,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNodeFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) { LDKChannelFeatures ret_var = ChannelFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24287,6 +26003,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIE return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) { LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24309,6 +26033,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIE return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKInvoiceFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) { LDKInitFeatures this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -24604,6 +26336,27 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compat return ret_val; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageReader_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1); + LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType"); + *ret_ret = Type_clone(orig_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Type_free(this_ptr_conv); +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -24761,6 +26514,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHop_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHop_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRouteHop obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -24789,6 +26561,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclas Route_free(this_obj_conv); } +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKRoute this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv); + jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL); + ; + for (size_t m = 0; m < ret_var.datalen; m++) { + LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m]; + int64_tArray ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen); + int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL); + for (size_t k = 0; k < ret_conv_12_var.datalen; k++) { + LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k]; + CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner; + if (ret_conv_12_conv_10_var.is_owned) { + ret_conv_12_conv_10_ref |= 1; + } + ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0); + FREE(ret_conv_12_var.data); + (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr); + } + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) { LDKRoute this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -24873,6 +26674,41 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, j return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Route_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = Route_eq(&a_conv, &b_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_fees(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_amount(&this_arg_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRoute obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -24901,17 +26737,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, j RouteHint_free(this_obj_conv); } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKRouteHint a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHint b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKRouteHint orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24926,6 +26751,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *en return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHint o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHint_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHint a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHint b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKRouteHintHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -25022,6 +26866,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minim this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv); } @@ -25040,6 +26885,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maxim this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -25052,7 +26898,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); fees_arg_conv = RoutingFees_clone(&fees_arg_conv); LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1); + htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1)); LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -25063,17 +26911,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e return ret_ref; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKRouteHintHop a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHintHop b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKRouteHintHop orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -25088,6 +26925,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHintHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHintHop_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHintHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHintHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) { LDKPublicKey our_node_id_ref; CHECK((*env)->GetArrayLength(env, our_node_id) == 33); @@ -25211,55 +27067,86 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env NetworkGraph_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKNetworkGraph orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKReadOnlyNetworkGraph this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ReadOnlyNetworkGraph_free(this_obj_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + NetworkUpdate_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig; + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKLockedNetworkGraph this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - LockedNetworkGraph_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_update_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKNetGraphMsgHandler this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - NetGraphMsgHandler_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) { + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) { - LDKThirtyTwoBytes genesis_hash_ref; - CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); - (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data); - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { - // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); - } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - if (logger_conv.free == LDKLogger_JCalls_free) { - // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKLogger_JCalls_cloned(&logger_conv); - } - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) { + LDKPublicKey node_id_ref; + CHECK((*env)->GetArrayLength(env, node_id) == 33); + (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj; + LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNetGraphMsgHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKNetGraphMsgHandler this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + NetGraphMsgHandler_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -25269,28 +27156,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNI return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) { - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) { + LDKNetworkGraph network_graph_conv; + network_graph_conv.inner = (void*)(network_graph & (~1)); + network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); if (logger_conv.free == LDKLogger_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKNetworkGraph network_graph_conv; - network_graph_conv.inner = (void*)(network_graph & (~1)); - network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); - network_graph_conv = NetworkGraph_clone(&network_graph_conv); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv); + LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -25304,64 +27200,34 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKNetGraphMsgHandler this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKLockedNetworkGraph this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; } - return ret_ref; + NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -25446,6 +27312,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1h this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -25501,6 +27368,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1l JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) { LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRoutingFees fees_arg_conv; fees_arg_conv.inner = (void*)(fees_arg & (~1)); fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); @@ -25689,6 +27557,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sa this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv); } @@ -25737,6 +27606,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *en two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0); two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv); LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1); + capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1)); LDKChannelAnnouncement announcement_message_arg_conv; announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1)); announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0); @@ -25859,6 +27729,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRoutingFees o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RoutingFees_hash(&o_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRoutingFees obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -26261,6 +28139,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *e return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -26292,19 +28184,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1chann LDKChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -26315,19 +28205,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1chann LDKUnsignedChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -26338,6 +28226,16 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1 NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent); } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKPublicKey _node_id_ref; + CHECK((*env)->GetArrayLength(env, _node_id) == 33); + (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form); + NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -26419,9 +28317,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Pe LDKFilesystemPersister this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist"); - *ret = FilesystemPersister_as_Persist(&this_arg_conv); - return (uint64_t)ret; + LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist"); + *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -26438,7 +28336,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free( ChannelManagerPersister_free(this_ptr_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t peer_manager, int64_t logger) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) { LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1); if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. @@ -26455,6 +28353,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start( LDKChannelManager channel_manager_conv; channel_manager_conv.inner = (void*)(channel_manager & (~1)); channel_manager_conv.is_owned = false; + LDKNetGraphMsgHandler net_graph_msg_handler_conv; + net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1)); + net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0); LDKPeerManager peer_manager_conv; peer_manager_conv.inner = (void*)(peer_manager & (~1)); peer_manager_conv.is_owned = false; @@ -26463,7 +28364,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start( // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv); + LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26777,6 +28678,12 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env return ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKCurrency* o_conv = (LDKCurrency*)(o & ~1); + int64_t ret_val = Currency_hash(o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKCurrency* a_conv = (LDKCurrency*)(a & ~1); LDKCurrency* b_conv = (LDKCurrency*)(b & ~1); @@ -26791,6 +28698,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jcla Sha256_free(this_obj_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKSha256 orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKSha256 ret_var = Sha256_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKSha256 o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Sha256_hash(&o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKSha256 a_conv; a_conv.inner = (void*)(a & (~1)); @@ -26802,11 +28731,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jc return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKSha256 orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKDescription this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + Description_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKDescription orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKSha256 ret_var = Sha256_clone(&orig_conv); + LDKDescription ret_var = Description_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26816,11 +28752,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKDescription this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - Description_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKDescription o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Description_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26834,11 +28771,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *en return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKDescription orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKPayeePubKey this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PayeePubKey_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKPayeePubKey orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKDescription ret_var = Description_clone(&orig_conv); + LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26848,11 +28792,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv * return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKPayeePubKey this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PayeePubKey_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKPayeePubKey o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PayeePubKey_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26866,11 +28811,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *en return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKPayeePubKey orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKExpiryTime this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ExpiryTime_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKExpiryTime orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); + LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26880,11 +28832,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv * return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKExpiryTime this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ExpiryTime_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKExpiryTime o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = ExpiryTime_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26898,11 +28851,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKExpiryTime orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKMinFinalCltvExpiry this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + MinFinalCltvExpiry_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKMinFinalCltvExpiry orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); + LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26912,11 +28872,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *e return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKMinFinalCltvExpiry this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - MinFinalCltvExpiry_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKMinFinalCltvExpiry o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26930,20 +28891,6 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNI return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKMinFinalCltvExpiry orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1); @@ -26991,6 +28938,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIE return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKFallback* o_conv = (LDKFallback*)o; + int64_t ret_val = Fallback_hash(o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKFallback* a_conv = (LDKFallback*)a; LDKFallback* b_conv = (LDKFallback*)b; @@ -27005,17 +28958,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv InvoiceSignature_free(this_obj_conv); } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKInvoiceSignature a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKInvoiceSignature b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKInvoiceSignature orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -27030,24 +28972,24 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNI return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKPrivateRoute this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PrivateRoute_free(this_obj_conv); -} - -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKPrivateRoute a_conv; +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKInvoiceSignature a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = false; - LDKPrivateRoute b_conv; + LDKInvoiceSignature b_conv; b_conv.inner = (void*)(b & (~1)); b_conv.is_owned = false; - jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); return ret_val; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKPrivateRoute this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PrivateRoute_free(this_obj_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKPrivateRoute orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -27062,6 +29004,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKPrivateRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PrivateRoute_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKPrivateRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKPrivateRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) { LDKSignedRawInvoice this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -27618,6 +29579,11 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1des return ret_conv; } +JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) { + jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret()); + return ret_conv; +} + JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) { jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets()); return ret_conv; @@ -27638,6 +29604,11 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1sign return ret_conv; } +JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) { + jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount()); + return ret_conv; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1); LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1); @@ -27709,6 +29680,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1chan } LDKCurrency network_conv = LDKCurrency_from_java(env, network); LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1); + amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1)); LDKStr description_conv = java_to_owned_str(env, description); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv); diff --git a/src/main/jni/bindings.c.body b/src/main/jni/bindings.c.body index d28c89d6..ed316a86 100644 --- a/src/main/jni/bindings.c.body +++ b/src/main/jni/bindings.c.body @@ -131,7 +131,7 @@ static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) { } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) { - return str_ref_to_java(env, "v0.0.100.2", strlen("v0.0.100.2")); + return str_ref_to_java(env, "v0.0.101.0", strlen("v0.0.101.0")); } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) { return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version())); @@ -612,10 +612,12 @@ static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass cl case 1: return LDKSemanticError_MultiplePaymentHashes; case 2: return LDKSemanticError_NoDescription; case 3: return LDKSemanticError_MultipleDescriptions; - case 4: return LDKSemanticError_MultiplePaymentSecrets; - case 5: return LDKSemanticError_InvalidFeatures; - case 6: return LDKSemanticError_InvalidRecoveryId; - case 7: return LDKSemanticError_InvalidSignature; + case 4: return LDKSemanticError_NoPaymentSecret; + case 5: return LDKSemanticError_MultiplePaymentSecrets; + case 6: return LDKSemanticError_InvalidFeatures; + case 7: return LDKSemanticError_InvalidRecoveryId; + case 8: return LDKSemanticError_InvalidSignature; + case 9: return LDKSemanticError_ImpreciseAmount; } abort(); } @@ -624,10 +626,12 @@ static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL; static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL; static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL; static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL; +static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL; static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL; static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL; +static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL; JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) { SemanticError_class = (*env)->NewGlobalRef(env, clz); CHECK(SemanticError_class != NULL); @@ -639,6 +643,8 @@ JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclas CHECK(SemanticError_LDKSemanticError_NoDescription != NULL); SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL); + SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;"); + CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL); SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL); SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;"); @@ -647,6 +653,8 @@ JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclas CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL); SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;"); CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL); + SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;"); + CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL); } static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) { switch (val) { @@ -658,6 +666,8 @@ static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription); case LDKSemanticError_MultipleDescriptions: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions); + case LDKSemanticError_NoPaymentSecret: + return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret); case LDKSemanticError_MultiplePaymentSecrets: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets); case LDKSemanticError_InvalidFeatures: @@ -666,6 +676,8 @@ static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId); case LDKSemanticError_InvalidSignature: return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature); + case LDKSemanticError_ImpreciseAmount: + return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount); default: abort(); } } @@ -970,6 +982,23 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitment uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(val->result_ok); + LDKTrustedClosingTransaction res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok; } @@ -1349,19 +1378,19 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonit } static jclass LDKMonitorEvent_HTLCEvent_class = NULL; static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL; -static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL; -static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL; +static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL; +static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) { LDKMonitorEvent_HTLCEvent_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;")); CHECK(LDKMonitorEvent_HTLCEvent_class != NULL); LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "", "(J)V"); CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL); - LDKMonitorEvent_CommitmentTxBroadcasted_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;")); - CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL); - LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "", "(J)V"); - CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL); + LDKMonitorEvent_CommitmentTxConfirmed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;")); + CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL); + LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "", "(J)V"); + CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL); } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1); @@ -1373,12 +1402,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_ uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1; return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref); } - case LDKMonitorEvent_CommitmentTxBroadcasted: { - LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted; - CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1; - return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref); + case LDKMonitorEvent_CommitmentTxConfirmed: { + LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed; + CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1; + return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref); } default: abort(); } @@ -1437,6 +1466,79 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeT default: abort(); } } +static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL; +static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL; +static jclass LDKNetworkUpdate_ChannelClosed_class = NULL; +static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL; +static jclass LDKNetworkUpdate_NodeFailure_class = NULL; +static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) { + LDKNetworkUpdate_ChannelUpdateMessage_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;")); + CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL); + LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "", "(J)V"); + CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL); + LDKNetworkUpdate_ChannelClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;")); + CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL); + LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "", "(JZ)V"); + CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL); + LDKNetworkUpdate_NodeFailure_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;")); + CHECK(LDKNetworkUpdate_NodeFailure_class != NULL); + LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "", "([BZ)V"); + CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1); + switch(obj->tag) { + case LDKNetworkUpdate_ChannelUpdateMessage: { + LDKChannelUpdate msg_var = obj->channel_update_message.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref); + } + case LDKNetworkUpdate_ChannelClosed: { + return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent); + } + case LDKNetworkUpdate_NodeFailure: { + int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form); + return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent); + } + default: abort(); + } +} +static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL; +static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL; +static jclass LDKCOption_NetworkUpdateZ_None_class = NULL; +static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) { + LDKCOption_NetworkUpdateZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;")); + CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL); + LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL); + LDKCOption_NetworkUpdateZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;")); + CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL); + LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "", "()V"); + CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_NetworkUpdateZ_Some: { + uint64_t some_ref = ((uint64_t)&obj->some) | 1; + return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref); + } + case LDKCOption_NetworkUpdateZ_None: { + return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth); + } + default: abort(); + } +} static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL; static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL; static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL; @@ -1570,50 +1672,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1 default: abort(); } } -static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL; -static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL; -static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL; -static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL; -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) { - LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;")); - CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL); - LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "", "(J)V"); - CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL); - LDKHTLCFailChannelUpdate_ChannelClosed_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;")); - CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL); - LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "", "(JZ)V"); - CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL); - LDKHTLCFailChannelUpdate_NodeFailure_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;")); - CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL); - LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "", "([BZ)V"); - CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL); -} -JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { - LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1); - switch(obj->tag) { - case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: { - LDKChannelUpdate msg_var = obj->channel_update_message.msg; - CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref); - } - case LDKHTLCFailChannelUpdate_ChannelClosed: { - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent); - } - case LDKHTLCFailChannelUpdate_NodeFailure: { - int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); - (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form); - return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent); - } - default: abort(); - } -} static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL; static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL; static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL; @@ -1646,8 +1704,6 @@ static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL; static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL; static jclass LDKMessageSendEvent_HandleError_class = NULL; static jmethodID LDKMessageSendEvent_HandleError_meth = NULL; -static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL; -static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL; static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL; static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL; static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL; @@ -1735,11 +1791,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init CHECK(LDKMessageSendEvent_HandleError_class != NULL); LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "", "([BJ)V"); CHECK(LDKMessageSendEvent_HandleError_meth != NULL); - LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;")); - CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL); - LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "", "(J)V"); - CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL); LDKMessageSendEvent_SendChannelRangeQuery_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;")); CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL); @@ -1898,10 +1949,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1; return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref); } - case LDKMessageSendEvent_PaymentFailureNetworkUpdate: { - uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1; - return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref); - } case LDKMessageSendEvent_SendChannelRangeQuery: { int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form); @@ -2101,6 +2148,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutput uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_NoneNoneZ*)arg)->result_ok; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) { LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); LDKSignature a_ref; @@ -2176,8 +2236,10 @@ typedef struct LDKBaseSign_JCalls { jweak o; jmethodID get_per_commitment_point_meth; jmethodID release_commitment_secret_meth; + jmethodID validate_holder_commitment_meth; jmethodID channel_keys_id_meth; jmethodID sign_counterparty_commitment_meth; + jmethodID validate_counterparty_revocation_meth; jmethodID sign_holder_commitment_and_htlcs_meth; jmethodID sign_justice_revoked_output_meth; jmethodID sign_justice_revoked_htlc_meth; @@ -2251,6 +2313,37 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a } return ret_ref; } +LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKHolderCommitmentTransaction holder_tx_var = *holder_tx; + holder_tx_var = HolderCommitmentTransaction_clone(holder_tx); + CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner; + if (holder_tx_var.is_owned) { + holder_tx_ref |= 1; + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception."); + } + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; @@ -2306,6 +2399,31 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L } return ret_conv; } +LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + int8_tArray secret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception."); + } + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; @@ -2440,7 +2558,7 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c } return ret_conv; } -LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) { +LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -2449,13 +2567,17 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKTransaction closing_tx_var = closing_tx; - int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen); - (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data); - Transaction_free(closing_tx_var); + LDKClosingTransaction closing_tx_var = *closing_tx; + // Warning: we may need a move here but no clone is available for LDKClosingTransaction + CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner; + if (closing_tx_var.is_owned) { + closing_tx_ref |= 1; + } jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception."); @@ -2537,10 +2659,14 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, CHECK(calls->get_per_commitment_point_meth != NULL); calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B"); CHECK(calls->release_commitment_secret_meth != NULL); + calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J"); + CHECK(calls->validate_holder_commitment_meth != NULL); calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B"); CHECK(calls->channel_keys_id_meth != NULL); calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J"); CHECK(calls->sign_counterparty_commitment_meth != NULL); + calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J"); + CHECK(calls->validate_counterparty_revocation_meth != NULL); calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J"); CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL); calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J"); @@ -2549,7 +2675,7 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, CHECK(calls->sign_justice_revoked_htlc_meth != NULL); calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J"); CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL); - calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J"); + calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J"); CHECK(calls->sign_closing_transaction_meth != NULL); calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J"); CHECK(calls->sign_channel_announcement_meth != NULL); @@ -2565,8 +2691,10 @@ static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, .this_arg = (void*) calls, .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall, .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall, + .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall, .channel_keys_id = channel_keys_id_LDKBaseSign_jcall, .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall, + .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall, .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall, .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall, .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall, @@ -2599,6 +2727,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1comm return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + LDKHolderCommitmentTransaction holder_tx_conv; + holder_tx_conv.inner = (void*)(holder_tx & (~1)); + holder_tx_conv.is_owned = false; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); int8_tArray ret_arr = (*env)->NewByteArray(env, 32); @@ -2616,6 +2754,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + unsigned char secret_arr[32]; + CHECK((*env)->GetArrayLength(env, secret) == 32); + (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr); + unsigned char (*secret_ref)[32] = &secret_arr; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); LDKHolderCommitmentTransaction commitment_tx_conv; @@ -2679,15 +2828,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart return (uint64_t)ret_conv; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray closing_tx) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); - LDKTransaction closing_tx_ref; - closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx); - closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes"); - (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data); - closing_tx_ref.data_is_owned = true; + LDKClosingTransaction closing_tx_conv; + closing_tx_conv.inner = (void*)(closing_tx & (~1)); + closing_tx_conv.is_owned = false; LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); - *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref); + *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv); return (uint64_t)ret_conv; } @@ -2831,9 +2978,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErro JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); CHECK(val->result_ok); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(&(*val->contents.result)); - return (uint64_t)ret; + LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *res_ret = Sign_clone(&(*val->contents.result)); + return (uint64_t)res_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); @@ -4016,9 +4163,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdow JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) { @@ -4286,6 +4433,203 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeE uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKType_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID type_id_meth; + jmethodID debug_str_meth; + jmethodID write_meth; +} LDKType_JCalls; +static void LDKType_JCalls_free(void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +uint16_t type_id_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception."); + } + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret; +} +LDKStr debug_str_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception."); + } + LDKStr ret_conv = java_to_owned_str(env, ret); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception."); + } + LDKCVec_u8Z ret_ref; + ret_ref.datalen = (*env)->GetArrayLength(env, ret); + ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_ref; +} +static void LDKType_JCalls_cloned(LDKType* new_obj) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S"); + CHECK(calls->type_id_meth != NULL); + calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;"); + CHECK(calls->debug_str_meth != NULL); + calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B"); + CHECK(calls->write_meth != NULL); + + LDKType ret = { + .this_arg = (void*) calls, + .type_id = type_id_LDKType_jcall, + .debug_str = debug_str_LDKType_jcall, + .write = write_LDKType_jcall, + .cloned = LDKType_JCalls_cloned, + .free = LDKType_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) { + LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType"); + *res_ptr = LDKType_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg); + return ret_val; +} + +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg); + jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len); + Str_free(ret_str); + return ret_conv; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +static jclass LDKCOption_TypeZ_Some_class = NULL; +static jmethodID LDKCOption_TypeZ_Some_meth = NULL; +static jclass LDKCOption_TypeZ_None_class = NULL; +static jmethodID LDKCOption_TypeZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) { + LDKCOption_TypeZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;")); + CHECK(LDKCOption_TypeZ_Some_class != NULL); + LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_TypeZ_Some_meth != NULL); + LDKCOption_TypeZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;")); + CHECK(LDKCOption_TypeZ_None_class != NULL); + LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "", "()V"); + CHECK(LDKCOption_TypeZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_TypeZ_Some: { + LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType"); + *some_ret = Type_clone(&obj->some); + return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_TypeZ_None: { + return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth); + } + default: abort(); + } +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1; + return res_ref; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok; } @@ -4773,20 +5117,104 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1fro default: abort(); } } +static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL; +static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL; +static jclass LDKClosureReason_HolderForceClosed_class = NULL; +static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL; +static jclass LDKClosureReason_CooperativeClosure_class = NULL; +static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL; +static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL; +static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL; +static jclass LDKClosureReason_ProcessingError_class = NULL; +static jmethodID LDKClosureReason_ProcessingError_meth = NULL; +static jclass LDKClosureReason_DisconnectedPeer_class = NULL; +static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL; +static jclass LDKClosureReason_OutdatedChannelManager_class = NULL; +static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) { + LDKClosureReason_CounterpartyForceClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;")); + CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL); + LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "", "(Ljava/lang/String;)V"); + CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL); + LDKClosureReason_HolderForceClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;")); + CHECK(LDKClosureReason_HolderForceClosed_class != NULL); + LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "", "()V"); + CHECK(LDKClosureReason_HolderForceClosed_meth != NULL); + LDKClosureReason_CooperativeClosure_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;")); + CHECK(LDKClosureReason_CooperativeClosure_class != NULL); + LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "", "()V"); + CHECK(LDKClosureReason_CooperativeClosure_meth != NULL); + LDKClosureReason_CommitmentTxConfirmed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;")); + CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL); + LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "", "()V"); + CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL); + LDKClosureReason_ProcessingError_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;")); + CHECK(LDKClosureReason_ProcessingError_class != NULL); + LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "", "(Ljava/lang/String;)V"); + CHECK(LDKClosureReason_ProcessingError_meth != NULL); + LDKClosureReason_DisconnectedPeer_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;")); + CHECK(LDKClosureReason_DisconnectedPeer_class != NULL); + LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "", "()V"); + CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL); + LDKClosureReason_OutdatedChannelManager_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;")); + CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL); + LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "", "()V"); + CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1); + switch(obj->tag) { + case LDKClosureReason_CounterpartyForceClosed: { + LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg; + jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len); + return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv); + } + case LDKClosureReason_HolderForceClosed: { + return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth); + } + case LDKClosureReason_CooperativeClosure: { + return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth); + } + case LDKClosureReason_CommitmentTxConfirmed: { + return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth); + } + case LDKClosureReason_ProcessingError: { + LDKStr err_str = obj->processing_error.err; + jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len); + return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv); + } + case LDKClosureReason_DisconnectedPeer: { + return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth); + } + case LDKClosureReason_OutdatedChannelManager: { + return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth); + } + default: abort(); + } +} static jclass LDKEvent_FundingGenerationReady_class = NULL; static jmethodID LDKEvent_FundingGenerationReady_meth = NULL; static jclass LDKEvent_PaymentReceived_class = NULL; static jmethodID LDKEvent_PaymentReceived_meth = NULL; static jclass LDKEvent_PaymentSent_class = NULL; static jmethodID LDKEvent_PaymentSent_meth = NULL; -static jclass LDKEvent_PaymentFailed_class = NULL; -static jmethodID LDKEvent_PaymentFailed_meth = NULL; +static jclass LDKEvent_PaymentPathFailed_class = NULL; +static jmethodID LDKEvent_PaymentPathFailed_meth = NULL; static jclass LDKEvent_PendingHTLCsForwardable_class = NULL; static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL; static jclass LDKEvent_SpendableOutputs_class = NULL; static jmethodID LDKEvent_SpendableOutputs_meth = NULL; static jclass LDKEvent_PaymentForwarded_class = NULL; static jmethodID LDKEvent_PaymentForwarded_meth = NULL; +static jclass LDKEvent_ChannelClosed_class = NULL; +static jmethodID LDKEvent_ChannelClosed_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) { LDKEvent_FundingGenerationReady_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;")); @@ -4803,11 +5231,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en CHECK(LDKEvent_PaymentSent_class != NULL); LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "", "([B)V"); CHECK(LDKEvent_PaymentSent_meth != NULL); - LDKEvent_PaymentFailed_class = - (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;")); - CHECK(LDKEvent_PaymentFailed_class != NULL); - LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "", "([BZ)V"); - CHECK(LDKEvent_PaymentFailed_meth != NULL); + LDKEvent_PaymentPathFailed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;")); + CHECK(LDKEvent_PaymentPathFailed_class != NULL); + LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "", "([BZJZ[J)V"); + CHECK(LDKEvent_PaymentPathFailed_meth != NULL); LDKEvent_PendingHTLCsForwardable_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;")); CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL); @@ -4823,6 +5251,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en CHECK(LDKEvent_PaymentForwarded_class != NULL); LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "", "(JZ)V"); CHECK(LDKEvent_PaymentForwarded_meth != NULL); + LDKEvent_ChannelClosed_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;")); + CHECK(LDKEvent_ChannelClosed_class != NULL); + LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "", "([BJ)V"); + CHECK(LDKEvent_ChannelClosed_meth != NULL); } JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { LDKEvent *obj = (LDKEvent*)(ptr & ~1); @@ -4846,10 +5279,22 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data); return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr); } - case LDKEvent_PaymentFailed: { + case LDKEvent_PaymentPathFailed: { int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data); - return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest); + (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data); + uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1; + LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path; + int64_tArray path_arr = (*env)->NewLongArray(env, path_var.datalen); + int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL); + for (size_t k = 0; k < path_var.datalen; k++) { + LDKRouteHop path_conv_10_var = path_var.data[k]; + CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1; + path_arr_ptr[k] = path_conv_10_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0); + return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr); } case LDKEvent_PendingHTLCsForwardable: { return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable); @@ -4869,6 +5314,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1; return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx); } + case LDKEvent_ChannelClosed: { + int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data); + uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1; + return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, reason_ref); + } default: abort(); } } @@ -5005,24 +5456,162 @@ static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVe } return ret; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { - return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); - CHECK(val->result_ok); - uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1; - return res_ref; +static jclass LDKBalance_ClaimableOnChannelClose_class = NULL; +static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL; +static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL; +static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL; +static jclass LDKBalance_ContentiousClaimable_class = NULL; +static jmethodID LDKBalance_ContentiousClaimable_meth = NULL; +static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL; +static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) { + LDKBalance_ClaimableOnChannelClose_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;")); + CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL); + LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "", "(J)V"); + CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL); + LDKBalance_ClaimableAwaitingConfirmations_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;")); + CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL); + LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "", "(JI)V"); + CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL); + LDKBalance_ContentiousClaimable_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;")); + CHECK(LDKBalance_ContentiousClaimable_class != NULL); + LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "", "(JI)V"); + CHECK(LDKBalance_ContentiousClaimable_meth != NULL); + LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;")); + CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL); + LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "", "(JI)V"); + CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKBalance *obj = (LDKBalance*)(ptr & ~1); + switch(obj->tag) { + case LDKBalance_ClaimableOnChannelClose: { + return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis); + } + case LDKBalance_ClaimableAwaitingConfirmations: { + return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height); + } + case LDKBalance_ContentiousClaimable: { + return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height); + } + case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: { + return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height); + } + default: abort(); + } } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKDecodeError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) { + LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ"); + ret->datalen = (*env)->GetArrayLength(env, elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data"); + int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL); + for (size_t i = 0; i < ret->datalen; i++) { + int64_t arr_elem = java_elems[i]; + LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0); + } + return (uint64_t)ret; +} +static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) { + LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = Balance_clone(&orig->data[i]); + } + return ret; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1; + return res_ref; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKLightningError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) { + LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + LDKPublicKey a_ref; + CHECK((*env)->GetArrayLength(env, a) == 33); + (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form); + ret->a = a_ref; + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + b_conv = Type_clone(&b_conv); + ret->b = b_conv; + return (uint64_t)ret; +} +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + int8_tArray a_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, a_arr, 0, 33, tuple->a.compressed_form); + return a_arr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + LDKType* b_ret =MALLOC(sizeof(LDKType), "LDKType"); + *b_ret = Type_clone(&tuple->b); + return (uint64_t)b_ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) { + LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ"); + ret->datalen = (*env)->GetArrayLength(env, elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data"); + int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL); + for (size_t i = 0; i < ret->datalen; i++) { + int64_t arr_elem = java_elems[i]; + LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0); + } + return (uint64_t)ret; +} +static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) { + LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]); + } + return ret; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok; } @@ -5135,23 +5724,6 @@ static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCV } return ret; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { - return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; -} -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(val->result_ok); - return *val->contents.result; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKLightningError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t err_ref = (uint64_t)err_var.inner & ~1; - return err_ref; -} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; } @@ -5206,6 +5778,126 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleE uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKAccess_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID get_utxo_meth; +} LDKAccess_JCalls; +static void LDKAccess_JCalls_free(void* this_arg) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception."); + } + LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); + CHECK(calls->get_utxo_meth != NULL); + + LDKAccess ret = { + .this_arg = (void*) calls, + .get_utxo = get_utxo_LDKAccess_jcall, + .free = LDKAccess_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) { + LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); + *res_ptr = LDKAccess_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { + LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); + unsigned char genesis_hash_arr[32]; + CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); + (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr); + unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; + LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); + *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); + return (uint64_t)ret_conv; +} + +static jclass LDKCOption_AccessZ_Some_class = NULL; +static jmethodID LDKCOption_AccessZ_Some_meth = NULL; +static jclass LDKCOption_AccessZ_None_class = NULL; +static jmethodID LDKCOption_AccessZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) { + LDKCOption_AccessZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;")); + CHECK(LDKCOption_AccessZ_Some_class != NULL); + LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_AccessZ_Some_meth != NULL); + LDKCOption_AccessZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;")); + CHECK(LDKCOption_AccessZ_None_class != NULL); + LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "", "()V"); + CHECK(LDKCOption_AccessZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_AccessZ_Some: { + LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + if ((*some_ret).free == LDKAccess_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKAccess_JCalls_cloned(&(*some_ret)); + } + return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_AccessZ_None: { + return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth); + } + default: abort(); + } +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; } @@ -6231,14 +6923,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCr uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; return err_ref; } -typedef struct LDKMessageSendEventsProvider_JCalls { +typedef struct LDKFilter_JCalls { atomic_size_t refcnt; JavaVM *vm; jweak o; - jmethodID get_and_clear_pending_msg_events_meth; -} LDKMessageSendEventsProvider_JCalls; -static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + jmethodID register_tx_meth; + jmethodID register_output_meth; +} LDKFilter_JCalls; +static void LDKFilter_JCalls_free(void* this_arg) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -6254,8 +6947,8 @@ static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { FREE(j_calls); } } -LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; +void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); if (get_jenv_res == JNI_EDETACHED) { @@ -6263,40 +6956,207 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP } else { DO_ASSERT(get_jenv_res == JNI_OK); } + int8_tArray txid_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid); + LDKu8slice script_pubkey_var = script_pubkey; + int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen); + (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data); jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth); + (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception."); + (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception."); } - LDKCVec_MessageSendEventZ ret_constr; - ret_constr.datalen = (*env)->GetArrayLength(env, ret); - if (ret_constr.datalen > 0) - ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); - else - ret_constr.data = NULL; - int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); - for (size_t s = 0; s < ret_constr.datalen; s++) { - int64_t ret_conv_18 = ret_vals[s]; - LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1); - ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1)); - ret_constr.data[s] = ret_conv_18_conv; + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); } - (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); +} +LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKWatchedOutput output_var = output; + CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t output_ref = (uint64_t)output_var.inner; + if (output_var.is_owned) { + output_ref |= 1; + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception."); + } + LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); + ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); if (get_jenv_res == JNI_EDETACHED) { DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); } - return ret_constr; + return ret_conv; } -static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg; +static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); } -static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) { +static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) { jclass c = (*env)->GetObjectClass(env, o); CHECK(c != NULL); - LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); + LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V"); + CHECK(calls->register_tx_meth != NULL); + calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J"); + CHECK(calls->register_output_meth != NULL); + + LDKFilter ret = { + .this_arg = (void*) calls, + .register_tx = register_tx_LDKFilter_jcall, + .register_output = register_output_LDKFilter_jcall, + .free = LDKFilter_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) { + LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); + *res_ptr = LDKFilter_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + unsigned char txid_arr[32]; + CHECK((*env)->GetArrayLength(env, txid) == 32); + (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr); + unsigned char (*txid_ref)[32] = &txid_arr; + LDKu8slice script_pubkey_ref; + script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey); + script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL); + (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); + (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + LDKWatchedOutput output_conv; + output_conv.inner = (void*)(output & (~1)); + output_conv.is_owned = (output & 1) || (output == 0); + output_conv = WatchedOutput_clone(&output_conv); + LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); + *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +static jclass LDKCOption_FilterZ_Some_class = NULL; +static jmethodID LDKCOption_FilterZ_Some_meth = NULL; +static jclass LDKCOption_FilterZ_None_class = NULL; +static jmethodID LDKCOption_FilterZ_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) { + LDKCOption_FilterZ_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;")); + CHECK(LDKCOption_FilterZ_Some_class != NULL); + LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "", "(J)V"); + CHECK(LDKCOption_FilterZ_Some_meth != NULL); + LDKCOption_FilterZ_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;")); + CHECK(LDKCOption_FilterZ_None_class != NULL); + LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "", "()V"); + CHECK(LDKCOption_FilterZ_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_FilterZ_Some: { + LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + if ((*some_ret).free == LDKFilter_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKFilter_JCalls_cloned(&(*some_ret)); + } + return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret); + } + case LDKCOption_FilterZ_None: { + return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth); + } + default: abort(); + } +} +typedef struct LDKMessageSendEventsProvider_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID get_and_clear_pending_msg_events_meth; +} LDKMessageSendEventsProvider_JCalls; +static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception."); + } + LDKCVec_MessageSendEventZ ret_constr; + ret_constr.datalen = (*env)->GetArrayLength(env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements"); + else + ret_constr.data = NULL; + int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); + for (size_t s = 0; s < ret_constr.datalen; s++) { + int64_t ret_conv_18 = ret_vals[s]; + LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1); + ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1)); + ret_constr.data[s] = ret_conv_18_conv; + } + (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_constr; +} +static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) { + LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); atomic_init(&calls->refcnt, 1); DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); calls->o = (*env)->NewWeakGlobalRef(env, o); @@ -6354,7 +7214,7 @@ static void LDKEventHandler_JCalls_free(void* this_arg) { FREE(j_calls); } } -void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { +void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg; JNIEnv *env; jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); @@ -6363,12 +7223,11 @@ void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *event_copy = event; - uint64_t event_ref = (uint64_t)event_copy; + LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion"); + *ret_event = Event_clone(event); jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref); + (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception."); @@ -6405,7 +7264,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) { LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1); - LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1); + LDKEvent* event_conv = (LDKEvent*)event; (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv); } @@ -6441,11 +7300,11 @@ void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEve } else { DO_ASSERT(get_jenv_res == JNI_OK); } - LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); - *ret = handler; + LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *handler_ret = handler; jobject obj = (*env)->NewLocalRef(env, j_calls->o); CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret); + (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret); if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception."); @@ -6490,91 +7349,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pendi (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv); } -typedef struct LDKAccess_JCalls { - atomic_size_t refcnt; - JavaVM *vm; - jweak o; - jmethodID get_utxo_meth; -} LDKAccess_JCalls; -static void LDKAccess_JCalls_free(void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - (*env)->DeleteWeakGlobalRef(env, j_calls->o); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - FREE(j_calls); - } -} -LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash); - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception."); - } - LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - return ret_conv; -} -static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); - CHECK(calls->get_utxo_meth != NULL); - - LDKAccess ret = { - .this_arg = (void*) calls, - .get_utxo = get_utxo_LDKAccess_jcall, - .free = LDKAccess_JCalls_free, - }; - return ret; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) { - LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *res_ptr = LDKAccess_init(env, clz, o); - return (uint64_t)res_ptr; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { - LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); - unsigned char genesis_hash_arr[32]; - CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); - (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr); - unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; - LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); - *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); - return (uint64_t)ret_conv; -} - typedef struct LDKListen_JCalls { atomic_size_t refcnt; JavaVM *vm; @@ -6903,151 +7677,18 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated( (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height); } -JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1); - LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg); - jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL); - ; - for (size_t i = 0; i < ret_var.datalen; i++) { - int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data); - (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr); - } - FREE(ret_var.data); - return ret_arr; -} - -typedef struct LDKFilter_JCalls { - atomic_size_t refcnt; - JavaVM *vm; - jweak o; - jmethodID register_tx_meth; - jmethodID register_output_meth; -} LDKFilter_JCalls; -static void LDKFilter_JCalls_free(void* this_arg) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - (*env)->DeleteWeakGlobalRef(env, j_calls->o); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - FREE(j_calls); - } -} -void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - int8_tArray txid_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid); - LDKu8slice script_pubkey_var = script_pubkey; - int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen); - (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data); - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception."); - } - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } -} -LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - LDKWatchedOutput output_var = output; - CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t output_ref = (uint64_t)output_var.inner; - if (output_var.is_owned) { - output_ref |= 1; - } - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception."); - } - LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); - ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } - return ret_conv; -} -static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V"); - CHECK(calls->register_tx_meth != NULL); - calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J"); - CHECK(calls->register_output_meth != NULL); - - LDKFilter ret = { - .this_arg = (void*) calls, - .register_tx = register_tx_LDKFilter_jcall, - .register_output = register_output_LDKFilter_jcall, - .free = LDKFilter_JCalls_free, - }; - return ret; -} -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) { - LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *res_ptr = LDKFilter_init(env, clz, o); - return (uint64_t)res_ptr; -} -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - unsigned char txid_arr[32]; - CHECK((*env)->GetArrayLength(env, txid) == 32); - (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr); - unsigned char (*txid_ref)[32] = &txid_arr; - LDKu8slice script_pubkey_ref; - script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey); - script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL); - (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); - (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - LDKWatchedOutput output_conv; - output_conv.inner = (void*)(output & (~1)); - output_conv.is_owned = (output & 1) || (output == 0); - output_conv = WatchedOutput_clone(&output_conv); - LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); - *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1); + LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg); + jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL); + ; + for (size_t i = 0; i < ret_var.datalen; i++) { + int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data); + (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr); + } + FREE(ret_var.data); + return ret_arr; } typedef struct LDKPersist_JCalls { @@ -8203,7 +8844,6 @@ typedef struct LDKRoutingMessageHandler_JCalls { jmethodID handle_node_announcement_meth; jmethodID handle_channel_announcement_meth; jmethodID handle_channel_update_meth; - jmethodID handle_htlc_fail_channel_update_meth; jmethodID get_next_channel_announcements_meth; jmethodID get_next_node_announcements_meth; jmethodID sync_routing_table_meth; @@ -8322,27 +8962,6 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc } return ret_conv; } -void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) { - LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - JNIEnv *env; - jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); - } else { - DO_ASSERT(get_jenv_res == JNI_OK); - } - uint64_t ret_update = (uint64_t)update; - jobject obj = (*env)->NewLocalRef(env, j_calls->o); - CHECK(obj != NULL); - (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception."); - } - if (get_jenv_res == JNI_EDETACHED) { - DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); - } -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *env; @@ -8593,8 +9212,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *en CHECK(calls->handle_channel_announcement_meth != NULL); calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J"); CHECK(calls->handle_channel_update_meth != NULL); - calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V"); - CHECK(calls->handle_htlc_fail_channel_update_meth != NULL); calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J"); CHECK(calls->get_next_channel_announcements_meth != NULL); calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J"); @@ -8615,7 +9232,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *en .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall, - .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall, .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall, .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall, .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall, @@ -8659,128 +9275,363 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv); return (uint64_t)ret_conv; } - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = false; - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv); - return (uint64_t)ret_conv; + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = false; + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t l = 0; l < ret_var.datalen; l++) { + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); + *ret_conv_63_ref = ret_var.data[l]; + ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey starting_point_ref; + CHECK((*env)->GetArrayLength(env, starting_point) == 33); + (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form); + LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t s = 0; s < ret_var.datalen; s++) { + LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s]; + CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner; + if (ret_conv_18_var.is_owned) { + ret_conv_18_ref |= 1; + } + ret_arr_ptr[s] = ret_conv_18_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKInit init_conv; + init_conv.inner = (void*)(init & (~1)); + init_conv.is_owned = false; + (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKReplyChannelRange msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ReplyChannelRange_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKReplyShortChannelIdsEnd msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKQueryChannelRange msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = QueryChannelRange_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { + LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKPublicKey their_node_id_ref; + CHECK((*env)->GetArrayLength(env, their_node_id) == 33); + (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); + LDKQueryShortChannelIds msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = QueryShortChannelIds_clone(&msg_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageReader_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + jmethodID read_meth; +} LDKCustomMessageReader_JCalls; +static void LDKCustomMessageReader_JCalls_free(void* this_arg) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKu8slice buffer_var = buffer; + int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen); + (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception."); + } + LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J"); + CHECK(calls->read_meth != NULL); + + LDKCustomMessageReader ret = { + .this_arg = (void*) calls, + .read = read_LDKCustomMessageReader_jcall, + .free = LDKCustomMessageReader_JCalls_free, + }; + return ret; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) { + LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *res_ptr = LDKCustomMessageReader_init(env, clz, o); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) { + LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1); + LDKu8slice buffer_ref; + buffer_ref.datalen = (*env)->GetArrayLength(env, buffer); + buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref); + (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageHandler_JCalls { + atomic_size_t refcnt; + JavaVM *vm; + jweak o; + LDKCustomMessageReader_JCalls* CustomMessageReader; + jmethodID handle_custom_message_meth; + jmethodID get_and_clear_pending_msg_meth; +} LDKCustomMessageHandler_JCalls; +static void LDKCustomMessageHandler_JCalls_free(void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + (*env)->DeleteWeakGlobalRef(env, j_calls->o); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + FREE(j_calls); + } +} +LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType"); + *msg_ret = msg; + int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form); + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception."); + } + LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1)); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_conv; +} +LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + JNIEnv *env; + jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK); + } else { + DO_ASSERT(get_jenv_res == JNI_OK); + } + jobject obj = (*env)->NewLocalRef(env, j_calls->o); + CHECK(obj != NULL); + int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception."); + } + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr; + ret_constr.datalen = (*env)->GetArrayLength(env, ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + ret_constr.data = NULL; + int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL); + for (size_t y = 0; y < ret_constr.datalen; y++) { + int64_t ret_conv_24 = ret_vals[y]; + LDKC2Tuple_PublicKeyTypeZ ret_conv_24_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_24) & ~1); + ret_conv_24_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_24) & ~1)); + ret_constr.data[y] = ret_conv_24_conv; + } + (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0); + if (get_jenv_res == JNI_EDETACHED) { + DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK); + } + return ret_constr; +} +static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); + atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release); } +static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) { + jclass c = (*env)->GetObjectClass(env, o); + CHECK(c != NULL); + LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls"); + atomic_init(&calls->refcnt, 1); + DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); + calls->o = (*env)->NewWeakGlobalRef(env, o); + calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J"); + CHECK(calls->handle_custom_message_meth != NULL); + calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J"); + CHECK(calls->get_and_clear_pending_msg_meth != NULL); -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t update) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update; - (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv); + LDKCustomMessageHandler ret = { + .this_arg = (void*) calls, + .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall, + .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall, + .free = LDKCustomMessageHandler_JCalls_free, + .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader), + }; + calls->CustomMessageReader = ret.CustomMessageReader.this_arg; + return ret; } - -JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); - int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); - int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); - for (size_t l = 0; l < ret_var.datalen; l++) { - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); - *ret_conv_63_ref = ret_var.data[l]; - ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref; +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) { + LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader); + return (uint64_t)res_ptr; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) { + LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1); + uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader; + DO_ASSERT((res_ptr & 1) == 0); + return (int64_t)(res_ptr | 1); +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1); + if (msg_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&msg_conv); } - (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); - FREE(ret_var.data); - return ret_arr; + LDKPublicKey sender_node_id_ref; + CHECK((*env)->GetArrayLength(env, sender_node_id) == 33); + (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref); + return (uint64_t)ret_conv; } -JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey starting_point_ref; - CHECK((*env)->GetArrayLength(env, starting_point) == 33); - (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form); - LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount); +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg); int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); - for (size_t s = 0; s < ret_var.datalen; s++) { - LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s]; - CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner; - if (ret_conv_18_var.is_owned) { - ret_conv_18_ref |= 1; - } - ret_arr_ptr[s] = ret_conv_18_ref; + for (size_t y = 0; y < ret_var.datalen; y++) { + LDKC2Tuple_PublicKeyTypeZ* ret_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_conv_24_ref = ret_var.data[y]; + ret_arr_ptr[y] = (uint64_t)ret_conv_24_ref; } (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); FREE(ret_var.data); return ret_arr; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKInit init_conv; - init_conv.inner = (void*)(init & (~1)); - init_conv.is_owned = false; - (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKReplyChannelRange msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ReplyChannelRange_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKReplyShortChannelIdsEnd msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1channel_1range(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKQueryChannelRange msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = QueryChannelRange_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKPublicKey their_node_id_ref; - CHECK((*env)->GetArrayLength(env, their_node_id) == 33); - (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form); - LDKQueryShortChannelIds msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = QueryShortChannelIds_clone(&msg_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv); - return (uint64_t)ret_conv; -} - typedef struct LDKSocketDescriptor_JCalls { atomic_size_t refcnt; JavaVM *vm; @@ -9508,6 +10359,29 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTra return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) { + LDKTrustedClosingTransaction o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) { + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_err(); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_TrustedClosingTransactionNoneZ_free(_res_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKCommitmentTransaction o_conv; o_conv.inner = (void*)(o & (~1)); @@ -9911,6 +10785,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErro JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1); + o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1)); LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10044,6 +10919,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIE JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1)); LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -10072,6 +10948,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1); + o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1)); + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_NetworkUpdateZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig; + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { LDKCVec_SpendableOutputDescriptorZ _res_constr; _res_constr.datalen = (*env)->GetArrayLength(env, _res); @@ -10286,6 +11193,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutpu JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1); + o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1)); LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ"); *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10315,6 +11223,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDes return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_ok(); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_err(); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneNoneZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1); + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1); LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); @@ -10353,6 +11287,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1Signat JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1)); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10729,6 +11664,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok( JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10792,6 +11728,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFai JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ"); *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -10822,6 +11759,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPayment JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -10896,6 +11834,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIEr JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10956,6 +11895,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManag JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -11046,6 +11986,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&o_conv); + } + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_TypeZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig; + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { + LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1); + o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1)); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { + LDKDecodeError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = DecodeError_clone(&e_conv); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_COption_TypeZDecodeErrorZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) { LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o); LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ"); @@ -11686,6 +12692,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) { LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1); + b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1)); LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ"); *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv); return (uint64_t)ret_ref; @@ -11771,8 +12778,27 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr); } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { + LDKCVec_BalanceZ _res_constr; + _res_constr.datalen = (*env)->GetArrayLength(env, _res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements"); + else + _res_constr.data = NULL; + int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL); + for (size_t j = 0; j < _res_constr.datalen; j++) { + int64_t _res_conv_9 = _res_vals[j]; + LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1); + FREE((void*)_res_conv_9); + _res_constr.data[j] = _res_conv_9_conv; + } + (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0); + CVec_BalanceZ_free(_res_constr); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -11795,6 +12821,82 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashCha CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) { + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_ok(); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { + LDKLightningError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = LightningError_clone(&e_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneLightningErrorZ_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_clone(orig_conv); + return (uint64_t)ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) { + LDKPublicKey a_ref; + CHECK((*env)->GetArrayLength(env, a) == 33); + (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form); + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + if (b_conv.free == LDKType_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKType_JCalls_cloned(&b_conv); + } + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv); + return (uint64_t)ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + C2Tuple_PublicKeyTypeZ_free(_res_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) { + LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr; + _res_constr.datalen = (*env)->GetArrayLength(env, _res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + _res_constr.data = NULL; + int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL); + for (size_t y = 0; y < _res_constr.datalen; y++) { + int64_t _res_conv_24 = _res_vals[y]; + LDKC2Tuple_PublicKeyTypeZ _res_conv_24_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_24) & ~1); + FREE((void*)_res_conv_24); + _res_constr.data[y] = _res_conv_24_conv; + } + (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0); + CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) { LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); *ret_conv = CResult_boolLightningErrorZ_ok(o); @@ -11894,36 +12996,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free( CVec_NodeAnnouncementZ_free(_res_constr); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) { - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_ok(); - return (uint64_t)ret_conv; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { - LDKLightningError e_conv; - e_conv.inner = (void*)(e & (~1)); - e_conv.is_owned = (e & 1) || (e == 0); - e_conv = LightningError_clone(&e_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); - return (uint64_t)ret_conv; -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { - if ((_res & 1) != 0) return; - LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); - FREE((void*)_res); - CResult_NoneLightningErrorZ_free(_res_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) { LDKCVec_PublicKeyZ _res_constr; _res_constr.datalen = (*env)->GetArrayLength(env, _res); @@ -12035,6 +13107,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErro return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKAccess_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKAccess_JCalls_cloned(&o_conv); + } + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_AccessZ_free(_res_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKDirectionalChannelInfo o_conv; o_conv.inner = (void*)(o & (~1)); @@ -12225,7 +13323,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecode LDKNetworkGraph o_conv; o_conv.inner = (void*)(o & (~1)); o_conv.is_owned = (o & 1) || (o == 0); - o_conv = NetworkGraph_clone(&o_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -12248,15 +13346,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErr CResult_NetworkGraphDecodeErrorZ_free(_res_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1); - LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); - *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z"); *ret_conv = CResult_NetAddressu8Z_ok(o_conv); return (uint64_t)ret_conv; @@ -12284,6 +13376,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clo JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1); + o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1)); LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ"); *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -12315,6 +13408,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddres JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ"); *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -13520,6 +14614,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) { LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1); + e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1)); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -13539,6 +14634,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat return (uint64_t)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) { + LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1); + if (o_conv.free == LDKFilter_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKFilter_JCalls_cloned(&o_conv); + } + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) { + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_FilterZ_free(_res_conv); +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1); @@ -13577,6 +14698,81 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + ClosureReason_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKClosureReason* orig_conv = (LDKClosureReason*)orig; + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) { + LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_holder_force_closed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_cooperative_closure(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_commitment_tx_confirmed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) { + LDKStr err_conv = java_to_owned_str(env, err); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_processing_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_disconnected_peer(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_outdated_channel_manager(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKClosureReason* obj_conv = (LDKClosureReason*)obj; + LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1); @@ -13611,6 +14807,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1); + purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -13627,12 +14824,30 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path) { LDKThirtyTwoBytes payment_hash_ref; CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); + LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1); + network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1)); + LDKCVec_RouteHopZ path_constr; + path_constr.datalen = (*env)->GetArrayLength(env, path); + if (path_constr.datalen > 0) + path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + path_constr.data = NULL; + int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL); + for (size_t k = 0; k < path_constr.datalen; k++) { + int64_t path_conv_10 = path_vals[k]; + LDKRouteHop path_conv_10_conv; + path_conv_10_conv.inner = (void*)(path_conv_10 & (~1)); + path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0); + path_conv_10_conv = RouteHop_clone(&path_conv_10_conv); + path_constr.data[k] = path_conv_10_conv; + } + (*env)->ReleaseLongArrayElements(env, path, path_vals, 0); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest); + *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -13667,12 +14882,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) { LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1); + fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t reason) { + LDKThirtyTwoBytes channel_id_ref; + CHECK((*env)->GetArrayLength(env, channel_id) == 32); + (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data); + LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1); + reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1)); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_channel_closed(channel_id_ref, reason_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKEvent* obj_conv = (LDKEvent*)obj; LDKCVec_u8Z ret_var = Event_write(obj_conv); @@ -13907,20 +15135,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1e CHECK((*env)->GetArrayLength(env, node_id) == 33); (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1); + action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1)); LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) { - LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1); - LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); - *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) { LDKPublicKey node_id_ref; CHECK((*env)->GetArrayLength(env, node_id) == 33); @@ -14989,16 +16210,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) { - LDKFilter *chain_source_conv_ptr = NULL; - if (chain_source != 0) { - LDKFilter chain_source_conv; - chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1); - if (chain_source_conv.free == LDKFilter_JCalls_free) { + LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ + if (chain_source_conv.tag == LDKCOption_FilterZ_Some) { + // Manually implement clone for Java trait instances + if (chain_source_conv.some.free == LDKFilter_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKFilter_JCalls_cloned(&chain_source_conv); + LDKFilter_JCalls_cloned(&chain_source_conv.some); } - chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *chain_source_conv_ptr = chain_source_conv; } LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1); if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) { @@ -15020,7 +16239,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKPersist_JCalls_cloned(&persister_conv); } - LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv); + LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -15030,40 +16249,74 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e return ret_ref; } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) { + LDKChainMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_ChannelDetailsZ ignored_channels_constr; + ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels); + if (ignored_channels_constr.datalen > 0) + ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + ignored_channels_constr.data = NULL; + int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL); + for (size_t q = 0; q < ignored_channels_constr.datalen; q++) { + int64_t ignored_channels_conv_16 = ignored_channels_vals[q]; + LDKChannelDetails ignored_channels_conv_16_conv; + ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1)); + ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0); + ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv); + ignored_channels_constr.data[q] = ignored_channels_conv_16_conv; + } + (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0); + LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChainMonitor_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChainMonitor_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChainMonitor_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch"); - *ret = ChainMonitor_as_Watch(&this_arg_conv); - return (uint64_t)ret; + LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch"); + *ret_ret = ChainMonitor_as_Watch(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChainMonitor_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -15186,13 +16439,13 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNI return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) { LDKOutPoint a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); a_conv = OutPoint_clone(&a_conv); LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); - *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv); + *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -15239,6 +16492,56 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *en return (uint64_t)ret_conv; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Balance_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBalance* orig_conv = (LDKBalance*)orig; + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKBalance* a_conv = (LDKBalance*)a; + LDKBalance* b_conv = (LDKBalance*)b; + jboolean ret_val = Balance_eq(a_conv, b_conv); + return ret_val; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelMonitor this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -15601,6 +16904,24 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1be return ret_ref; } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -15808,6 +17129,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -15873,6 +17195,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33); (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKPublicKey revocation_pubkey_arg_ref; CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33); (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form); @@ -15961,6 +17284,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_ this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -16004,6 +17328,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0); outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKThirtyTwoBytes channel_keys_id_arg_ref; CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32); (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data); @@ -16073,6 +17398,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1 outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0); outpoint_conv = OutPoint_clone(&outpoint_conv); LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1); + output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1)); LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -16129,9 +17455,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jc JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(orig_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = Sign_clone(orig_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -16419,18 +17745,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSig LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); - *ret = InMemorySigner_as_BaseSign(&this_arg_conv); - return (uint64_t)ret; + LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); + *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) { LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = InMemorySigner_as_Sign(&this_arg_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = InMemorySigner_as_Sign(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) { @@ -16539,9 +17865,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterf LDKKeysManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); - *ret = KeysManager_as_KeysInterface(&this_arg_conv); - return (uint64_t)ret; + LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); + *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -16629,6 +17955,83 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKCounterpartyForwardingInfo this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + CounterpartyForwardingInfo_free(this_obj_conv); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val); +} + +JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) { + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCounterpartyForwardingInfo orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -16695,6 +18098,53 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unsp ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = CounterpartyForwardingInfo_clone(&val_conv); + ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg) { + LDKPublicKey node_id_arg_ref; + CHECK((*env)->GetArrayLength(env, node_id_arg) == 33); + (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form); + LDKInitFeatures features_arg_conv; + features_arg_conv.inner = (void*)(features_arg & (~1)); + features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0); + features_arg_conv = InitFeatures_clone(&features_arg_conv); + LDKCounterpartyForwardingInfo forwarding_info_arg_conv; + forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1)); + forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0); + forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv); + LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKChannelCounterparty orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -16800,6 +18250,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } @@ -16833,6 +18284,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendab this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } @@ -16896,6 +18348,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmat this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); } @@ -16914,6 +18367,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1cl this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); } @@ -16990,9 +18444,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1)); LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1)); LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1)); LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -17034,6 +18491,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(J JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) { LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1); + a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1)); LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); *ret_copy = PaymentSendFailure_parameter_error(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -17405,6 +18863,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ"); *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_ref; @@ -17418,6 +18877,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb CHECK((*env)->GetArrayLength(env, payment_hash) == 32); (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_conv; @@ -17427,36 +18887,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Message LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChannelManager_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChannelManager_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChannelManager_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChannelManager_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChannelManager_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) { @@ -17492,9 +18952,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Channel LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) { @@ -21319,12 +22779,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JN this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1); + val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1)); LightningError_set_action(&this_ptr_conv, val_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) { LDKStr err_arg_conv = java_to_owned_str(env, err_arg); LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1); + action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1)); LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -21356,6 +22818,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv CommitmentUpdate_free(this_obj_conv); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t p = 0; p < ret_var.datalen; p++) { + LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p]; + CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner; + if (ret_conv_15_var.is_owned) { + ret_conv_15_ref |= 1; + } + ret_arr_ptr[p] = ret_conv_15_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21379,6 +22863,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t t = 0; t < ret_var.datalen; t++) { + LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t]; + CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner; + if (ret_conv_19_var.is_owned) { + ret_conv_19_ref |= 1; + } + ret_arr_ptr[t] = ret_conv_19_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21402,6 +22908,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q]; + CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner; + if (ret_conv_16_var.is_owned) { + ret_conv_16_ref |= 1; + } + ret_arr_ptr[q] = ret_conv_16_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21425,6 +22953,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr); } +JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv); + int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen); + int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL); + for (size_t z = 0; z < ret_var.datalen; z++) { + LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z]; + CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner; + if (ret_conv_25_var.is_owned) { + ret_conv_25_ref |= 1; + } + ret_arr_ptr[z] = ret_conv_25_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0); + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -21595,49 +23145,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { - if ((this_ptr & 1) != 0) return; - LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1); - FREE((void*)this_ptr); - HTLCFailChannelUpdate_free(this_ptr_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig; - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_clone(orig_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) { - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ChannelUpdate_clone(&msg_conv); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) { - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) { - LDKPublicKey node_id_ref; - CHECK((*env)->GetArrayLength(env, node_id) == 33); - (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1); @@ -22240,16 +23747,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1w return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); - *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; -} - JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKReplyShortChannelIdsEnd obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22261,6 +23758,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); + *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) { LDKQueryChannelRange this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -22269,16 +23776,6 @@ JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blo return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); - *ret_conv = QueryChannelRange_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; -} - JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKQueryChannelRange obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22290,6 +23787,16 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1writ return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); + *ret_conv = QueryChannelRange_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = (*env)->GetArrayLength(env, ser); @@ -22311,6 +23818,17 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1writ return ret_arr; } +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKGossipTimestampFilter obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = (*env)->GetArrayLength(env, ser); @@ -22321,15 +23839,11 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read return (uint64_t)ret_conv; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) { - LDKGossipTimestampFilter obj_conv; - obj_conv.inner = (void*)(obj & (~1)); - obj_conv.is_owned = false; - LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv); - int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); - (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); - CVec_u8Z_free(ret_var); - return ret_arr; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageHandler_free(this_ptr_conv); } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22354,18 +23868,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_ LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22390,18 +23922,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_ LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -22474,9 +24006,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1); - LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); - *ret = SocketDescriptor_clone(orig_conv); - return (uint64_t)ret; + LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); + *ret_ret = SocketDescriptor_clone(orig_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -22540,7 +24072,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, PeerManager_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) { LDKMessageHandler message_handler_conv; message_handler_conv.inner = (void*)(message_handler & (~1)); message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0); @@ -22557,7 +24089,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *en // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv); + LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1); + if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) { + // If this_arg is a JCalls struct, then we need to increment the refcnt in it. + LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv); + } + LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22680,6 +24217,26 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secr return ret_arr; } +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + Transaction_free(ret_var); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) { LDKPublicKey per_commitment_point_ref; CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33); @@ -23193,6 +24750,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1t this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv); } @@ -23201,6 +24759,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32); (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data); LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1); + transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1)); LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -23849,11 +25408,106 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_ return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKBuiltCommitmentTransaction orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBuiltCommitmentTransaction orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKBuiltCommitmentTransaction obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ"); + *ret_conv = BuiltCommitmentTransaction_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (uint64_t)ret_conv; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKBuiltCommitmentTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); + funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); + int8_tArray ret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); + (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); + return ret_arr; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKBuiltCommitmentTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + unsigned char funding_key_arr[32]; + CHECK((*env)->GetArrayLength(env, funding_key) == 32); + (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr); + unsigned char (*funding_key_ref)[32] = &funding_key_arr; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); + funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); + int8_tArray ret_arr = (*env)->NewByteArray(env, 64); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); + (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); + return ret_arr; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ClosingTransaction_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23863,42 +25517,88 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_ return ret_ref; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) { - LDKBuiltCommitmentTransaction obj_conv; - obj_conv.inner = (void*)(obj & (~1)); - obj_conv.is_owned = false; - LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv); + return (uint64_t)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv); int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); - CVec_u8Z_free(ret_var); return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = (*env)->GetArrayLength(env, ser); - ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ"); - *ret_conv = BuiltCommitmentTransaction_read(ser_ref); - (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); - return (uint64_t)ret_conv; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + return ret_arr; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { - LDKBuiltCommitmentTransaction this_arg_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKTrustedClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + TrustedClosingTransaction_free(this_obj_conv); +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + Transaction_free(ret_var); + return ret_arr; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKu8slice funding_redeemscript_ref; funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); int8_tArray ret_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data); (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); return ret_arr; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { - LDKBuiltCommitmentTransaction this_arg_conv; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; unsigned char funding_key_arr[32]; @@ -23909,7 +25609,7 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransact funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript); funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL); int8_tArray ret_arr = (*env)->NewByteArray(env, 64); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form); (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0); return ret_arr; } @@ -24241,6 +25941,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKInitFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) { LDKNodeFeatures ret_var = NodeFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24263,6 +25971,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNodeFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) { LDKChannelFeatures ret_var = ChannelFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24285,6 +26001,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIE return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) { LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -24307,6 +26031,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIE return ret_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKInvoiceFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) { LDKInitFeatures this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -24602,6 +26334,27 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compat return ret_val; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageReader_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1); + LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType"); + *ret_ret = Type_clone(orig_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Type_free(this_ptr_conv); +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -24759,6 +26512,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHop_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHop_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRouteHop obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -24787,6 +26559,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclas Route_free(this_obj_conv); } +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKRoute this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv); + jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL); + ; + for (size_t m = 0; m < ret_var.datalen; m++) { + LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m]; + int64_tArray ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen); + int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL); + for (size_t k = 0; k < ret_conv_12_var.datalen; k++) { + LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k]; + CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner; + if (ret_conv_12_conv_10_var.is_owned) { + ret_conv_12_conv_10_ref |= 1; + } + ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref; + } + (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0); + FREE(ret_conv_12_var.data); + (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr); + } + FREE(ret_var.data); + return ret_arr; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) { LDKRoute this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -24871,6 +26672,41 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, j return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Route_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = Route_eq(&a_conv, &b_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_fees(&this_arg_conv); + return ret_val; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_amount(&this_arg_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRoute obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -24899,17 +26735,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, j RouteHint_free(this_obj_conv); } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKRouteHint a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHint b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKRouteHint orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24924,6 +26749,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *en return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHint o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHint_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHint a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHint b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKRouteHintHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -25020,6 +26864,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minim this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv); } @@ -25038,6 +26883,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maxim this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -25050,7 +26896,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); fees_arg_conv = RoutingFees_clone(&fees_arg_conv); LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1); + htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1)); LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -25061,17 +26909,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e return ret_ref; } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKRouteHintHop a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHintHop b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKRouteHintHop orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -25086,6 +26923,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRouteHintHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHintHop_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKRouteHintHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHintHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) { LDKPublicKey our_node_id_ref; CHECK((*env)->GetArrayLength(env, our_node_id) == 33); @@ -25209,55 +27065,86 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env NetworkGraph_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKNetworkGraph orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKReadOnlyNetworkGraph this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ReadOnlyNetworkGraph_free(this_obj_conv); +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + NetworkUpdate_free(this_ptr_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig; + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKLockedNetworkGraph this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - LockedNetworkGraph_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_update_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKNetGraphMsgHandler this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - NetGraphMsgHandler_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) { + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t chain_access, int64_t logger) { - LDKThirtyTwoBytes genesis_hash_ref; - CHECK((*env)->GetArrayLength(env, genesis_hash) == 32); - (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data); - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { - // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); - } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - if (logger_conv.free == LDKLogger_JCalls_free) { - // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKLogger_JCalls_cloned(&logger_conv); - } - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) { + LDKPublicKey node_id_ref; + CHECK((*env)->GetArrayLength(env, node_id) == 33); + (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj; + LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNetGraphMsgHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKNetGraphMsgHandler this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + NetGraphMsgHandler_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -25267,28 +27154,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNI return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph(JNIEnv *env, jclass clz, int64_t chain_access, int64_t logger, int64_t network_graph) { - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) { + LDKNetworkGraph network_graph_conv; + network_graph_conv.inner = (void*)(network_graph & (~1)); + network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); if (logger_conv.free == LDKLogger_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKNetworkGraph network_graph_conv; - network_graph_conv.inner = (void*)(network_graph & (~1)); - network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); - network_graph_conv = NetworkGraph_clone(&network_graph_conv); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv); + LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -25302,64 +27198,34 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKNetGraphMsgHandler this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKLockedNetworkGraph this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; } - return ret_ref; + NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -25444,6 +27310,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1h this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -25499,6 +27366,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1l JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new(JNIEnv *env, jclass clz, int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) { LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRoutingFees fees_arg_conv; fees_arg_conv.inner = (void*)(fees_arg & (~1)); fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); @@ -25687,6 +27555,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sa this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv); } @@ -25735,6 +27604,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *en two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0); two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv); LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1); + capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1)); LDKChannelAnnouncement announcement_message_arg_conv; announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1)); announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0); @@ -25857,6 +27727,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv * return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKRoutingFees o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RoutingFees_hash(&o_conv); + return ret_val; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKRoutingFees obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -26259,6 +28137,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *e return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1node_1from_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -26290,19 +28182,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1chann LDKChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -26313,19 +28203,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1chann LDKUnsignedChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - if (chain_access_conv.free == LDKAccess_JCalls_free) { + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + if (chain_access_conv.some.free == LDKAccess_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. - LDKAccess_JCalls_cloned(&chain_access_conv); + LDKAccess_JCalls_cloned(&chain_access_conv.some); } - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -26336,6 +28224,16 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1 NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent); } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKPublicKey _node_id_ref; + CHECK((*env)->GetArrayLength(env, _node_id) == 33); + (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form); + NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -26417,9 +28315,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Pe LDKFilesystemPersister this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist"); - *ret = FilesystemPersister_as_Persist(&this_arg_conv); - return (uint64_t)ret; + LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist"); + *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv); + return (uint64_t)ret_ret; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) { @@ -26436,7 +28334,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free( ChannelManagerPersister_free(this_ptr_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t peer_manager, int64_t logger) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) { LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1); if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) { // If this_arg is a JCalls struct, then we need to increment the refcnt in it. @@ -26453,6 +28351,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start( LDKChannelManager channel_manager_conv; channel_manager_conv.inner = (void*)(channel_manager & (~1)); channel_manager_conv.is_owned = false; + LDKNetGraphMsgHandler net_graph_msg_handler_conv; + net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1)); + net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0); LDKPeerManager peer_manager_conv; peer_manager_conv.inner = (void*)(peer_manager & (~1)); peer_manager_conv.is_owned = false; @@ -26461,7 +28362,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start( // If this_arg is a JCalls struct, then we need to increment the refcnt in it. LDKLogger_JCalls_cloned(&logger_conv); } - LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv); + LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26775,6 +28676,12 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env return ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKCurrency* o_conv = (LDKCurrency*)(o & ~1); + int64_t ret_val = Currency_hash(o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKCurrency* a_conv = (LDKCurrency*)(a & ~1); LDKCurrency* b_conv = (LDKCurrency*)(b & ~1); @@ -26789,6 +28696,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jcla Sha256_free(this_obj_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKSha256 orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKSha256 ret_var = Sha256_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKSha256 o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Sha256_hash(&o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKSha256 a_conv; a_conv.inner = (void*)(a & (~1)); @@ -26800,11 +28729,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jc return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKSha256 orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKDescription this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + Description_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKDescription orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKSha256 ret_var = Sha256_clone(&orig_conv); + LDKDescription ret_var = Description_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26814,11 +28750,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKDescription this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - Description_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKDescription o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Description_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26832,11 +28769,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *en return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKDescription orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKPayeePubKey this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PayeePubKey_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKPayeePubKey orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKDescription ret_var = Description_clone(&orig_conv); + LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26846,11 +28790,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv * return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKPayeePubKey this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PayeePubKey_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKPayeePubKey o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PayeePubKey_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26864,11 +28809,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *en return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKPayeePubKey orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKExpiryTime this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ExpiryTime_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKExpiryTime orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); + LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26878,11 +28830,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv * return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKExpiryTime this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ExpiryTime_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKExpiryTime o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = ExpiryTime_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26896,11 +28849,18 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKExpiryTime orig_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKMinFinalCltvExpiry this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + MinFinalCltvExpiry_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKMinFinalCltvExpiry orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); + LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -26910,11 +28870,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *e return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKMinFinalCltvExpiry this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - MinFinalCltvExpiry_free(this_obj_conv); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKMinFinalCltvExpiry o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv); + return ret_val; } JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { @@ -26928,20 +28889,6 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNI return ret_val; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKMinFinalCltvExpiry orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1); @@ -26989,6 +28936,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIE return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKFallback* o_conv = (LDKFallback*)o; + int64_t ret_val = Fallback_hash(o_conv); + return ret_val; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKFallback* a_conv = (LDKFallback*)a; LDKFallback* b_conv = (LDKFallback*)b; @@ -27003,17 +28956,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv InvoiceSignature_free(this_obj_conv); } -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKInvoiceSignature a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKInvoiceSignature b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); - return ret_val; -} - JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKInvoiceSignature orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -27028,24 +28970,24 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNI return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKPrivateRoute this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PrivateRoute_free(this_obj_conv); -} - -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { - LDKPrivateRoute a_conv; +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKInvoiceSignature a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = false; - LDKPrivateRoute b_conv; + LDKInvoiceSignature b_conv; b_conv.inner = (void*)(b & (~1)); b_conv.is_owned = false; - jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); return ret_val; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKPrivateRoute this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PrivateRoute_free(this_obj_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKPrivateRoute orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -27060,6 +29002,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) { + LDKPrivateRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PrivateRoute_hash(&o_conv); + return ret_val; +} + +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { + LDKPrivateRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKPrivateRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + return ret_val; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) { LDKSignedRawInvoice this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -27616,6 +29577,11 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1des return ret_conv; } +JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) { + jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret()); + return ret_conv; +} + JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) { jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets()); return ret_conv; @@ -27636,6 +29602,11 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1sign return ret_conv; } +JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) { + jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount()); + return ret_conv; +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) { LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1); LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1); @@ -27707,6 +29678,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1chan } LDKCurrency network_conv = LDKCurrency_from_java(env, network); LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1); + amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1)); LDKStr description_conv = java_to_owned_str(env, description); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv); diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index 5e40e6a2..df5e0c9c 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -407,6 +407,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTr JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_TrustedClosingTransactionNoneZ_result_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1result_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_TrustedClosingTransactionNoneZ_get_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_TrustedClosingTransactionNoneZ_get_err + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok @@ -759,6 +783,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKNetworkUpdate_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKNetworkUpdate; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCOption_NetworkUpdateZ_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKCOption_NetworkUpdateZ; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKSpendableOutputDescriptor_ref_from_ptr @@ -783,14 +823,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescr JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: LDKHTLCFailChannelUpdate_ref_from_ptr - * Signature: (J)Lorg/ldk/impl/bindings/LDKHTLCFailChannelUpdate; - */ -JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: LDKMessageSendEvent_ref_from_ptr @@ -975,6 +1007,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDe JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneNoneZ_result_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1result_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneNoneZ_get_ok + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneNoneZ_get_err + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKC2Tuple_SignatureCVec_SignatureZZ_new @@ -1071,6 +1127,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1comm JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: BaseSign_validate_holder_commitment + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: BaseSign_channel_keys_id @@ -1087,6 +1151,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: BaseSign_validate_counterparty_revocation + * Signature: (JJ[B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + /* * Class: org_ldk_impl_bindings * Method: BaseSign_sign_holder_commitment_and_htlcs @@ -1122,10 +1194,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_ /* * Class: org_ldk_impl_bindings * Method: BaseSign_sign_closing_transaction - * Signature: (J[B)J + * Signature: (JJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction - (JNIEnv *, jclass, jlong, jbyteArray); + (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -1775,6 +1847,70 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErr JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKType_new + * Signature: (Lorg/ldk/impl/bindings/LDKType;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKType_1new + (JNIEnv *, jclass, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: Type_type_id + * Signature: (J)S + */ +JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_Type_1type_1id + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Type_debug_str + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Type_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Type_1write + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCOption_TypeZ_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKCOption_TypeZ; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_COption_TypeZDecodeErrorZ_result_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1result_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_COption_TypeZDecodeErrorZ_get_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_COption_TypeZDecodeErrorZ_get_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_SiPrefixNoneZ_result_ok @@ -2247,6 +2383,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKClosureReason_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKClosureReason; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKEvent_ref_from_ptr @@ -2327,6 +2471,22 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new (JNIEnv *, jclass, jlongArray); +/* + * Class: org_ldk_impl_bindings + * Method: LDKBalance_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKBalance; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCVec_BalanceZ_new + * Signature: ([J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new + (JNIEnv *, jclass, jlongArray); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok @@ -2351,6 +2511,62 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHas JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneLightningErrorZ_result_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneLightningErrorZ_get_ok + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_NoneLightningErrorZ_get_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_PublicKeyTypeZ_new + * Signature: ([BJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1new + (JNIEnv *, jclass, jbyteArray, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_PublicKeyTypeZ_get_a + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1a + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKC2Tuple_PublicKeyTypeZ_get_b + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PublicKeyTypeZ_1get_1b + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCVec_C2Tuple_PublicKeyTypeZZ_new + * Signature: ([J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKeyTypeZZ_1new + (JNIEnv *, jclass, jlongArray); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_boolLightningErrorZ_result_ok @@ -2423,30 +2639,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnno JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new (JNIEnv *, jclass, jlongArray); -/* - * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneLightningErrorZ_result_ok - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneLightningErrorZ_get_ok - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: LDKCResult_NoneLightningErrorZ_get_err - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok @@ -2519,6 +2711,30 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandle JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKAccess_new + * Signature: (Lorg/ldk/impl/bindings/LDKAccess;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new + (JNIEnv *, jclass, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: Access_get_utxo + * Signature: (J[BJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo + (JNIEnv *, jclass, jlong, jbyteArray, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCOption_AccessZ_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKCOption_AccessZ; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok @@ -3575,6 +3791,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCrea JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKFilter_new + * Signature: (Lorg/ldk/impl/bindings/LDKFilter;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new + (JNIEnv *, jclass, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: Filter_register_tx + * Signature: (J[B[B)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx + (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); + +/* + * Class: org_ldk_impl_bindings + * Method: Filter_register_output + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCOption_FilterZ_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKCOption_FilterZ; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKMessageSendEventsProvider_new @@ -3625,24 +3873,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pendi /* * Class: org_ldk_impl_bindings - * Method: LDKAccess_new - * Signature: (Lorg/ldk/impl/bindings/LDKAccess;)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new - (JNIEnv *, jclass, jobject); - -/* - * Class: org_ldk_impl_bindings - * Method: Access_get_utxo - * Signature: (J[BJ)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo - (JNIEnv *, jclass, jlong, jbyteArray, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: LDKListen_new - * Signature: (Lorg/ldk/impl/bindings/LDKListen;)J + * Method: LDKListen_new + * Signature: (Lorg/ldk/impl/bindings/LDKListen;)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKListen_1new (JNIEnv *, jclass, jobject); @@ -3703,30 +3935,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: LDKFilter_new - * Signature: (Lorg/ldk/impl/bindings/LDKFilter;)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new - (JNIEnv *, jclass, jobject); - -/* - * Class: org_ldk_impl_bindings - * Method: Filter_register_tx - * Signature: (J[B[B)V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx - (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); - -/* - * Class: org_ldk_impl_bindings - * Method: Filter_register_output - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output - (JNIEnv *, jclass, jlong, jlong); - /* * Class: org_ldk_impl_bindings * Method: LDKPersist_new @@ -3967,14 +4175,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update (JNIEnv *, jclass, jlong, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: RoutingMessageHandler_handle_htlc_fail_channel_update - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update - (JNIEnv *, jclass, jlong, jlong); - /* * Class: org_ldk_impl_bindings * Method: RoutingMessageHandler_get_next_channel_announcements @@ -4031,6 +4231,54 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1query_1short_1channel_1ids (JNIEnv *, jclass, jlong, jbyteArray, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCustomMessageReader_new + * Signature: (Lorg/ldk/impl/bindings/LDKCustomMessageReader;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new + (JNIEnv *, jclass, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: CustomMessageReader_read + * Signature: (JS[B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read + (JNIEnv *, jclass, jlong, jshort, jbyteArray); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCustomMessageHandler_new + * Signature: (Lorg/ldk/impl/bindings/LDKCustomMessageHandler;Lorg/ldk/impl/bindings/LDKCustomMessageReader;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new + (JNIEnv *, jclass, jobject, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCustomMessageHandler_get_CustomMessageReader + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CustomMessageHandler_handle_custom_message + * Signature: (JJ[B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: org_ldk_impl_bindings + * Method: CustomMessageHandler_get_and_clear_pending_msg + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKSocketDescriptor_new @@ -4495,6 +4743,30 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransa JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CResult_TrustedClosingTransactionNoneZ_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_TrustedClosingTransactionNoneZ_err + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_TrustedClosingTransactionNoneZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CResult_CommitmentTransactionDecodeErrorZ_ok @@ -4975,6 +5247,38 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransac JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: COption_NetworkUpdateZ_some + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_NetworkUpdateZ_none + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_NetworkUpdateZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_NetworkUpdateZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CVec_SpendableOutputDescriptorZ_free @@ -5183,6 +5487,38 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescri JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneNoneZ_ok + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneNoneZ_err + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneNoneZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneNoneZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: C2Tuple_SignatureCVec_SignatureZZ_clone @@ -5823,6 +6159,70 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: COption_TypeZ_some + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_TypeZ_none + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_TypeZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_TypeZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_COption_TypeZDecodeErrorZ_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_COption_TypeZDecodeErrorZ_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_COption_TypeZDecodeErrorZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_COption_TypeZDecodeErrorZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CResult_SiPrefixNoneZ_ok @@ -6463,6 +6863,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u3 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free (JNIEnv *, jclass, jlongArray); +/* + * Class: org_ldk_impl_bindings + * Method: CVec_BalanceZ_free + * Signature: ([J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free + (JNIEnv *, jclass, jlongArray); + /* * Class: org_ldk_impl_bindings * Method: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok @@ -6487,6 +6895,70 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashCh JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneLightningErrorZ_ok + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneLightningErrorZ_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneLightningErrorZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_NoneLightningErrorZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: C2Tuple_PublicKeyTypeZ_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: C2Tuple_PublicKeyTypeZ_new + * Signature: ([BJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new + (JNIEnv *, jclass, jbyteArray, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: C2Tuple_PublicKeyTypeZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CVec_C2Tuple_PublicKeyTypeZZ_free + * Signature: ([J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free + (JNIEnv *, jclass, jlongArray); + /* * Class: org_ldk_impl_bindings * Method: CResult_boolLightningErrorZ_ok @@ -6559,38 +7031,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnounce JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free (JNIEnv *, jclass, jlongArray); -/* - * Class: org_ldk_impl_bindings - * Method: CResult_NoneLightningErrorZ_ok - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok - (JNIEnv *, jclass); - -/* - * Class: org_ldk_impl_bindings - * Method: CResult_NoneLightningErrorZ_err - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: CResult_NoneLightningErrorZ_free - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: CResult_NoneLightningErrorZ_clone - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: CVec_PublicKeyZ_free @@ -6695,6 +7135,30 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: COption_AccessZ_some + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_AccessZ_none + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_AccessZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CResult_DirectionalChannelInfoDecodeErrorZ_ok @@ -6887,14 +7351,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeEr JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: CResult_NetworkGraphDecodeErrorZ_clone - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: CResult_NetAddressu8Z_ok @@ -8079,6 +8535,30 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreation JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: COption_FilterZ_some + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_FilterZ_none + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_FilterZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: PaymentPurpose_free @@ -8111,6 +8591,86 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1paym JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment (JNIEnv *, jclass, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_counterparty_force_closed + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed + (JNIEnv *, jclass, jstring); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_holder_force_closed + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_cooperative_closure + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_commitment_tx_confirmed + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_processing_error + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error + (JNIEnv *, jclass, jstring); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_disconnected_peer + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_outdated_channel_manager + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: ClosureReason_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Event_free @@ -8153,11 +8713,11 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent /* * Class: org_ldk_impl_bindings - * Method: Event_payment_failed - * Signature: ([BZ)J + * Method: Event_payment_path_failed + * Signature: ([BZJZ[J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed - (JNIEnv *, jclass, jbyteArray, jboolean); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed + (JNIEnv *, jclass, jbyteArray, jboolean, jlong, jboolean, jlongArray); /* * Class: org_ldk_impl_bindings @@ -8183,6 +8743,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded (JNIEnv *, jclass, jlong, jboolean); +/* + * Class: org_ldk_impl_bindings + * Method: Event_channel_closed + * Signature: ([BJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed + (JNIEnv *, jclass, jbyteArray, jlong); + /* * Class: org_ldk_impl_bindings * Method: Event_write @@ -8335,14 +8903,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1chann JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error (JNIEnv *, jclass, jbyteArray, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: MessageSendEvent_payment_failure_network_update - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: MessageSendEvent_send_channel_range_query @@ -9319,6 +9879,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ChainMonitor_get_claimable_balances + * Signature: (J[J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances + (JNIEnv *, jclass, jlong, jlongArray); + /* * Class: org_ldk_impl_bindings * Method: ChainMonitor_as_Listen @@ -9465,10 +10033,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent /* * Class: org_ldk_impl_bindings - * Method: MonitorEvent_commitment_tx_broadcasted + * Method: MonitorEvent_commitment_tx_confirmed * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed (JNIEnv *, jclass, jlong); /* @@ -9503,6 +10071,62 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read (JNIEnv *, jclass, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: Balance_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Balance_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_claimable_on_channel_close + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_claimable_awaiting_confirmations + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_contentious_claimable + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_maybe_claimable_htlcawaiting_timeout + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: org_ldk_impl_bindings + * Method: Balance_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: ChannelMonitor_free @@ -9647,6 +10271,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1r JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelMonitor_get_claimable_balances + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Persist_free @@ -10409,114 +11041,210 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_free + * Method: CounterpartyForwardingInfo_free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_get_node_id - * Signature: (J)[B + * Method: CounterpartyForwardingInfo_get_fee_base_msat + * Signature: (J)I */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_set_node_id - * Signature: (J[B)V + * Method: CounterpartyForwardingInfo_set_fee_base_msat + * Signature: (JI)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id - (JNIEnv *, jclass, jlong, jbyteArray); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat + (JNIEnv *, jclass, jlong, jint); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_get_features - * Signature: (J)J + * Method: CounterpartyForwardingInfo_get_fee_proportional_millionths + * Signature: (J)I */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_set_features - * Signature: (JJ)V + * Method: CounterpartyForwardingInfo_set_fee_proportional_millionths + * Signature: (JI)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths + (JNIEnv *, jclass, jlong, jint); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_get_unspendable_punishment_reserve - * Signature: (J)J + * Method: CounterpartyForwardingInfo_get_cltv_expiry_delta + * Signature: (J)S */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve +JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_set_unspendable_punishment_reserve - * Signature: (JJ)V + * Method: CounterpartyForwardingInfo_set_cltv_expiry_delta + * Signature: (JS)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta + (JNIEnv *, jclass, jlong, jshort); /* * Class: org_ldk_impl_bindings - * Method: ChannelCounterparty_clone + * Method: CounterpartyForwardingInfo_new + * Signature: (IIS)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new + (JNIEnv *, jclass, jint, jint, jshort); + +/* + * Class: org_ldk_impl_bindings + * Method: CounterpartyForwardingInfo_clone * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_free + * Method: ChannelCounterparty_free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_channel_id + * Method: ChannelCounterparty_get_node_id * Signature: (J)[B */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_channel_id + * Method: ChannelCounterparty_set_node_id * Signature: (J[B)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id (JNIEnv *, jclass, jlong, jbyteArray); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_counterparty + * Method: ChannelCounterparty_get_features * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_counterparty + * Method: ChannelCounterparty_set_features * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_funding_txo + * Method: ChannelCounterparty_get_unspendable_punishment_reserve * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_set_unspendable_punishment_reserve + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_get_forwarding_info + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_set_forwarding_info + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_new + * Signature: ([BJJJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new + (JNIEnv *, jclass, jbyteArray, jlong, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_get_channel_id + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_set_channel_id + * Signature: (J[B)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id + (JNIEnv *, jclass, jlong, jbyteArray); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_get_counterparty + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_set_counterparty + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_get_funding_txo + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo (JNIEnv *, jclass, jlong); /* @@ -14095,6 +14823,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LightningError_1clone JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentUpdate_get_update_add_htlcs + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_add_htlcs @@ -14103,6 +14839,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs (JNIEnv *, jclass, jlong, jlongArray); +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentUpdate_get_update_fulfill_htlcs + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fulfill_htlcs @@ -14111,6 +14855,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs (JNIEnv *, jclass, jlong, jlongArray); +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentUpdate_get_update_fail_htlcs + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fail_htlcs @@ -14119,6 +14871,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs (JNIEnv *, jclass, jlong, jlongArray); +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentUpdate_get_update_fail_malformed_htlcs + * Signature: (J)[J + */ +JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CommitmentUpdate_set_update_fail_malformed_htlcs @@ -14175,46 +14935,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: HTLCFailChannelUpdate_free - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: HTLCFailChannelUpdate_clone - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: HTLCFailChannelUpdate_channel_update_message - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message - (JNIEnv *, jclass, jlong); - -/* - * Class: org_ldk_impl_bindings - * Method: HTLCFailChannelUpdate_channel_closed - * Signature: (JZ)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed - (JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: org_ldk_impl_bindings - * Method: HTLCFailChannelUpdate_node_failure - * Signature: ([BZ)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure - (JNIEnv *, jclass, jbyteArray, jboolean); - /* * Class: org_ldk_impl_bindings * Method: ChannelMessageHandler_free @@ -14679,6 +15399,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ReplyShortChannelIdsEnd_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ReplyShortChannelIdsEnd_read @@ -14689,18 +15417,18 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read /* * Class: org_ldk_impl_bindings - * Method: ReplyShortChannelIdsEnd_write - * Signature: (J)[B + * Method: QueryChannelRange_end_blocknum + * Signature: (J)I */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: QueryChannelRange_end_blocknum - * Signature: (J)I + * Method: QueryChannelRange_write + * Signature: (J)[B */ -JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write (JNIEnv *, jclass, jlong); /* @@ -14711,14 +15439,6 @@ JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blockn JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read (JNIEnv *, jclass, jbyteArray); -/* - * Class: org_ldk_impl_bindings - * Method: QueryChannelRange_write - * Signature: (J)[B - */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: ReplyChannelRange_read @@ -14735,6 +15455,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: GossipTimestampFilter_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: GossipTimestampFilter_read @@ -14745,10 +15473,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read /* * Class: org_ldk_impl_bindings - * Method: GossipTimestampFilter_write - * Signature: (J)[B + * Method: CustomMessageHandler_free + * Signature: (J)V */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free (JNIEnv *, jclass, jlong); /* @@ -14783,6 +15511,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1M JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: IgnoringMessageHandler_as_CustomMessageReader + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: IgnoringMessageHandler_as_CustomMessageHandler + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ErroringMessageHandler_free @@ -14930,10 +15674,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free /* * Class: org_ldk_impl_bindings * Method: PeerManager_new - * Signature: (J[B[BJ)J + * Signature: (J[B[BJJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PeerManager_1new - (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jlong); + (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -15015,6 +15759,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occu JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret (JNIEnv *, jclass, jbyteArray, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: build_closing_transaction + * Signature: (JJ[B[BJ)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray, jlong); + /* * Class: org_ldk_impl_bindings * Method: derive_private_key @@ -15873,120 +16625,216 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransacti /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_free + * Method: ClosingTransaction_free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_clone - * Signature: (J)J + * Method: ClosingTransaction_new + * Signature: (JJ[B[BJ)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_write - * Signature: (J)[B + * Method: ClosingTransaction_trust + * Signature: (J)J */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_read - * Signature: ([B)J + * Method: ClosingTransaction_verify + * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify + (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_commitment_number + * Method: ClosingTransaction_to_holder_value_sat * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_to_broadcaster_value_sat + * Method: ClosingTransaction_to_counterparty_value_sat * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_to_countersignatory_value_sat - * Signature: (J)J + * Method: ClosingTransaction_to_holder_script + * Signature: (J)[B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_feerate_per_kw - * Signature: (J)I + * Method: ClosingTransaction_to_counterparty_script + * Signature: (J)[B */ -JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_trust - * Signature: (J)J + * Method: TrustedClosingTransaction_free + * Signature: (J)V */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: CommitmentTransaction_verify - * Signature: (JJJJ)J + * Method: TrustedClosingTransaction_built_transaction + * Signature: (J)[B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1verify - (JNIEnv *, jclass, jlong, jlong, jlong, jlong); +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: TrustedCommitmentTransaction_free - * Signature: (J)V + * Method: TrustedClosingTransaction_get_sighash_all + * Signature: (J[BJ)[B */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free - (JNIEnv *, jclass, jlong); +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all + (JNIEnv *, jclass, jlong, jbyteArray, jlong); /* * Class: org_ldk_impl_bindings - * Method: TrustedCommitmentTransaction_txid - * Signature: (J)[B + * Method: TrustedClosingTransaction_sign + * Signature: (J[B[BJ)[B */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid - (JNIEnv *, jclass, jlong); +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign + (JNIEnv *, jclass, jlong, jbyteArray, jbyteArray, jlong); /* * Class: org_ldk_impl_bindings - * Method: TrustedCommitmentTransaction_built_transaction - * Signature: (J)J + * Method: CommitmentTransaction_free + * Signature: (J)V */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: TrustedCommitmentTransaction_keys + * Method: CommitmentTransaction_clone * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: TrustedCommitmentTransaction_get_htlc_sigs - * Signature: (J[BJ)J + * Method: CommitmentTransaction_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_read + * Signature: ([B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read + (JNIEnv *, jclass, jbyteArray); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_commitment_number + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_to_broadcaster_value_sat + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_to_countersignatory_value_sat + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_feerate_per_kw + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_trust + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CommitmentTransaction_verify + * Signature: (JJJJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1verify + (JNIEnv *, jclass, jlong, jlong, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: TrustedCommitmentTransaction_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: TrustedCommitmentTransaction_txid + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: TrustedCommitmentTransaction_built_transaction + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: TrustedCommitmentTransaction_keys + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: TrustedCommitmentTransaction_get_htlc_sigs + * Signature: (J[BJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1get_1htlc_1sigs (JNIEnv *, jclass, jlong, jbyteArray, jlong); @@ -16111,6 +16959,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: InitFeatures_requires_unknown_bits + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: NodeFeatures_empty @@ -16127,6 +16983,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: NodeFeatures_requires_unknown_bits + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ChannelFeatures_empty @@ -16143,6 +17007,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelFeatures_requires_unknown_bits + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InvoiceFeatures_empty @@ -16159,6 +17031,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_requires_unknown_bits + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InitFeatures_supports_payment_secret @@ -16375,6 +17255,30 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1lega JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CustomMessageReader_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Type_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Type_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Type_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: RouteHop_free @@ -16495,6 +17399,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1new JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: RouteHop_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: RouteHop_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: RouteHop_write @@ -16519,6 +17439,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHop_1read JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: Route_get_paths + * Signature: (J)[[J + */ +JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Route_set_paths @@ -16543,6 +17471,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: Route_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1hash + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Route_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Route_get_total_fees + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: Route_get_total_amount + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Route_write @@ -16569,20 +17529,28 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free /* * Class: org_ldk_impl_bindings - * Method: RouteHint_eq - * Signature: (JJ)Z + * Method: RouteHint_clone + * Signature: (J)J */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: RouteHint_clone + * Method: RouteHint_hash * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: RouteHint_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: RouteHintHop_free @@ -16697,20 +17665,28 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new /* * Class: org_ldk_impl_bindings - * Method: RouteHintHop_eq - * Signature: (JJ)Z + * Method: RouteHintHop_clone + * Signature: (J)J */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: RouteHintHop_clone + * Method: RouteHintHop_hash * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: RouteHintHop_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: get_keysend_route @@ -16737,68 +17713,108 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free /* * Class: org_ldk_impl_bindings - * Method: NetworkGraph_clone - * Signature: (J)J + * Method: ReadOnlyNetworkGraph_free + * Signature: (J)V */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: LockedNetworkGraph_free + * Method: NetworkUpdate_free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: NetGraphMsgHandler_free - * Signature: (J)V + * Method: NetworkUpdate_clone + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: NetGraphMsgHandler_new - * Signature: ([BJJ)J + * Method: NetworkUpdate_channel_update_message + * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new - (JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: NetGraphMsgHandler_from_net_graph - * Signature: (JJJ)J + * Method: NetworkUpdate_channel_closed + * Signature: (JZ)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1from_1net_1graph - (JNIEnv *, jclass, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed + (JNIEnv *, jclass, jlong, jboolean); /* * Class: org_ldk_impl_bindings - * Method: NetGraphMsgHandler_add_chain_access - * Signature: (JJ)V + * Method: NetworkUpdate_node_failure + * Signature: ([BZ)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure + (JNIEnv *, jclass, jbyteArray, jboolean); + +/* + * Class: org_ldk_impl_bindings + * Method: NetworkUpdate_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: NetGraphMsgHandler_read_locked_graph + * Method: NetGraphMsgHandler_as_EventHandler * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: LockedNetworkGraph_graph + * Method: NetGraphMsgHandler_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: NetGraphMsgHandler_get_network_graph * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1get_1network_1graph (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: NetGraphMsgHandler_set_network_graph + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1set_1network_1graph + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: NetGraphMsgHandler_new + * Signature: (JJJ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new + (JNIEnv *, jclass, jlong, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: NetGraphMsgHandler_add_chain_access + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: NetGraphMsgHandler_as_RoutingMessageHandler @@ -17183,6 +18199,14 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: RoutingFees_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: RoutingFees_write @@ -17431,6 +18455,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new (JNIEnv *, jclass, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: NetworkGraph_read_only + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: NetworkGraph_update_node_from_announcement @@ -17471,6 +18503,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update (JNIEnv *, jclass, jlong, jlong, jboolean); +/* + * Class: org_ldk_impl_bindings + * Method: NetworkGraph_fail_node + * Signature: (J[BZ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node + (JNIEnv *, jclass, jlong, jbyteArray, jboolean); + /* * Class: org_ldk_impl_bindings * Method: NetworkGraph_update_channel @@ -17554,10 +18594,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free /* * Class: org_ldk_impl_bindings * Method: BackgroundProcessor_start - * Signature: (JJJJJJ)J + * Signature: (JJJJJJJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start - (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong); + (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -17839,6 +18879,14 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_Currency_1simnet JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_Currency_1signet (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: Currency_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Currency_1hash + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Currency_eq @@ -17855,14 +18903,6 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free (JNIEnv *, jclass, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: Sha256_eq - * Signature: (JJ)Z - */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq - (JNIEnv *, jclass, jlong, jlong); - /* * Class: org_ldk_impl_bindings * Method: Sha256_clone @@ -17873,20 +18913,28 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Sha256_1clone /* * Class: org_ldk_impl_bindings - * Method: Description_free - * Signature: (J)V + * Method: Sha256_hash + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Sha256_1hash (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: Description_eq + * Method: Sha256_eq * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: Description_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Description_clone @@ -17897,20 +18945,28 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Description_1clone /* * Class: org_ldk_impl_bindings - * Method: PayeePubKey_free - * Signature: (J)V + * Method: Description_hash + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Description_1hash (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: PayeePubKey_eq + * Method: Description_eq * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: PayeePubKey_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: PayeePubKey_clone @@ -17921,20 +18977,28 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone /* * Class: org_ldk_impl_bindings - * Method: ExpiryTime_free - * Signature: (J)V + * Method: PayeePubKey_hash + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ExpiryTime_eq + * Method: PayeePubKey_eq * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ExpiryTime_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ExpiryTime_clone @@ -17945,20 +19009,28 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone /* * Class: org_ldk_impl_bindings - * Method: MinFinalCltvExpiry_free - * Signature: (J)V + * Method: ExpiryTime_hash + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: MinFinalCltvExpiry_eq + * Method: ExpiryTime_eq * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: MinFinalCltvExpiry_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: MinFinalCltvExpiry_clone @@ -17967,6 +19039,22 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: MinFinalCltvExpiry_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: MinFinalCltvExpiry_eq + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: Fallback_free @@ -18007,6 +19095,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash (JNIEnv *, jclass, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: Fallback_hash + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Fallback_1hash + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Fallback_eq @@ -18023,6 +19119,14 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceSignature_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InvoiceSignature_eq @@ -18033,18 +19137,26 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq /* * Class: org_ldk_impl_bindings - * Method: InvoiceSignature_clone + * Method: PrivateRoute_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: PrivateRoute_clone * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: PrivateRoute_free - * Signature: (J)V + * Method: PrivateRoute_hash + * Signature: (J)J */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash (JNIEnv *, jclass, jlong); /* @@ -18055,14 +19167,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq (JNIEnv *, jclass, jlong, jlong); -/* - * Class: org_ldk_impl_bindings - * Method: PrivateRoute_clone - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone - (JNIEnv *, jclass, jlong); - /* * Class: org_ldk_impl_bindings * Method: SignedRawInvoice_into_parts @@ -18519,6 +19623,14 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1descript JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: SemanticError_no_payment_secret + * Signature: ()Lorg/ldk/enums/SemanticError; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret + (JNIEnv *, jclass); + /* * Class: org_ldk_impl_bindings * Method: SemanticError_multiple_payment_secrets @@ -18551,6 +19663,14 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1rec JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: SemanticError_imprecise_amount + * Signature: ()Lorg/ldk/enums/SemanticError; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount + (JNIEnv *, jclass); + /* * Class: org_ldk_impl_bindings * Method: SemanticError_eq diff --git a/src/main/jni/org_ldk_impl_bindings_LDKBalance.h b/src/main/jni/org_ldk_impl_bindings_LDKBalance.h new file mode 100644 index 00000000..b65cbfca --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKBalance.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKBalance */ + +#ifndef _Included_org_ldk_impl_bindings_LDKBalance +#define _Included_org_ldk_impl_bindings_LDKBalance +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKBalance + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKCOption_AccessZ.h b/src/main/jni/org_ldk_impl_bindings_LDKCOption_AccessZ.h new file mode 100644 index 00000000..ddc64e37 --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKCOption_AccessZ.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKCOption_AccessZ */ + +#ifndef _Included_org_ldk_impl_bindings_LDKCOption_AccessZ +#define _Included_org_ldk_impl_bindings_LDKCOption_AccessZ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKCOption_AccessZ + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKCOption_FilterZ.h b/src/main/jni/org_ldk_impl_bindings_LDKCOption_FilterZ.h new file mode 100644 index 00000000..6947bf9e --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKCOption_FilterZ.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKCOption_FilterZ */ + +#ifndef _Included_org_ldk_impl_bindings_LDKCOption_FilterZ +#define _Included_org_ldk_impl_bindings_LDKCOption_FilterZ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKCOption_FilterZ + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ.h b/src/main/jni/org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ.h new file mode 100644 index 00000000..b04cfb04 --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ */ + +#ifndef _Included_org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ +#define _Included_org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKCOption_NetworkUpdateZ + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKCOption_TypeZ.h b/src/main/jni/org_ldk_impl_bindings_LDKCOption_TypeZ.h new file mode 100644 index 00000000..33f2f030 --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKCOption_TypeZ.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKCOption_TypeZ */ + +#ifndef _Included_org_ldk_impl_bindings_LDKCOption_TypeZ +#define _Included_org_ldk_impl_bindings_LDKCOption_TypeZ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKCOption_TypeZ + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKClosureReason.h b/src/main/jni/org_ldk_impl_bindings_LDKClosureReason.h new file mode 100644 index 00000000..4b4f479a --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKClosureReason.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKClosureReason */ + +#ifndef _Included_org_ldk_impl_bindings_LDKClosureReason +#define _Included_org_ldk_impl_bindings_LDKClosureReason +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKClosureReason + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKHTLCFailChannelUpdate.h b/src/main/jni/org_ldk_impl_bindings_LDKHTLCFailChannelUpdate.h deleted file mode 100644 index e14bad00..00000000 --- a/src/main/jni/org_ldk_impl_bindings_LDKHTLCFailChannelUpdate.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_ldk_impl_bindings_LDKHTLCFailChannelUpdate */ - -#ifndef _Included_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate -#define _Included_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_ldk_impl_bindings_LDKHTLCFailChannelUpdate - * Method: init - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/main/jni/org_ldk_impl_bindings_LDKNetworkUpdate.h b/src/main/jni/org_ldk_impl_bindings_LDKNetworkUpdate.h new file mode 100644 index 00000000..e66c4b21 --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKNetworkUpdate.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKNetworkUpdate */ + +#ifndef _Included_org_ldk_impl_bindings_LDKNetworkUpdate +#define _Included_org_ldk_impl_bindings_LDKNetworkUpdate +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKNetworkUpdate + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ts/bindings.c b/ts/bindings.c index d5fb1658..1f6be38b 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -269,10 +269,12 @@ static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) { case 1: return LDKSemanticError_MultiplePaymentHashes; case 2: return LDKSemanticError_NoDescription; case 3: return LDKSemanticError_MultipleDescriptions; - case 4: return LDKSemanticError_MultiplePaymentSecrets; - case 5: return LDKSemanticError_InvalidFeatures; - case 6: return LDKSemanticError_InvalidRecoveryId; - case 7: return LDKSemanticError_InvalidSignature; + case 4: return LDKSemanticError_NoPaymentSecret; + case 5: return LDKSemanticError_MultiplePaymentSecrets; + case 6: return LDKSemanticError_InvalidFeatures; + case 7: return LDKSemanticError_InvalidRecoveryId; + case 8: return LDKSemanticError_InvalidSignature; + case 9: return LDKSemanticError_ImpreciseAmount; } abort(); } @@ -282,10 +284,12 @@ static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) { case LDKSemanticError_MultiplePaymentHashes: return 1; case LDKSemanticError_NoDescription: return 2; case LDKSemanticError_MultipleDescriptions: return 3; - case LDKSemanticError_MultiplePaymentSecrets: return 4; - case LDKSemanticError_InvalidFeatures: return 5; - case LDKSemanticError_InvalidRecoveryId: return 6; - case LDKSemanticError_InvalidSignature: return 7; + case LDKSemanticError_NoPaymentSecret: return 4; + case LDKSemanticError_MultiplePaymentSecrets: return 5; + case LDKSemanticError_InvalidFeatures: return 6; + case LDKSemanticError_InvalidRecoveryId: return 7; + case LDKSemanticError_InvalidSignature: return 8; + case LDKSemanticError_ImpreciseAmount: return 9; default: abort(); } } @@ -550,6 +554,23 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) { + return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(val->result_ok); + LDKTrustedClosingTransaction res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +void __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok; } @@ -917,12 +938,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr( uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1; return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref; } - case LDKMonitorEvent_CommitmentTxBroadcasted: { - LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted; - CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1; - return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref; + case LDKMonitorEvent_CommitmentTxConfirmed: { + LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed; + CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1; + return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref; } default: abort(); } @@ -964,6 +985,40 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTrans default: abort(); } } +uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) { + LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1); + switch(obj->tag) { + case LDKNetworkUpdate_ChannelUpdateMessage: { + LDKChannelUpdate msg_var = obj->channel_update_message.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref; + } + case LDKNetworkUpdate_ChannelClosed: { + return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent; + } + case LDKNetworkUpdate_NodeFailure: { + int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33); + return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent; + } + default: abort(); + } +} +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_NetworkUpdateZ_Some: { + uint64_t some_ref = ((uint64_t)&obj->some) | 1; + return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref; + } + case LDKCOption_NetworkUpdateZ_None: { + return 0 /* LDKCOption_NetworkUpdateZ - None */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) { LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1); switch(obj->tag) { @@ -1043,27 +1098,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u default: abort(); } } -uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) { - LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1); - switch(obj->tag) { - case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: { - LDKChannelUpdate msg_var = obj->channel_update_message.msg; - CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; - return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref; - } - case LDKHTLCFailChannelUpdate_ChannelClosed: { - return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent; - } - case LDKHTLCFailChannelUpdate_NodeFailure: { - int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33); - return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent; - } - default: abort(); - } -} uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) { LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1); switch(obj->tag) { @@ -1206,10 +1240,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1; return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref; } - case LDKMessageSendEvent_PaymentFailureNetworkUpdate: { - uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1; - return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref; - } case LDKMessageSendEvent_SendChannelRangeQuery: { int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33); @@ -1408,6 +1438,19 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDe uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) { + return ((LDKCResult_NoneNoneZ*)arg)->result_ok; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) { LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); LDKSignature a_ref; @@ -1482,8 +1525,10 @@ typedef struct LDKBaseSign_JCalls { atomic_size_t refcnt; uint32_t get_per_commitment_point_meth; uint32_t release_commitment_secret_meth; + uint32_t validate_holder_commitment_meth; uint32_t channel_keys_id_meth; uint32_t sign_counterparty_commitment_meth; + uint32_t validate_counterparty_revocation_meth; uint32_t sign_holder_commitment_and_htlcs_meth; uint32_t sign_justice_revoked_output_meth; uint32_t sign_justice_revoked_htlc_meth; @@ -1497,8 +1542,10 @@ static void LDKBaseSign_JCalls_free(void* this_arg) { if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { js_free(j_calls->get_per_commitment_point_meth); js_free(j_calls->release_commitment_secret_meth); + js_free(j_calls->validate_holder_commitment_meth); js_free(j_calls->channel_keys_id_meth); js_free(j_calls->sign_counterparty_commitment_meth); + js_free(j_calls->validate_counterparty_revocation_meth); js_free(j_calls->sign_holder_commitment_and_htlcs_meth); js_free(j_calls->sign_justice_revoked_output_meth); js_free(j_calls->sign_justice_revoked_htlc_meth); @@ -1525,6 +1572,21 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32); return ret_ref; } +LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + LDKHolderCommitmentTransaction holder_tx_var = *holder_tx; + holder_tx_var = HolderCommitmentTransaction_clone(holder_tx); + CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner; + if (holder_tx_var.is_owned) { + holder_tx_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref); + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth); @@ -1548,6 +1610,15 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; } +LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(secret_arr + 4), *secret, 32); + uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr); + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx; @@ -1618,13 +1689,17 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) { +LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; - LDKTransaction closing_tx_var = closing_tx; - int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen); - Transaction_free(closing_tx_var); - uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr); + LDKClosingTransaction closing_tx_var = *closing_tx; + // Warning: we may need a move here but no clone is available for LDKClosingTransaction + CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner; + if (closing_tx_var.is_owned) { + closing_tx_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1674,8 +1749,10 @@ static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* .this_arg = (void*) calls, .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall, .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall, + .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall, .channel_keys_id = channel_keys_id_LDKBaseSign_jcall, .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall, + .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall, .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall, .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall, .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall, @@ -1708,6 +1785,16 @@ int8_tArray __attribute__((visibility("default"))) TS_BaseSign_release_commitme return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + LDKHolderCommitmentTransaction holder_tx_conv; + holder_tx_conv.inner = (void*)(holder_tx & (~1)); + holder_tx_conv.is_owned = false; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv); + return (uint64_t)ret_conv; +} + int8_tArray __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); @@ -1725,6 +1812,17 @@ uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_c return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + unsigned char secret_arr[32]; + CHECK(*((uint32_t*)secret) == 32); + memcpy(secret_arr, (uint8_t*)(secret + 4), 32); + unsigned char (*secret_ref)[32] = &secret_arr; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); LDKHolderCommitmentTransaction commitment_tx_conv; @@ -1788,15 +1886,13 @@ uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_h return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) { +uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); - LDKTransaction closing_tx_ref; - closing_tx_ref.datalen = *((uint32_t*)closing_tx); - closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes"); - memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen); - closing_tx_ref.data_is_owned = true; + LDKClosingTransaction closing_tx_conv; + closing_tx_conv.inner = (void*)(closing_tx & (~1)); + closing_tx_conv.is_owned = false; LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); - *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref); + *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv); return (uint64_t)ret_conv; } @@ -1901,9 +1997,9 @@ jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); CHECK(val->result_ok); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(&(*val->contents.result)); - return (uint64_t)ret; + LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *res_ret = Sign_clone(&(*val->contents.result)); + return (uint64_t)res_ret; } uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); @@ -2719,9 +2815,9 @@ uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_s uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) { @@ -2921,6 +3017,119 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKType_JCalls { + atomic_size_t refcnt; + uint32_t type_id_meth; + uint32_t debug_str_meth; + uint32_t write_meth; +} LDKType_JCalls; +static void LDKType_JCalls_free(void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->type_id_meth); + js_free(j_calls->debug_str_meth); + js_free(j_calls->write_meth); + FREE(j_calls); + } +} +uint16_t type_id_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + return js_invoke_function_0(j_calls->type_id_meth); +} +LDKStr debug_str_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth); + LDKStr ret_conv = str_ref_to_owned_c(ret); + return ret_conv; +} +LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + int8_tArray ret = js_invoke_function_0(j_calls->write_meth); + LDKCVec_u8Z ret_ref; + ret_ref.datalen = *((uint32_t*)ret); + ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen); + return ret_ref; +} +static void LDKType_JCalls_cloned(LDKType* new_obj) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) { + LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKType ret = { + .this_arg = (void*) calls, + .type_id = type_id_LDKType_jcall, + .debug_str = debug_str_LDKType_jcall, + .write = write_LDKType_jcall, + .cloned = LDKType_JCalls_cloned, + .free = LDKType_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) { + LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType"); + *res_ptr = LDKType_init(o); + return (long)res_ptr; +} +int16_t __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg); + return ret_val; +} + +jstring __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg); + jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); + return ret_conv; +} + +int8_tArray __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_TypeZ_Some: { + LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType"); + *some_ret = Type_clone(&obj->some); + return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_TypeZ_None: { + return 0 /* LDKCOption_TypeZ - None */; + } + default: abort(); + } +} +jboolean __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) { return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok; } @@ -3387,6 +3596,37 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_pt default: abort(); } } +uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) { + LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1); + switch(obj->tag) { + case LDKClosureReason_CounterpartyForceClosed: { + LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg; + jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len); + return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv; + } + case LDKClosureReason_HolderForceClosed: { + return 0 /* LDKClosureReason - HolderForceClosed */; + } + case LDKClosureReason_CooperativeClosure: { + return 0 /* LDKClosureReason - CooperativeClosure */; + } + case LDKClosureReason_CommitmentTxConfirmed: { + return 0 /* LDKClosureReason - CommitmentTxConfirmed */; + } + case LDKClosureReason_ProcessingError: { + LDKStr err_str = obj->processing_error.err; + jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len); + return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv; + } + case LDKClosureReason_DisconnectedPeer: { + return 0 /* LDKClosureReason - DisconnectedPeer */; + } + case LDKClosureReason_OutdatedChannelManager: { + return 0 /* LDKClosureReason - OutdatedChannelManager */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) { LDKEvent *obj = (LDKEvent*)(ptr & ~1); switch(obj->tag) { @@ -3409,10 +3649,21 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32); return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr; } - case LDKEvent_PaymentFailed: { + case LDKEvent_PaymentPathFailed: { int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32); - return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest; + memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32); + uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1; + LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path; + uint32_tArray path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4); + for (size_t k = 0; k < path_var.datalen; k++) { + LDKRouteHop path_conv_10_var = path_var.data[k]; + CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1; + path_arr_ptr[k] = path_conv_10_ref; + } + return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; } case LDKEvent_PendingHTLCsForwardable: { return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable; @@ -3431,6 +3682,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1; return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx; } + case LDKEvent_ChannelClosed: { + int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32); + uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1; + return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) reason_ref; + } default: abort(); } } @@ -3562,6 +3819,48 @@ static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVe } return ret; } +uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) { + LDKBalance *obj = (LDKBalance*)(ptr & ~1); + switch(obj->tag) { + case LDKBalance_ClaimableOnChannelClose: { + return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis; + } + case LDKBalance_ClaimableAwaitingConfirmations: { + return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height; + } + case LDKBalance_ContentiousClaimable: { + return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height; + } + case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: { + return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height; + } + default: abort(); + } +} +uint32_t __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) { + LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ"); + ret->datalen = *((uint32_t*)elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data"); + uint32_t *java_elems = (uint32_t*)(elems + 4); + for (size_t i = 0; i < ret->datalen; i++) { + uint32_t arr_elem = java_elems[i]; + LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + } + return (uint64_t)ret; +} +static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) { + LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = Balance_clone(&orig->data[i]); + } + return ret; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; } @@ -3580,6 +3879,70 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKLightningError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) { + LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + LDKPublicKey a_ref; + CHECK(*((uint32_t*)a) == 33); + memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33); + ret->a = a_ref; + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + b_conv = Type_clone(&b_conv); + ret->b = b_conv; + return (uint64_t)ret; +} +int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_a(uint32_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + int8_tArray a_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(a_arr + 4), tuple->a.compressed_form, 33); + return a_arr; +} +uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_b(uint32_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + LDKType* b_ret =MALLOC(sizeof(LDKType), "LDKType"); + *b_ret = Type_clone(&tuple->b); + return (uint64_t)b_ret; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) { + LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ"); + ret->datalen = *((uint32_t*)elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data"); + uint32_t *java_elems = (uint32_t*)(elems + 4); + for (size_t i = 0; i < ret->datalen; i++) { + uint32_t arr_elem = java_elems[i]; + LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + } + return (uint64_t)ret; +} +static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) { + LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]); + } + return ret; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok; } @@ -3690,23 +4053,6 @@ static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCV } return ret; } -jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) { - return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; -} -void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(val->result_ok); - return *val->contents.result; -} -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKLightningError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t err_ref = (uint64_t)err_var.inner & ~1; - return err_ref; -} jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; } @@ -3761,24 +4107,91 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } -jboolean __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) { - return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; +typedef struct LDKAccess_JCalls { + atomic_size_t refcnt; + uint32_t get_utxo_meth; +} LDKAccess_JCalls; +static void LDKAccess_JCalls_free(void* this_arg) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->get_utxo_meth); + FREE(j_calls); + } } -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) { - LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); - CHECK(val->result_ok); - LDKDirectionalChannelInfo res_var = (*val->contents.result); - CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t res_ref = (uint64_t)res_var.inner & ~1; - return res_ref; +LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32); + uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) { - LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKDecodeError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. +static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) { + LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKAccess ret = { + .this_arg = (void*) calls, + .get_utxo = get_utxo_LDKAccess_jcall, + .free = LDKAccess_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) { + LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); + *res_ptr = LDKAccess_init(o); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { + LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); + unsigned char genesis_hash_arr[32]; + CHECK(*((uint32_t*)genesis_hash) == 32); + memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32); + unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; + LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); + *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_AccessZ_Some: { + LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_AccessZ_None: { + return 0 /* LDKCOption_AccessZ - None */; + } + default: abort(); + } +} +jboolean __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKDirectionalChannelInfo res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } @@ -4765,6 +5178,103 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCrea uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; return err_ref; } +typedef struct LDKFilter_JCalls { + atomic_size_t refcnt; + uint32_t register_tx_meth; + uint32_t register_output_meth; +} LDKFilter_JCalls; +static void LDKFilter_JCalls_free(void* this_arg) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->register_tx_meth); + js_free(j_calls->register_output_meth); + FREE(j_calls); + } +} +void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(txid_arr + 4), *txid, 32); + LDKu8slice script_pubkey_var = script_pubkey; + int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen); + js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr); +} +LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + LDKWatchedOutput output_var = output; + CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t output_ref = (uint64_t)output_var.inner; + if (output_var.is_owned) { + output_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref); + LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); + ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) { + LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKFilter ret = { + .this_arg = (void*) calls, + .register_tx = register_tx_LDKFilter_jcall, + .register_output = register_output_LDKFilter_jcall, + .free = LDKFilter_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) { + LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); + *res_ptr = LDKFilter_init(o); + return (long)res_ptr; +} +void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + unsigned char txid_arr[32]; + CHECK(*((uint32_t*)txid) == 32); + memcpy(txid_arr, (uint8_t*)(txid + 4), 32); + unsigned char (*txid_ref)[32] = &txid_arr; + LDKu8slice script_pubkey_ref; + script_pubkey_ref.datalen = *((uint32_t*)script_pubkey); + script_pubkey_ref.data = (int8_t*)(script_pubkey + 4); + (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + LDKWatchedOutput output_conv; + output_conv.inner = (void*)(output & (~1)); + output_conv.is_owned = (output & 1) || (output == 0); + output_conv = WatchedOutput_clone(&output_conv); + LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); + *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_FilterZ_Some: { + LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_FilterZ_None: { + return 0 /* LDKCOption_FilterZ - None */; + } + default: abort(); + } +} typedef struct LDKMessageSendEventsProvider_JCalls { atomic_size_t refcnt; uint32_t get_and_clear_pending_msg_events_meth; @@ -4841,12 +5351,11 @@ static void LDKEventHandler_JCalls_free(void* this_arg) { FREE(j_calls); } } -void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { +void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg; - LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *event_copy = event; - uint64_t event_ref = (uint64_t)event_copy; - js_invoke_function_1(j_calls->handle_event_meth, event_ref); + LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion"); + *ret_event = Event_clone(event); + js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event); } static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg; @@ -4871,7 +5380,7 @@ long __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS O } void __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) { LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1); - LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1); + LDKEvent* event_conv = (LDKEvent*)event; (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv); } @@ -4888,9 +5397,9 @@ static void LDKEventsProvider_JCalls_free(void* this_arg) { } void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; - LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); - *ret = handler; - js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret); + LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *handler_ret = handler; + js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret); } static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg; @@ -4919,58 +5428,6 @@ void __attribute__((visibility("default"))) TS_EventsProvider_process_pending_e (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv); } -typedef struct LDKAccess_JCalls { - atomic_size_t refcnt; - uint32_t get_utxo_meth; -} LDKAccess_JCalls; -static void LDKAccess_JCalls_free(void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->get_utxo_meth); - FREE(j_calls); - } -} -LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32); - uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); - LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); - return ret_conv; -} -static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) { - LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); - atomic_init(&calls->refcnt, 1); - //TODO: Assign calls->o from o - - LDKAccess ret = { - .this_arg = (void*) calls, - .get_utxo = get_utxo_LDKAccess_jcall, - .free = LDKAccess_JCalls_free, - }; - return ret; -} -long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) { - LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *res_ptr = LDKAccess_init(o); - return (long)res_ptr; -} -uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { - LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); - unsigned char genesis_hash_arr[32]; - CHECK(*((uint32_t*)genesis_hash) == 32); - memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32); - unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; - LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); - *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); - return (uint64_t)ret_conv; -} - typedef struct LDKListen_JCalls { atomic_size_t refcnt; uint32_t block_connected_meth; @@ -5177,121 +5634,39 @@ ptrArray __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(u return ret_arr; } -typedef struct LDKFilter_JCalls { +typedef struct LDKPersist_JCalls { atomic_size_t refcnt; - uint32_t register_tx_meth; - uint32_t register_output_meth; -} LDKFilter_JCalls; -static void LDKFilter_JCalls_free(void* this_arg) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + uint32_t persist_new_channel_meth; + uint32_t update_persisted_channel_meth; +} LDKPersist_JCalls; +static void LDKPersist_JCalls_free(void* this_arg) { + LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->register_tx_meth); - js_free(j_calls->register_output_meth); + js_free(j_calls->persist_new_channel_meth); + js_free(j_calls->update_persisted_channel_meth); FREE(j_calls); } } -void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(txid_arr + 4), *txid, 32); - LDKu8slice script_pubkey_var = script_pubkey; - int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen); - js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr); -} -LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - LDKWatchedOutput output_var = output; - CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t output_ref = (uint64_t)output_var.inner; - if (output_var.is_owned) { - output_ref |= 1; +LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) { + LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; + LDKOutPoint id_var = id; + CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t id_ref = (uint64_t)id_var.inner; + if (id_var.is_owned) { + id_ref |= 1; } - uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref); - LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); - ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); - return ret_conv; -} -static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) { - LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); - atomic_init(&calls->refcnt, 1); - //TODO: Assign calls->o from o - - LDKFilter ret = { - .this_arg = (void*) calls, - .register_tx = register_tx_LDKFilter_jcall, - .register_output = register_output_LDKFilter_jcall, - .free = LDKFilter_JCalls_free, - }; - return ret; -} -long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) { - LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *res_ptr = LDKFilter_init(o); - return (long)res_ptr; -} -void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - unsigned char txid_arr[32]; - CHECK(*((uint32_t*)txid) == 32); - memcpy(txid_arr, (uint8_t*)(txid + 4), 32); - unsigned char (*txid_ref)[32] = &txid_arr; - LDKu8slice script_pubkey_ref; - script_pubkey_ref.datalen = *((uint32_t*)script_pubkey); - script_pubkey_ref.data = (int8_t*)(script_pubkey + 4); - (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); -} - -uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - LDKWatchedOutput output_conv; - output_conv.inner = (void*)(output & (~1)); - output_conv.is_owned = (output & 1) || (output == 0); - output_conv = WatchedOutput_clone(&output_conv); - LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); - *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -typedef struct LDKPersist_JCalls { - atomic_size_t refcnt; - uint32_t persist_new_channel_meth; - uint32_t update_persisted_channel_meth; -} LDKPersist_JCalls; -static void LDKPersist_JCalls_free(void* this_arg) { - LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->persist_new_channel_meth); - js_free(j_calls->update_persisted_channel_meth); - FREE(j_calls); - } -} -LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) { - LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; - LDKOutPoint id_var = id; - CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t id_ref = (uint64_t)id_var.inner; - if (id_var.is_owned) { - id_ref |= 1; - } - LDKChannelMonitor data_var = *data; - data_var = ChannelMonitor_clone(data); - CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t data_ref = (uint64_t)data_var.inner; - if (data_var.is_owned) { - data_ref |= 1; - } - uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref); - LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1)); + LDKChannelMonitor data_var = *data; + data_var = ChannelMonitor_clone(data); + CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t data_ref = (uint64_t)data_var.inner; + if (data_var.is_owned) { + data_ref |= 1; + } + uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref); + LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1)); return ret_conv; } LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) { @@ -5998,7 +6373,6 @@ typedef struct LDKRoutingMessageHandler_JCalls { uint32_t handle_node_announcement_meth; uint32_t handle_channel_announcement_meth; uint32_t handle_channel_update_meth; - uint32_t handle_htlc_fail_channel_update_meth; uint32_t get_next_channel_announcements_meth; uint32_t get_next_node_announcements_meth; uint32_t sync_routing_table_meth; @@ -6013,7 +6387,6 @@ static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) { js_free(j_calls->handle_node_announcement_meth); js_free(j_calls->handle_channel_announcement_meth); js_free(j_calls->handle_channel_update_meth); - js_free(j_calls->handle_htlc_fail_channel_update_meth); js_free(j_calls->get_next_channel_announcements_meth); js_free(j_calls->get_next_node_announcements_meth); js_free(j_calls->sync_routing_table_meth); @@ -6069,11 +6442,6 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) { - LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - uint64_t ret_update = (uint64_t)update; - js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update); -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); @@ -6207,7 +6575,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall, - .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall, .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall, .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall, .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall, @@ -6256,12 +6623,6 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle return (uint64_t)ret_conv; } -void __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update; - (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv); -} - uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) { LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); @@ -6365,6 +6726,151 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle return (uint64_t)ret_conv; } +typedef struct LDKCustomMessageReader_JCalls { + atomic_size_t refcnt; + uint32_t read_meth; +} LDKCustomMessageReader_JCalls; +static void LDKCustomMessageReader_JCalls_free(void* this_arg) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->read_meth); + FREE(j_calls); + } +} +LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + LDKu8slice buffer_var = buffer; + int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen); + uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr); + LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) { + LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKCustomMessageReader ret = { + .this_arg = (void*) calls, + .read = read_LDKCustomMessageReader_jcall, + .free = LDKCustomMessageReader_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) { + LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *res_ptr = LDKCustomMessageReader_init(o); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) { + LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1); + LDKu8slice buffer_ref; + buffer_ref.datalen = *((uint32_t*)buffer); + buffer_ref.data = (int8_t*)(buffer + 4); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageHandler_JCalls { + atomic_size_t refcnt; + LDKCustomMessageReader_JCalls* CustomMessageReader; + uint32_t handle_custom_message_meth; + uint32_t get_and_clear_pending_msg_meth; +} LDKCustomMessageHandler_JCalls; +static void LDKCustomMessageHandler_JCalls_free(void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->handle_custom_message_meth); + js_free(j_calls->get_and_clear_pending_msg_meth); + FREE(j_calls); + } +} +LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType"); + *msg_ret = msg; + int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33); + uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr); + LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr; + ret_constr.datalen = *((uint32_t*)ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + ret_constr.data = NULL; + uint32_t* ret_vals = (uint32_t*)(ret + 4); + for (size_t c = 0; c < ret_constr.datalen; c++) { + uint32_t ret_conv_28 = ret_vals[c]; + LDKC2Tuple_PublicKeyTypeZ ret_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1); + ret_conv_28_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1)); + ret_constr.data[c] = ret_conv_28_conv; + } + return ret_constr; +} +static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); + atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) { + LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKCustomMessageHandler ret = { + .this_arg = (void*) calls, + .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall, + .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall, + .free = LDKCustomMessageHandler_JCalls_free, + .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader), + }; + calls->CustomMessageReader = ret.CustomMessageReader.this_arg; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) { + LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1); + LDKPublicKey sender_node_id_ref; + CHECK(*((uint32_t*)sender_node_id) == 33); + memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref); + return (uint64_t)ret_conv; +} + +uint32_tArray __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t c = 0; c < ret_var.datalen; c++) { + LDKC2Tuple_PublicKeyTypeZ* ret_conv_28_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_conv_28_ref = ret_var.data[c]; + ret_arr_ptr[c] = (uint64_t)ret_conv_28_ref; + } + FREE(ret_var.data); + return ret_arr; +} + typedef struct LDKSocketDescriptor_JCalls { atomic_size_t refcnt; uint32_t send_data_meth; @@ -6949,6 +7455,29 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTrans return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) { + LDKTrustedClosingTransaction o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() { + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_err(); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_TrustedClosingTransactionNoneZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) { LDKCommitmentTransaction o_conv; o_conv.inner = (void*)(o & (~1)); @@ -7350,6 +7879,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ uint32_t __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) { LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1); + o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1)); LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -7482,6 +8012,7 @@ void __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_t uint32_t __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) { LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1)); LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -7510,6 +8041,37 @@ uint32_t __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) { + LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1); + o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1)); + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() { + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_NetworkUpdateZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) { + LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig; + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) { LDKCVec_SpendableOutputDescriptorZ _res_constr; _res_constr.datalen = *((uint32_t*)_res); @@ -7722,6 +8284,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputD uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) { LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1); + o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1)); LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ"); *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -7751,6 +8314,32 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescr return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_ok(); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_err(); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneNoneZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) { + LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1); + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) { LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1); LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); @@ -7790,6 +8379,7 @@ void __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZ uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) { LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1)); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv); return (uint64_t)ret_conv; @@ -8161,6 +8751,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() { uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -8222,6 +8813,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailu uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ"); *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -8252,6 +8844,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSe uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -8325,6 +8918,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErro uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -8384,6 +8978,7 @@ void __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) { LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -8474,6 +9069,68 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) { + LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1); + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_none() { + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_TypeZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) { + LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig; + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) { + LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1); + o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1)); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) { + LDKDecodeError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = DecodeError_clone(&e_conv); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_COption_TypeZDecodeErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) { + LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) { LDKSiPrefix o_conv = LDKSiPrefix_from_js(o); LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ"); @@ -9110,6 +9767,7 @@ uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) { LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1); + b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1)); LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ"); *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv); return (uint64_t)ret_ref; @@ -9192,8 +9850,26 @@ void __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3 CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr); } +void __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) { + LDKCVec_BalanceZ _res_constr; + _res_constr.datalen = *((uint32_t*)_res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements"); + else + _res_constr.data = NULL; + uint32_t* _res_vals = (uint32_t*)(_res + 4); + for (size_t j = 0; j < _res_constr.datalen; j++) { + uint32_t _res_conv_9 = _res_vals[j]; + LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1); + FREE((void*)_res_conv_9); + _res_constr.data[j] = _res_conv_9_conv; + } + CVec_BalanceZ_free(_res_constr); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) { LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9216,44 +9892,115 @@ void __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannel CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) { - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_ok(o); +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() { + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_ok(); return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) { +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) { LDKLightningError e_conv; e_conv.inner = (void*)(e & (~1)); e_conv.is_owned = (e & 1) || (e == 0); e_conv = LightningError_clone(&e_conv); - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_err(e_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); return (uint64_t)ret_conv; } -void __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) { +void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) { if ((_res & 1) != 0) return; - LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1); + LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); FREE((void*)_res); - CResult_boolLightningErrorZ_free(_res_conv); + CResult_NoneLightningErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) { - LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1); - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv); +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) { + LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) { - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1); - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); - *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv); +uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) { + LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_clone(orig_conv); return (uint64_t)ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) { +uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) { + LDKPublicKey a_ref; + CHECK(*((uint32_t*)a) == 33); + memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33); + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv); + return (uint64_t)ret_ref; +} + +void __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + C2Tuple_PublicKeyTypeZ_free(_res_conv); +} + +void __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) { + LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr; + _res_constr.datalen = *((uint32_t*)_res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + _res_constr.data = NULL; + uint32_t* _res_vals = (uint32_t*)(_res + 4); + for (size_t c = 0; c < _res_constr.datalen; c++) { + uint32_t _res_conv_28 = _res_vals[c]; + LDKC2Tuple_PublicKeyTypeZ _res_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_28) & ~1); + FREE((void*)_res_conv_28); + _res_constr.data[c] = _res_conv_28_conv; + } + CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) { + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_ok(o); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) { + LDKLightningError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = LightningError_clone(&e_conv); + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_boolLightningErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) { + LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1); + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) { + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1); + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); + *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv); + return (uint64_t)ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) { LDKChannelAnnouncement a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); @@ -9313,36 +10060,6 @@ void __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint CVec_NodeAnnouncementZ_free(_res_constr); } -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() { - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_ok(); - return (uint64_t)ret_conv; -} - -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) { - LDKLightningError e_conv; - e_conv.inner = (void*)(e & (~1)); - e_conv.is_owned = (e & 1) || (e == 0); - e_conv = LightningError_clone(&e_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); - return (uint64_t)ret_conv; -} - -void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) { - if ((_res & 1) != 0) return; - LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); - FREE((void*)_res); - CResult_NoneLightningErrorZ_free(_res_conv); -} - -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) { - LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - void __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) { LDKCVec_PublicKeyZ _res_constr; _res_constr.datalen = *((uint32_t*)_res); @@ -9455,6 +10172,28 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) { + LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1); + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_AccessZ_none() { + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_AccessZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) { LDKDirectionalChannelInfo o_conv; o_conv.inner = (void*)(o & (~1)); @@ -9644,7 +10383,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeEr LDKNetworkGraph o_conv; o_conv.inner = (void*)(o & (~1)); o_conv.is_owned = (o & 1) || (o == 0); - o_conv = NetworkGraph_clone(&o_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9667,15 +10406,9 @@ void __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) { - LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1); - LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); - *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z"); *ret_conv = CResult_NetAddressu8Z_ok(o_conv); return (uint64_t)ret_conv; @@ -9703,6 +10436,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone( uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) { LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1); + o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1)); LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ"); *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9734,6 +10468,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8 uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ"); *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10935,6 +11670,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) { LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1); + e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1)); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10954,6 +11690,28 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) { + LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1); + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_FilterZ_none() { + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_FilterZ_free(_res_conv); +} + void __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1); @@ -10992,6 +11750,81 @@ uint32_t __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_p return ret_ref; } +void __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + ClosureReason_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) { + LDKClosureReason* orig_conv = (LDKClosureReason*)orig; + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) { + LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_holder_force_closed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_cooperative_closure(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_commitment_tx_confirmed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_processing_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_disconnected_peer(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_outdated_channel_manager(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) { + LDKClosureReason* obj_conv = (LDKClosureReason*)obj; + LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1); @@ -11026,6 +11859,7 @@ uint32_t __attribute__((visibility("default"))) TS_Event_payment_received(int8_ CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1); + purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -11042,12 +11876,29 @@ uint32_t __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArr return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_Event_payment_failed(int8_tArray payment_hash, jboolean rejected_by_dest) { +uint32_t __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path) { LDKThirtyTwoBytes payment_hash_ref; CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); + LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1); + network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1)); + LDKCVec_RouteHopZ path_constr; + path_constr.datalen = *((uint32_t*)path); + if (path_constr.datalen > 0) + path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + path_constr.data = NULL; + uint32_t* path_vals = (uint32_t*)(path + 4); + for (size_t k = 0; k < path_constr.datalen; k++) { + uint32_t path_conv_10 = path_vals[k]; + LDKRouteHop path_conv_10_conv; + path_conv_10_conv.inner = (void*)(path_conv_10 & (~1)); + path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0); + path_conv_10_conv = RouteHop_clone(&path_conv_10_conv); + path_constr.data[k] = path_conv_10_conv; + } LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest); + *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -11081,12 +11932,25 @@ uint32_t __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint uint32_t __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) { LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1); + fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, uint32_t reason) { + LDKThirtyTwoBytes channel_id_ref; + CHECK(*((uint32_t*)channel_id) == 32); + memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32); + LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1); + reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1)); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_channel_closed(channel_id_ref, reason_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) { LDKEvent* obj_conv = (LDKEvent*)obj; LDKCVec_u8Z ret_var = Event_write(obj_conv); @@ -11321,20 +12185,13 @@ uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_handle_erro CHECK(*((uint32_t*)node_id) == 33); memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1); + action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1)); LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_payment_failure_network_update(uint32_t update) { - LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1); - LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); - *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) { LDKPublicKey node_id_ref; CHECK(*((uint32_t*)node_id) == 33); @@ -12399,18 +13256,16 @@ void __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_ } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) { - LDKFilter *chain_source_conv_ptr = NULL; - if (chain_source != 0) { - LDKFilter chain_source_conv; - chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1); - chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *chain_source_conv_ptr = chain_source_conv; + LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ + if (chain_source_conv.tag == LDKCOption_FilterZ_Some) { + // Manually implement clone for Java trait instances } LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1); LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1); LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1); - LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv); + LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -12420,40 +13275,72 @@ uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t ch return ret_ref; } +uint32_tArray __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) { + LDKChainMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_ChannelDetailsZ ignored_channels_constr; + ignored_channels_constr.datalen = *((uint32_t*)ignored_channels); + if (ignored_channels_constr.datalen > 0) + ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + ignored_channels_constr.data = NULL; + uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4); + for (size_t q = 0; q < ignored_channels_constr.datalen; q++) { + uint32_t ignored_channels_conv_16 = ignored_channels_vals[q]; + LDKChannelDetails ignored_channels_conv_16_conv; + ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1)); + ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0); + ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv); + ignored_channels_constr.data[q] = ignored_channels_conv_16_conv; + } + LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + FREE(ret_var.data); + return ret_arr; +} + uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChainMonitor_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChainMonitor_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChainMonitor_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch"); - *ret = ChainMonitor_as_Watch(&this_arg_conv); - return (uint64_t)ret; + LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch"); + *ret_ret = ChainMonitor_as_Watch(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChainMonitor_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) { @@ -12575,13 +13462,13 @@ uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint3 return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_broadcasted(uint32_t a) { +uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) { LDKOutPoint a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); a_conv = OutPoint_clone(&a_conv); LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); - *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv); + *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -12627,6 +13514,56 @@ uint32_t __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray return (uint64_t)ret_conv; } +void __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Balance_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) { + LDKBalance* orig_conv = (LDKBalance*)orig; + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +jboolean __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) { + LDKBalance* a_conv = (LDKBalance*)a; + LDKBalance* b_conv = (LDKBalance*)b; + jboolean ret_val = Balance_eq(a_conv, b_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) { LDKChannelMonitor this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -12921,6 +13858,23 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_ return ret_ref; } +uint32_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -13126,6 +14080,7 @@ void __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_s this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -13191,6 +14146,7 @@ uint32_t __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript CHECK(*((uint32_t*)per_commitment_point_arg) == 33); memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKPublicKey revocation_pubkey_arg_ref; CHECK(*((uint32_t*)revocation_pubkey_arg) == 33); memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33); @@ -13278,6 +14234,7 @@ void __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_se this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -13321,6 +14278,7 @@ uint32_t __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0); outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKThirtyTwoBytes channel_keys_id_arg_ref; CHECK(*((uint32_t*)channel_keys_id_arg) == 32); memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32); @@ -13389,6 +14347,7 @@ uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_st outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0); outpoint_conv = OutPoint_clone(&outpoint_conv); LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1); + output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1)); LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -13444,9 +14403,9 @@ void __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) uint32_t __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) { LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(orig_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = Sign_clone(orig_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) { @@ -13734,18 +14693,18 @@ uint32_t __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(u LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); - *ret = InMemorySigner_as_BaseSign(&this_arg_conv); - return (uint64_t)ret; + LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); + *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) { LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = InMemorySigner_as_Sign(&this_arg_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = InMemorySigner_as_Sign(&this_arg_conv); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) { @@ -13851,9 +14810,9 @@ uint32_t __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface LDKKeysManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); - *ret = KeysManager_as_KeysInterface(&this_arg_conv); - return (uint64_t)ret; + LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); + *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) { @@ -13941,54 +14900,131 @@ uint32_t __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32 return ret_ref; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { - LDKChannelCounterparty this_obj_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) { + LDKCounterpartyForwardingInfo this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ChannelCounterparty_free(this_obj_conv); + CounterpartyForwardingInfo_free(this_obj_conv); } -int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { - LDKChannelCounterparty this_ptr_conv; +int32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); - return ret_arr; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { - LDKChannelCounterparty this_ptr_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK(*((uint32_t*)val) == 33); - memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); - ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); + CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { - LDKChannelCounterparty this_ptr_conv; +int32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { - LDKChannelCounterparty this_ptr_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); + CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val); +} + +int16_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) { + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) { + LDKCounterpartyForwardingInfo orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { + LDKChannelCounterparty this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ChannelCounterparty_free(this_obj_conv); +} + +int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); + return ret_arr; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK(*((uint32_t*)val) == 33); + memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); ChannelCounterparty_set_features(&this_ptr_conv, val_conv); } @@ -14007,6 +15043,53 @@ void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspenda ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = CounterpartyForwardingInfo_clone(&val_conv); + ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg) { + LDKPublicKey node_id_arg_ref; + CHECK(*((uint32_t*)node_id_arg) == 33); + memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33); + LDKInitFeatures features_arg_conv; + features_arg_conv.inner = (void*)(features_arg & (~1)); + features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0); + features_arg_conv = InitFeatures_clone(&features_arg_conv); + LDKCounterpartyForwardingInfo forwarding_info_arg_conv; + forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1)); + forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0); + forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv); + LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) { LDKChannelCounterparty orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -14112,6 +15195,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } @@ -14145,6 +15229,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_p this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } @@ -14208,6 +15293,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); } @@ -14226,6 +15312,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_s this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); } @@ -14302,9 +15389,12 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArr funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1)); LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1)); LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1)); LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -14346,6 +15436,7 @@ uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uin uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) { LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1); + a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1)); LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); *ret_copy = PaymentSendFailure_parameter_error(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -14691,6 +15782,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_create_inboun this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ"); *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_ref; @@ -14704,6 +15796,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_create_inboun CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_conv; @@ -14713,36 +15806,36 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSen LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChannelManager_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChannelManager_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChannelManager_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChannelManager_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChannelManager_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } jboolean __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) { @@ -14778,9 +15871,9 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMes LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) { @@ -18558,12 +19651,14 @@ void __attribute__((visibility("default"))) TS_LightningError_set_action(uint32 this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1); + val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1)); LightningError_set_action(&this_ptr_conv, val_conv); } uint32_t __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) { LDKStr err_arg_conv = str_ref_to_owned_c(err_arg); LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1); + action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1)); LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -18595,6 +19690,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t t CommitmentUpdate_free(this_obj_conv); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t p = 0; p < ret_var.datalen; p++) { + LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p]; + CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner; + if (ret_conv_15_var.is_owned) { + ret_conv_15_ref |= 1; + } + ret_arr_ptr[p] = ret_conv_15_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18617,6 +19733,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_ CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t t = 0; t < ret_var.datalen; t++) { + LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t]; + CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner; + if (ret_conv_19_var.is_owned) { + ret_conv_19_ref |= 1; + } + ret_arr_ptr[t] = ret_conv_19_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18639,6 +19776,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulf CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q]; + CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner; + if (ret_conv_16_var.is_owned) { + ret_conv_16_ref |= 1; + } + ret_arr_ptr[q] = ret_conv_16_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18661,6 +19819,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t z = 0; z < ret_var.datalen; z++) { + LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z]; + CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner; + if (ret_conv_25_var.is_owned) { + ret_conv_25_ref |= 1; + } + ret_arr_ptr[z] = ret_conv_25_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18826,49 +20005,6 @@ uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3 return ret_ref; } -void __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) { - if ((this_ptr & 1) != 0) return; - LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1); - FREE((void*)this_ptr); - HTLCFailChannelUpdate_free(this_ptr_conv); -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) { - LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig; - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_clone(orig_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_update_message(uint32_t msg) { - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ChannelUpdate_clone(&msg_conv); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) { - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) { - LDKPublicKey node_id_ref; - CHECK(*((uint32_t*)node_id) == 33); - memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - void __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1); @@ -19443,15 +20579,6 @@ int8_tArray __attribute__((visibility("default"))) TS_QueryShortChannelIds_writ return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); - *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) { LDKReplyShortChannelIdsEnd obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19463,6 +20590,15 @@ int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_w return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); + *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); + return (uint64_t)ret_conv; +} + int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) { LDKQueryChannelRange this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -19471,15 +20607,6 @@ int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknu return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); - *ret_conv = QueryChannelRange_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) { LDKQueryChannelRange obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19491,6 +20618,15 @@ int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_write(u return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); + *ret_conv = QueryChannelRange_read(ser_ref); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = *((uint32_t*)ser); @@ -19511,15 +20647,6 @@ int8_tArray __attribute__((visibility("default"))) TS_ReplyChannelRange_write(u return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ"); - *ret_conv = GossipTimestampFilter_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) { LDKGossipTimestampFilter obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19531,6 +20658,22 @@ int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_wri return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ"); + *ret_conv = GossipTimestampFilter_read(ser_ref); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageHandler_free(this_ptr_conv); +} + void __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) { LDKIgnoringMessageHandler this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -19553,22 +20696,40 @@ uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Me LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) { LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } -void __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) { - LDKErroringMessageHandler this_obj_conv; +uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv); + return (uint64_t)ret_ret; +} + +uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +void __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) { + LDKErroringMessageHandler this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); ErroringMessageHandler_free(this_obj_conv); @@ -19589,18 +20750,18 @@ uint32_t __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_Me LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) { LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) { @@ -19657,9 +20818,9 @@ uint32_t __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t uint32_t __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) { LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1); - LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); - *ret = SocketDescriptor_clone(orig_conv); - return (uint64_t)ret; + LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); + *ret_ret = SocketDescriptor_clone(orig_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) { @@ -19723,7 +20884,7 @@ void __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_o PeerManager_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) { +uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger, uint32_t custom_message_handler) { LDKMessageHandler message_handler_conv; message_handler_conv.inner = (void*)(message_handler & (~1)); message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0); @@ -19736,7 +20897,8 @@ uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t mes memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32); unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr; LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv); + LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1); + LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -19850,6 +21012,26 @@ int8_tArray __attribute__((visibility("default"))) TS_build_commitment_secret(i return ret_arr; } +int8_tArray __attribute__((visibility("default"))) TS_build_closing_transaction(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = *((uint32_t*)to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + Transaction_free(ret_var); + return ret_arr; +} + uint32_t __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) { LDKPublicKey per_commitment_point_ref; CHECK(*((uint32_t*)per_commitment_point) == 33); @@ -20361,6 +21543,7 @@ void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_trans this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv); } @@ -20369,6 +21552,7 @@ uint32_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(j CHECK(*((uint32_t*)payment_hash_arg) == 32); memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32); LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1); + transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1)); LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -21077,6 +22261,145 @@ int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransactio return ret_arr; } +void __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) { + LDKClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ClosingTransaction_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = *((uint32_t*)to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv); + return (uint64_t)ret_conv; +} + +int64_t __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv); + return ret_val; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + return ret_arr; +} + +void __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) { + LDKTrustedClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + TrustedClosingTransaction_free(this_obj_conv); +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + Transaction_free(ret_var); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript); + funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4); + int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + unsigned char funding_key_arr[32]; + CHECK(*((uint32_t*)funding_key) == 32); + memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32); + unsigned char (*funding_key_ref)[32] = &funding_key_arr; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript); + funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4); + int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) { LDKCommitmentTransaction this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -21403,6 +22726,14 @@ uint32_t __attribute__((visibility("default"))) TS_InitFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKInitFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_NodeFeatures_empty() { LDKNodeFeatures ret_var = NodeFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21425,6 +22756,14 @@ uint32_t __attribute__((visibility("default"))) TS_NodeFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKNodeFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_empty() { LDKChannelFeatures ret_var = ChannelFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21447,6 +22786,14 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKChannelFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() { LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21469,6 +22816,14 @@ uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKInvoiceFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) { LDKInitFeatures this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -21758,6 +23113,27 @@ jboolean __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible return ret_val; } +void __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageReader_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) { + LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1); + LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType"); + *ret_ret = Type_clone(orig_conv); + return (uint64_t)ret_ret; +} + +void __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Type_free(this_ptr_conv); +} + void __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -21915,6 +23291,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) { + LDKRouteHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHop_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) { + LDKRouteHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHop_eq(&a_conv, &b_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) { LDKRouteHop obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -21942,6 +23337,34 @@ void __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) { Route_free(this_obj_conv); } +ptrArray __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) { + LDKRoute this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv); + ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes"); + uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4); + for (size_t m = 0; m < ret_var.datalen; m++) { + LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m]; + uint32_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4); + for (size_t k = 0; k < ret_conv_12_var.datalen; k++) { + LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k]; + CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner; + if (ret_conv_12_conv_10_var.is_owned) { + ret_conv_12_conv_10_ref |= 1; + } + ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref; + } + FREE(ret_conv_12_var.data); + ret_arr_ptr[m] = ret_conv_12_arr; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) { LDKRoute this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -22026,6 +23449,41 @@ uint32_t __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) { return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) { + LDKRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Route_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) { + LDKRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = Route_eq(&a_conv, &b_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_fees(&this_arg_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_amount(&this_arg_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) { LDKRoute obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22053,17 +23511,6 @@ void __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj RouteHint_free(this_obj_conv); } -jboolean __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) { - LDKRouteHint a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHint b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) { LDKRouteHint orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -22078,6 +23525,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t ori return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) { + LDKRouteHint o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHint_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) { + LDKRouteHint a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHint b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) { LDKRouteHintHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -22174,6 +23640,7 @@ void __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_ms this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv); } @@ -22192,6 +23659,7 @@ void __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_ms this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -22204,7 +23672,9 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); fees_arg_conv = RoutingFees_clone(&fees_arg_conv); LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1); + htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1)); LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -22215,17 +23685,6 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray return ret_ref; } -jboolean __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) { - LDKRouteHintHop a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHintHop b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) { LDKRouteHintHop orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -22240,6 +23699,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) { + LDKRouteHintHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHintHop_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) { + LDKRouteHintHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHintHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) { LDKPublicKey our_node_id_ref; CHECK(*((uint32_t*)our_node_id) == 33); @@ -22351,25 +23829,72 @@ void __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_ NetworkGraph_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) { - LDKNetworkGraph orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } +void __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) { + LDKReadOnlyNetworkGraph this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ReadOnlyNetworkGraph_free(this_obj_conv); +} + +void __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + NetworkUpdate_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) { + LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig; + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -void __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) { - LDKLockedNetworkGraph this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - LockedNetworkGraph_free(this_obj_conv); +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_update_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) { + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +int8_tArray __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) { + LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj; + LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) { + LDKNetGraphMsgHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) { @@ -22379,19 +23904,11 @@ void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t NetGraphMsgHandler_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) { - LDKThirtyTwoBytes genesis_hash_ref; - CHECK(*((uint32_t*)genesis_hash) == 32); - memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32); - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv); +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_get_network_graph(uint32_t this_ptr) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22401,20 +23918,29 @@ uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_ return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) { - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); +void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_set_network_graph(uint32_t this_ptr, uint32_t val) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) { LDKNetworkGraph network_graph_conv; network_graph_conv.inner = (void*)(network_graph & (~1)); network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); - network_graph_conv = NetworkGraph_clone(&network_graph_conv); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + } + LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); + LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22428,60 +23954,30 @@ void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_acc LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr); -} - -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) { - LDKNetGraphMsgHandler this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) { - LDKLockedNetworkGraph this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } - return ret_ref; + NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv); } uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) { @@ -22566,6 +24062,7 @@ void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_ this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -22621,6 +24118,7 @@ void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_ uint32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) { LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRoutingFees fees_arg_conv; fees_arg_conv.inner = (void*)(fees_arg & (~1)); fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); @@ -22808,6 +24306,7 @@ void __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(ui this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv); } @@ -22856,6 +24355,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t fea two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0); two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv); LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1); + capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1)); LDKChannelAnnouncement announcement_message_arg_conv; announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1)); announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0); @@ -22977,6 +24477,14 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t o return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) { + LDKRoutingFees o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RoutingFees_hash(&o_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) { LDKRoutingFees obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -23371,6 +24879,20 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -23402,15 +24924,13 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_ LDKChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -23421,15 +24941,13 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_ LDKUnsignedChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -23440,6 +24958,16 @@ void __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_ NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent); } +void __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKPublicKey _node_id_ref; + CHECK(*((uint32_t*)_node_id) == 33); + memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33); + NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent); +} + uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -23517,9 +25045,9 @@ uint32_t __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persi LDKFilesystemPersister this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist"); - *ret = FilesystemPersister_as_Persist(&this_arg_conv); - return (uint64_t)ret; + LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist"); + *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) { @@ -23536,7 +25064,7 @@ void __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uin ChannelManagerPersister_free(this_ptr_conv); } -uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t peer_manager, uint32_t logger) { +uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t net_graph_msg_handler, uint32_t peer_manager, uint32_t logger) { LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1); LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1); LDKChainMonitor chain_monitor_conv; @@ -23545,11 +25073,14 @@ uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(ui LDKChannelManager channel_manager_conv; channel_manager_conv.inner = (void*)(channel_manager & (~1)); channel_manager_conv.is_owned = false; + LDKNetGraphMsgHandler net_graph_msg_handler_conv; + net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1)); + net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0); LDKPeerManager peer_manager_conv; peer_manager_conv.inner = (void*)(peer_manager & (~1)); peer_manager_conv.is_owned = false; LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv); + LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23863,6 +25394,12 @@ uint32_t __attribute__((visibility("default"))) TS_Currency_signet() { return ret_conv; } +int64_t __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) { + LDKCurrency* o_conv = (LDKCurrency*)(o & ~1); + int64_t ret_val = Currency_hash(o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) { LDKCurrency* a_conv = (LDKCurrency*)(a & ~1); LDKCurrency* b_conv = (LDKCurrency*)(b & ~1); @@ -23877,6 +25414,28 @@ void __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) { Sha256_free(this_obj_conv); } +uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) { + LDKSha256 orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKSha256 ret_var = Sha256_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +int64_t __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) { + LDKSha256 o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Sha256_hash(&o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) { LDKSha256 a_conv; a_conv.inner = (void*)(a & (~1)); @@ -23888,11 +25447,18 @@ jboolean __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32 return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) { - LDKSha256 orig_conv; +void __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) { + LDKDescription this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + Description_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) { + LDKDescription orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKSha256 ret_var = Sha256_clone(&orig_conv); + LDKDescription ret_var = Description_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23902,11 +25468,12 @@ uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) return ret_ref; } -void __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) { - LDKDescription this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - Description_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) { + LDKDescription o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Description_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) { @@ -23920,11 +25487,18 @@ jboolean __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, u return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) { - LDKDescription orig_conv; +void __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) { + LDKPayeePubKey this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PayeePubKey_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) { + LDKPayeePubKey orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKDescription ret_var = Description_clone(&orig_conv); + LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23934,11 +25508,12 @@ uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t o return ret_ref; } -void __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) { - LDKPayeePubKey this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PayeePubKey_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) { + LDKPayeePubKey o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PayeePubKey_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) { @@ -23952,11 +25527,18 @@ jboolean __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, u return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) { - LDKPayeePubKey orig_conv; +void __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) { + LDKExpiryTime this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ExpiryTime_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) { + LDKExpiryTime orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); + LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23966,11 +25548,12 @@ uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t o return ret_ref; } -void __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) { - LDKExpiryTime this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ExpiryTime_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) { + LDKExpiryTime o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = ExpiryTime_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) { @@ -23984,11 +25567,18 @@ jboolean __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, ui return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) { - LDKExpiryTime orig_conv; +void __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) { + LDKMinFinalCltvExpiry this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + MinFinalCltvExpiry_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) { + LDKMinFinalCltvExpiry orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); + LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23998,11 +25588,12 @@ uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t or return ret_ref; } -void __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) { - LDKMinFinalCltvExpiry this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - MinFinalCltvExpiry_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) { + LDKMinFinalCltvExpiry o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) { @@ -24016,20 +25607,6 @@ jboolean __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32 return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) { - LDKMinFinalCltvExpiry orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - void __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1); @@ -24077,6 +25654,12 @@ uint32_t __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tA return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) { + LDKFallback* o_conv = (LDKFallback*)o; + int64_t ret_val = Fallback_hash(o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) { LDKFallback* a_conv = (LDKFallback*)a; LDKFallback* b_conv = (LDKFallback*)b; @@ -24091,17 +25674,6 @@ void __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t t InvoiceSignature_free(this_obj_conv); } -jboolean __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) { - LDKInvoiceSignature a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKInvoiceSignature b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) { LDKInvoiceSignature orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24116,24 +25688,24 @@ uint32_t __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint3 return ret_ref; } -void __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) { - LDKPrivateRoute this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PrivateRoute_free(this_obj_conv); -} - -jboolean __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) { - LDKPrivateRoute a_conv; +jboolean __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) { + LDKInvoiceSignature a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = false; - LDKPrivateRoute b_conv; + LDKInvoiceSignature b_conv; b_conv.inner = (void*)(b & (~1)); b_conv.is_owned = false; - jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); return ret_val; } +void __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) { + LDKPrivateRoute this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PrivateRoute_free(this_obj_conv); +} + uint32_t __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) { LDKPrivateRoute orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24148,6 +25720,25 @@ uint32_t __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) { + LDKPrivateRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PrivateRoute_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) { + LDKPrivateRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKPrivateRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) { LDKSignedRawInvoice this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -24701,6 +26292,11 @@ uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_descr return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret()); + return ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() { uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets()); return ret_conv; @@ -24721,6 +26317,11 @@ uint32_t __attribute__((visibility("default"))) TS_SemanticError_invalid_signat return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) { LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1); LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1); @@ -24788,6 +26389,7 @@ uint32_t __attribute__((visibility("default"))) TS_create_invoice_from_channelm LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1); LDKCurrency network_conv = LDKCurrency_from_js(network); LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1); + amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1)); LDKStr description_conv = str_ref_to_owned_c(description); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv); diff --git a/ts/bindings.c.body b/ts/bindings.c.body index 90ea56c0..5661316a 100644 --- a/ts/bindings.c.body +++ b/ts/bindings.c.body @@ -267,10 +267,12 @@ static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) { case 1: return LDKSemanticError_MultiplePaymentHashes; case 2: return LDKSemanticError_NoDescription; case 3: return LDKSemanticError_MultipleDescriptions; - case 4: return LDKSemanticError_MultiplePaymentSecrets; - case 5: return LDKSemanticError_InvalidFeatures; - case 6: return LDKSemanticError_InvalidRecoveryId; - case 7: return LDKSemanticError_InvalidSignature; + case 4: return LDKSemanticError_NoPaymentSecret; + case 5: return LDKSemanticError_MultiplePaymentSecrets; + case 6: return LDKSemanticError_InvalidFeatures; + case 7: return LDKSemanticError_InvalidRecoveryId; + case 8: return LDKSemanticError_InvalidSignature; + case 9: return LDKSemanticError_ImpreciseAmount; } abort(); } @@ -280,10 +282,12 @@ static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) { case LDKSemanticError_MultiplePaymentHashes: return 1; case LDKSemanticError_NoDescription: return 2; case LDKSemanticError_MultipleDescriptions: return 3; - case LDKSemanticError_MultiplePaymentSecrets: return 4; - case LDKSemanticError_InvalidFeatures: return 5; - case LDKSemanticError_InvalidRecoveryId: return 6; - case LDKSemanticError_InvalidSignature: return 7; + case LDKSemanticError_NoPaymentSecret: return 4; + case LDKSemanticError_MultiplePaymentSecrets: return 5; + case LDKSemanticError_InvalidFeatures: return 6; + case LDKSemanticError_InvalidRecoveryId: return 7; + case LDKSemanticError_InvalidSignature: return 8; + case LDKSemanticError_ImpreciseAmount: return 9; default: abort(); } } @@ -548,6 +552,23 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) { + return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(val->result_ok); + LDKTrustedClosingTransaction res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +void __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) { + LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok; } @@ -915,12 +936,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr( uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1; return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref; } - case LDKMonitorEvent_CommitmentTxBroadcasted: { - LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted; - CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1; - return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref; + case LDKMonitorEvent_CommitmentTxConfirmed: { + LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed; + CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1; + return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref; } default: abort(); } @@ -962,6 +983,40 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTrans default: abort(); } } +uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) { + LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1); + switch(obj->tag) { + case LDKNetworkUpdate_ChannelUpdateMessage: { + LDKChannelUpdate msg_var = obj->channel_update_message.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref; + } + case LDKNetworkUpdate_ChannelClosed: { + return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent; + } + case LDKNetworkUpdate_NodeFailure: { + int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33); + return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent; + } + default: abort(); + } +} +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_NetworkUpdateZ_Some: { + uint64_t some_ref = ((uint64_t)&obj->some) | 1; + return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref; + } + case LDKCOption_NetworkUpdateZ_None: { + return 0 /* LDKCOption_NetworkUpdateZ - None */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) { LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1); switch(obj->tag) { @@ -1041,27 +1096,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u default: abort(); } } -uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) { - LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1); - switch(obj->tag) { - case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: { - LDKChannelUpdate msg_var = obj->channel_update_message.msg; - CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; - return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref; - } - case LDKHTLCFailChannelUpdate_ChannelClosed: { - return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent; - } - case LDKHTLCFailChannelUpdate_NodeFailure: { - int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33); - return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent; - } - default: abort(); - } -} uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) { LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1); switch(obj->tag) { @@ -1204,10 +1238,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1; return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref; } - case LDKMessageSendEvent_PaymentFailureNetworkUpdate: { - uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1; - return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref; - } case LDKMessageSendEvent_SendChannelRangeQuery: { int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33); @@ -1406,6 +1436,19 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDe uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) { + return ((LDKCResult_NoneNoneZ*)arg)->result_ok; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) { + LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1); + CHECK(!val->result_ok); + return *val->contents.err; +} uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) { LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); LDKSignature a_ref; @@ -1480,8 +1523,10 @@ typedef struct LDKBaseSign_JCalls { atomic_size_t refcnt; uint32_t get_per_commitment_point_meth; uint32_t release_commitment_secret_meth; + uint32_t validate_holder_commitment_meth; uint32_t channel_keys_id_meth; uint32_t sign_counterparty_commitment_meth; + uint32_t validate_counterparty_revocation_meth; uint32_t sign_holder_commitment_and_htlcs_meth; uint32_t sign_justice_revoked_output_meth; uint32_t sign_justice_revoked_htlc_meth; @@ -1495,8 +1540,10 @@ static void LDKBaseSign_JCalls_free(void* this_arg) { if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { js_free(j_calls->get_per_commitment_point_meth); js_free(j_calls->release_commitment_secret_meth); + js_free(j_calls->validate_holder_commitment_meth); js_free(j_calls->channel_keys_id_meth); js_free(j_calls->sign_counterparty_commitment_meth); + js_free(j_calls->validate_counterparty_revocation_meth); js_free(j_calls->sign_holder_commitment_and_htlcs_meth); js_free(j_calls->sign_justice_revoked_output_meth); js_free(j_calls->sign_justice_revoked_htlc_meth); @@ -1523,6 +1570,21 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32); return ret_ref; } +LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + LDKHolderCommitmentTransaction holder_tx_var = *holder_tx; + holder_tx_var = HolderCommitmentTransaction_clone(holder_tx); + CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner; + if (holder_tx_var.is_owned) { + holder_tx_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref); + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth); @@ -1546,6 +1608,15 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; } +LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; + int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(secret_arr + 4), *secret, 32); + uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr); + LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx; @@ -1616,13 +1687,17 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) { +LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) { LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; - LDKTransaction closing_tx_var = closing_tx; - int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen); - Transaction_free(closing_tx_var); - uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr); + LDKClosingTransaction closing_tx_var = *closing_tx; + // Warning: we may need a move here but no clone is available for LDKClosingTransaction + CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner; + if (closing_tx_var.is_owned) { + closing_tx_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1672,8 +1747,10 @@ static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* .this_arg = (void*) calls, .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall, .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall, + .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall, .channel_keys_id = channel_keys_id_LDKBaseSign_jcall, .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall, + .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall, .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall, .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall, .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall, @@ -1706,6 +1783,16 @@ int8_tArray __attribute__((visibility("default"))) TS_BaseSign_release_commitme return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + LDKHolderCommitmentTransaction holder_tx_conv; + holder_tx_conv.inner = (void*)(holder_tx & (~1)); + holder_tx_conv.is_owned = false; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv); + return (uint64_t)ret_conv; +} + int8_tArray __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); @@ -1723,6 +1810,17 @@ uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_c return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) { + LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); + unsigned char secret_arr[32]; + CHECK(*((uint32_t*)secret) == 32); + memcpy(secret_arr, (uint8_t*)(secret + 4), 32); + unsigned char (*secret_ref)[32] = &secret_arr; + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); LDKHolderCommitmentTransaction commitment_tx_conv; @@ -1786,15 +1884,13 @@ uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_h return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) { +uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) { LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1); - LDKTransaction closing_tx_ref; - closing_tx_ref.datalen = *((uint32_t*)closing_tx); - closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes"); - memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen); - closing_tx_ref.data_is_owned = true; + LDKClosingTransaction closing_tx_conv; + closing_tx_conv.inner = (void*)(closing_tx & (~1)); + closing_tx_conv.is_owned = false; LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ"); - *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref); + *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv); return (uint64_t)ret_conv; } @@ -1899,9 +1995,9 @@ jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); CHECK(val->result_ok); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(&(*val->contents.result)); - return (uint64_t)ret; + LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *res_ret = Sign_clone(&(*val->contents.result)); + return (uint64_t)res_ret; } uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) { LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1); @@ -2717,9 +2813,9 @@ uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_s uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) { @@ -2919,6 +3015,119 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +typedef struct LDKType_JCalls { + atomic_size_t refcnt; + uint32_t type_id_meth; + uint32_t debug_str_meth; + uint32_t write_meth; +} LDKType_JCalls; +static void LDKType_JCalls_free(void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->type_id_meth); + js_free(j_calls->debug_str_meth); + js_free(j_calls->write_meth); + FREE(j_calls); + } +} +uint16_t type_id_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + return js_invoke_function_0(j_calls->type_id_meth); +} +LDKStr debug_str_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth); + LDKStr ret_conv = str_ref_to_owned_c(ret); + return ret_conv; +} +LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg; + int8_tArray ret = js_invoke_function_0(j_calls->write_meth); + LDKCVec_u8Z ret_ref; + ret_ref.datalen = *((uint32_t*)ret); + ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen); + return ret_ref; +} +static void LDKType_JCalls_cloned(LDKType* new_obj) { + LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) { + LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKType ret = { + .this_arg = (void*) calls, + .type_id = type_id_LDKType_jcall, + .debug_str = debug_str_LDKType_jcall, + .write = write_LDKType_jcall, + .cloned = LDKType_JCalls_cloned, + .free = LDKType_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) { + LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType"); + *res_ptr = LDKType_init(o); + return (long)res_ptr; +} +int16_t __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg); + return ret_val; +} + +jstring __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg); + jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); + return ret_conv; +} + +int8_tArray __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) { + LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1); + LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_TypeZ_Some: { + LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType"); + *some_ret = Type_clone(&obj->some); + return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_TypeZ_None: { + return 0 /* LDKCOption_TypeZ - None */; + } + default: abort(); + } +} +jboolean __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) { return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok; } @@ -3385,6 +3594,37 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_pt default: abort(); } } +uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) { + LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1); + switch(obj->tag) { + case LDKClosureReason_CounterpartyForceClosed: { + LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg; + jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len); + return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv; + } + case LDKClosureReason_HolderForceClosed: { + return 0 /* LDKClosureReason - HolderForceClosed */; + } + case LDKClosureReason_CooperativeClosure: { + return 0 /* LDKClosureReason - CooperativeClosure */; + } + case LDKClosureReason_CommitmentTxConfirmed: { + return 0 /* LDKClosureReason - CommitmentTxConfirmed */; + } + case LDKClosureReason_ProcessingError: { + LDKStr err_str = obj->processing_error.err; + jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len); + return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv; + } + case LDKClosureReason_DisconnectedPeer: { + return 0 /* LDKClosureReason - DisconnectedPeer */; + } + case LDKClosureReason_OutdatedChannelManager: { + return 0 /* LDKClosureReason - OutdatedChannelManager */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) { LDKEvent *obj = (LDKEvent*)(ptr & ~1); switch(obj->tag) { @@ -3407,10 +3647,21 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32); return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr; } - case LDKEvent_PaymentFailed: { + case LDKEvent_PaymentPathFailed: { int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32); - return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest; + memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32); + uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1; + LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path; + uint32_tArray path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4); + for (size_t k = 0; k < path_var.datalen; k++) { + LDKRouteHop path_conv_10_var = path_var.data[k]; + CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1; + path_arr_ptr[k] = path_conv_10_ref; + } + return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; } case LDKEvent_PendingHTLCsForwardable: { return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable; @@ -3429,6 +3680,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1; return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx; } + case LDKEvent_ChannelClosed: { + int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32); + uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1; + return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) reason_ref; + } default: abort(); } } @@ -3560,6 +3817,48 @@ static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVe } return ret; } +uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) { + LDKBalance *obj = (LDKBalance*)(ptr & ~1); + switch(obj->tag) { + case LDKBalance_ClaimableOnChannelClose: { + return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis; + } + case LDKBalance_ClaimableAwaitingConfirmations: { + return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height; + } + case LDKBalance_ContentiousClaimable: { + return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height; + } + case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: { + return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height; + } + default: abort(); + } +} +uint32_t __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) { + LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ"); + ret->datalen = *((uint32_t*)elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data"); + uint32_t *java_elems = (uint32_t*)(elems + 4); + for (size_t i = 0; i < ret->datalen; i++) { + uint32_t arr_elem = java_elems[i]; + LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + } + return (uint64_t)ret; +} +static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) { + LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = Balance_clone(&orig->data[i]); + } + return ret; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok; } @@ -3578,6 +3877,70 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; +} +void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(val->result_ok); + return *val->contents.result; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) { + LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKLightningError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) { + LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + LDKPublicKey a_ref; + CHECK(*((uint32_t*)a) == 33); + memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33); + ret->a = a_ref; + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + b_conv = Type_clone(&b_conv); + ret->b = b_conv; + return (uint64_t)ret; +} +int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_a(uint32_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + int8_tArray a_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(a_arr + 4), tuple->a.compressed_form, 33); + return a_arr; +} +uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_b(uint32_t ptr) { + LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1); + LDKType* b_ret =MALLOC(sizeof(LDKType), "LDKType"); + *b_ret = Type_clone(&tuple->b); + return (uint64_t)b_ret; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) { + LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ"); + ret->datalen = *((uint32_t*)elems); + if (ret->datalen == 0) { + ret->data = NULL; + } else { + ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data"); + uint32_t *java_elems = (uint32_t*)(elems + 4); + for (size_t i = 0; i < ret->datalen; i++) { + uint32_t arr_elem = java_elems[i]; + LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1); + arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1)); + ret->data[i] = arr_elem_conv; + } + } + return (uint64_t)ret; +} +static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) { + LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen }; + for (size_t i = 0; i < ret.datalen; i++) { + ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]); + } + return ret; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok; } @@ -3688,23 +4051,6 @@ static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCV } return ret; } -jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) { - return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok; -} -void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(val->result_ok); - return *val->contents.result; -} -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) { - LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKLightningError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t err_ref = (uint64_t)err_var.inner & ~1; - return err_ref; -} jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok; } @@ -3759,24 +4105,91 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErr uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } -jboolean __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) { - return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; +typedef struct LDKAccess_JCalls { + atomic_size_t refcnt; + uint32_t get_utxo_meth; +} LDKAccess_JCalls; +static void LDKAccess_JCalls_free(void* this_arg) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->get_utxo_meth); + FREE(j_calls); + } } -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) { - LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); - CHECK(val->result_ok); - LDKDirectionalChannelInfo res_var = (*val->contents.result); - CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t res_ref = (uint64_t)res_var.inner & ~1; - return res_ref; +LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; + int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32); + uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) { - LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); - CHECK(!val->result_ok); - LDKDecodeError err_var = (*val->contents.err); - CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. +static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) { + LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKAccess ret = { + .this_arg = (void*) calls, + .get_utxo = get_utxo_LDKAccess_jcall, + .free = LDKAccess_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) { + LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); + *res_ptr = LDKAccess_init(o); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { + LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); + unsigned char genesis_hash_arr[32]; + CHECK(*((uint32_t*)genesis_hash) == 32); + memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32); + unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; + LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); + *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_AccessZ_Some: { + LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_AccessZ_None: { + return 0 /* LDKCOption_AccessZ - None */; + } + default: abort(); + } +} +jboolean __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKDirectionalChannelInfo res_var = (*val->contents.result); + CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } @@ -4763,6 +5176,103 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCrea uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; return err_ref; } +typedef struct LDKFilter_JCalls { + atomic_size_t refcnt; + uint32_t register_tx_meth; + uint32_t register_output_meth; +} LDKFilter_JCalls; +static void LDKFilter_JCalls_free(void* this_arg) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->register_tx_meth); + js_free(j_calls->register_output_meth); + FREE(j_calls); + } +} +void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(txid_arr + 4), *txid, 32); + LDKu8slice script_pubkey_var = script_pubkey; + int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen); + js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr); +} +LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + LDKWatchedOutput output_var = output; + CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t output_ref = (uint64_t)output_var.inner; + if (output_var.is_owned) { + output_ref |= 1; + } + uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref); + LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); + ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) { + LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKFilter ret = { + .this_arg = (void*) calls, + .register_tx = register_tx_LDKFilter_jcall, + .register_output = register_output_LDKFilter_jcall, + .free = LDKFilter_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) { + LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); + *res_ptr = LDKFilter_init(o); + return (long)res_ptr; +} +void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + unsigned char txid_arr[32]; + CHECK(*((uint32_t*)txid) == 32); + memcpy(txid_arr, (uint8_t*)(txid + 4), 32); + unsigned char (*txid_ref)[32] = &txid_arr; + LDKu8slice script_pubkey_ref; + script_pubkey_ref.datalen = *((uint32_t*)script_pubkey); + script_pubkey_ref.data = (int8_t*)(script_pubkey + 4); + (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) { + LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); + LDKWatchedOutput output_conv; + output_conv.inner = (void*)(output & (~1)); + output_conv.is_owned = (output & 1) || (output == 0); + output_conv = WatchedOutput_clone(&output_conv); + LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); + *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) { + LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_FilterZ_Some: { + LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter"); + *some_ret = obj->some; + // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances + return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret; + } + case LDKCOption_FilterZ_None: { + return 0 /* LDKCOption_FilterZ - None */; + } + default: abort(); + } +} typedef struct LDKMessageSendEventsProvider_JCalls { atomic_size_t refcnt; uint32_t get_and_clear_pending_msg_events_meth; @@ -4839,12 +5349,11 @@ static void LDKEventHandler_JCalls_free(void* this_arg) { FREE(j_calls); } } -void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { +void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg; - LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *event_copy = event; - uint64_t event_ref = (uint64_t)event_copy; - js_invoke_function_1(j_calls->handle_event_meth, event_ref); + LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion"); + *ret_event = Event_clone(event); + js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event); } static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) { LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg; @@ -4869,7 +5378,7 @@ long __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS O } void __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) { LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1); - LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1); + LDKEvent* event_conv = (LDKEvent*)event; (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv); } @@ -4886,9 +5395,9 @@ static void LDKEventsProvider_JCalls_free(void* this_arg) { } void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; - LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); - *ret = handler; - js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret); + LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *handler_ret = handler; + js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret); } static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) { LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg; @@ -4917,58 +5426,6 @@ void __attribute__((visibility("default"))) TS_EventsProvider_process_pending_e (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv); } -typedef struct LDKAccess_JCalls { - atomic_size_t refcnt; - uint32_t get_utxo_meth; -} LDKAccess_JCalls; -static void LDKAccess_JCalls_free(void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->get_utxo_meth); - FREE(j_calls); - } -} -LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32); - uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); - LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); - return ret_conv; -} -static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) { - LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); - atomic_init(&calls->refcnt, 1); - //TODO: Assign calls->o from o - - LDKAccess ret = { - .this_arg = (void*) calls, - .get_utxo = get_utxo_LDKAccess_jcall, - .free = LDKAccess_JCalls_free, - }; - return ret; -} -long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) { - LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *res_ptr = LDKAccess_init(o); - return (long)res_ptr; -} -uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { - LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1); - unsigned char genesis_hash_arr[32]; - CHECK(*((uint32_t*)genesis_hash) == 32); - memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32); - unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr; - LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); - *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id); - return (uint64_t)ret_conv; -} - typedef struct LDKListen_JCalls { atomic_size_t refcnt; uint32_t block_connected_meth; @@ -5175,121 +5632,39 @@ ptrArray __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(u return ret_arr; } -typedef struct LDKFilter_JCalls { +typedef struct LDKPersist_JCalls { atomic_size_t refcnt; - uint32_t register_tx_meth; - uint32_t register_output_meth; -} LDKFilter_JCalls; -static void LDKFilter_JCalls_free(void* this_arg) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; + uint32_t persist_new_channel_meth; + uint32_t update_persisted_channel_meth; +} LDKPersist_JCalls; +static void LDKPersist_JCalls_free(void* this_arg) { + LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->register_tx_meth); - js_free(j_calls->register_output_meth); + js_free(j_calls->persist_new_channel_meth); + js_free(j_calls->update_persisted_channel_meth); FREE(j_calls); } } -void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(txid_arr + 4), *txid, 32); - LDKu8slice script_pubkey_var = script_pubkey; - int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen); - js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr); -} -LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - LDKWatchedOutput output_var = output; - CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t output_ref = (uint64_t)output_var.inner; - if (output_var.is_owned) { - output_ref |= 1; +LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) { + LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; + LDKOutPoint id_var = id; + CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t id_ref = (uint64_t)id_var.inner; + if (id_var.is_owned) { + id_ref |= 1; } - uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref); - LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1); - ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1)); - return ret_conv; -} -static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); -} -static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) { - LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); - atomic_init(&calls->refcnt, 1); - //TODO: Assign calls->o from o - - LDKFilter ret = { - .this_arg = (void*) calls, - .register_tx = register_tx_LDKFilter_jcall, - .register_output = register_output_LDKFilter_jcall, - .free = LDKFilter_JCalls_free, - }; - return ret; -} -long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) { - LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *res_ptr = LDKFilter_init(o); - return (long)res_ptr; -} -void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - unsigned char txid_arr[32]; - CHECK(*((uint32_t*)txid) == 32); - memcpy(txid_arr, (uint8_t*)(txid + 4), 32); - unsigned char (*txid_ref)[32] = &txid_arr; - LDKu8slice script_pubkey_ref; - script_pubkey_ref.datalen = *((uint32_t*)script_pubkey); - script_pubkey_ref.data = (int8_t*)(script_pubkey + 4); - (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref); -} - -uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) { - LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1); - LDKWatchedOutput output_conv; - output_conv.inner = (void*)(output & (~1)); - output_conv.is_owned = (output & 1) || (output == 0); - output_conv = WatchedOutput_clone(&output_conv); - LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); - *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -typedef struct LDKPersist_JCalls { - atomic_size_t refcnt; - uint32_t persist_new_channel_meth; - uint32_t update_persisted_channel_meth; -} LDKPersist_JCalls; -static void LDKPersist_JCalls_free(void* this_arg) { - LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; - if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { - js_free(j_calls->persist_new_channel_meth); - js_free(j_calls->update_persisted_channel_meth); - FREE(j_calls); - } -} -LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) { - LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; - LDKOutPoint id_var = id; - CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t id_ref = (uint64_t)id_var.inner; - if (id_var.is_owned) { - id_ref |= 1; - } - LDKChannelMonitor data_var = *data; - data_var = ChannelMonitor_clone(data); - CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t data_ref = (uint64_t)data_var.inner; - if (data_var.is_owned) { - data_ref |= 1; - } - uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref); - LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1); - ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1)); + LDKChannelMonitor data_var = *data; + data_var = ChannelMonitor_clone(data); + CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t data_ref = (uint64_t)data_var.inner; + if (data_var.is_owned) { + data_ref |= 1; + } + uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref); + LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1)); return ret_conv; } LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) { @@ -5996,7 +6371,6 @@ typedef struct LDKRoutingMessageHandler_JCalls { uint32_t handle_node_announcement_meth; uint32_t handle_channel_announcement_meth; uint32_t handle_channel_update_meth; - uint32_t handle_htlc_fail_channel_update_meth; uint32_t get_next_channel_announcements_meth; uint32_t get_next_node_announcements_meth; uint32_t sync_routing_table_meth; @@ -6011,7 +6385,6 @@ static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) { js_free(j_calls->handle_node_announcement_meth); js_free(j_calls->handle_channel_announcement_meth); js_free(j_calls->handle_channel_update_meth); - js_free(j_calls->handle_htlc_fail_channel_update_meth); js_free(j_calls->get_next_channel_announcements_meth); js_free(j_calls->get_next_node_announcements_meth); js_free(j_calls->sync_routing_table_meth); @@ -6067,11 +6440,6 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) { - LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - uint64_t ret_update = (uint64_t)update; - js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update); -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount); @@ -6205,7 +6573,6 @@ static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall, .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall, - .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall, .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall, .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall, .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall, @@ -6254,12 +6621,6 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle return (uint64_t)ret_conv; } -void __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) { - LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); - LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update; - (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv); -} - uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) { LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1); LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount); @@ -6363,6 +6724,151 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle return (uint64_t)ret_conv; } +typedef struct LDKCustomMessageReader_JCalls { + atomic_size_t refcnt; + uint32_t read_meth; +} LDKCustomMessageReader_JCalls; +static void LDKCustomMessageReader_JCalls_free(void* this_arg) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->read_meth); + FREE(j_calls); + } +} +LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg; + LDKu8slice buffer_var = buffer; + int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen); + uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr); + LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) { + LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) { + LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKCustomMessageReader ret = { + .this_arg = (void*) calls, + .read = read_LDKCustomMessageReader_jcall, + .free = LDKCustomMessageReader_JCalls_free, + }; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) { + LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *res_ptr = LDKCustomMessageReader_init(o); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) { + LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1); + LDKu8slice buffer_ref; + buffer_ref.datalen = *((uint32_t*)buffer); + buffer_ref.data = (int8_t*)(buffer + 4); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref); + return (uint64_t)ret_conv; +} + +typedef struct LDKCustomMessageHandler_JCalls { + atomic_size_t refcnt; + LDKCustomMessageReader_JCalls* CustomMessageReader; + uint32_t handle_custom_message_meth; + uint32_t get_and_clear_pending_msg_meth; +} LDKCustomMessageHandler_JCalls; +static void LDKCustomMessageHandler_JCalls_free(void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { + js_free(j_calls->handle_custom_message_meth); + js_free(j_calls->get_and_clear_pending_msg_meth); + FREE(j_calls); + } +} +LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType"); + *msg_ret = msg; + int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33); + uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr); + LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1); + ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1)); + return ret_conv; +} +LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg; + uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr; + ret_constr.datalen = *((uint32_t*)ret); + if (ret_constr.datalen > 0) + ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + ret_constr.data = NULL; + uint32_t* ret_vals = (uint32_t*)(ret + 4); + for (size_t c = 0; c < ret_constr.datalen; c++) { + uint32_t ret_conv_28 = ret_vals[c]; + LDKC2Tuple_PublicKeyTypeZ ret_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1); + ret_conv_28_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1)); + ret_constr.data[c] = ret_conv_28_conv; + } + return ret_constr; +} +static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) { + LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg; + atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); + atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release); +} +static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) { + LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls"); + atomic_init(&calls->refcnt, 1); + //TODO: Assign calls->o from o + + LDKCustomMessageHandler ret = { + .this_arg = (void*) calls, + .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall, + .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall, + .free = LDKCustomMessageHandler_JCalls_free, + .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader), + }; + calls->CustomMessageReader = ret.CustomMessageReader.this_arg; + return ret; +} +long __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) { + LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader); + return (long)res_ptr; +} +uint32_t __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1); + LDKPublicKey sender_node_id_ref; + CHECK(*((uint32_t*)sender_node_id) == 33); + memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref); + return (uint64_t)ret_conv; +} + +uint32_tArray __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) { + LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1); + LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t c = 0; c < ret_var.datalen; c++) { + LDKC2Tuple_PublicKeyTypeZ* ret_conv_28_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_conv_28_ref = ret_var.data[c]; + ret_arr_ptr[c] = (uint64_t)ret_conv_28_ref; + } + FREE(ret_var.data); + return ret_arr; +} + typedef struct LDKSocketDescriptor_JCalls { atomic_size_t refcnt; uint32_t send_data_meth; @@ -6947,6 +7453,29 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTrans return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) { + LDKTrustedClosingTransaction o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() { + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = CResult_TrustedClosingTransactionNoneZ_err(); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_TrustedClosingTransactionNoneZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) { LDKCommitmentTransaction o_conv; o_conv.inner = (void*)(o & (~1)); @@ -7348,6 +7877,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ uint32_t __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) { LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1); + o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1)); LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ"); *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -7480,6 +8010,7 @@ void __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_t uint32_t __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) { LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1)); LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ"); *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -7508,6 +8039,37 @@ uint32_t __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) { + LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1); + o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1)); + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() { + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_NetworkUpdateZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) { + LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig; + LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ"); + *ret_copy = COption_NetworkUpdateZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) { LDKCVec_SpendableOutputDescriptorZ _res_constr; _res_constr.datalen = *((uint32_t*)_res); @@ -7720,6 +8282,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputD uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) { LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1); + o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1)); LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ"); *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -7749,6 +8312,32 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescr return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_ok(); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() { + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_err(); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_NoneNoneZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) { + LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1); + LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ"); + *ret_conv = CResult_NoneNoneZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) { LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1); LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ"); @@ -7788,6 +8377,7 @@ void __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZ uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) { LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1); + o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1)); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ"); *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv); return (uint64_t)ret_conv; @@ -8159,6 +8749,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() { uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -8220,6 +8811,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailu uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ"); *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -8250,6 +8842,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSe uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) { LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1)); LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv); return (uint64_t)ret_conv; @@ -8323,6 +8916,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErro uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) { LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1); + e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -8382,6 +8976,7 @@ void __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) { LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -8472,6 +9067,68 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) { + LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1); + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_none() { + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_TypeZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) { + LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig; + LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ"); + *ret_copy = COption_TypeZ_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) { + LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1); + o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1)); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) { + LDKDecodeError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = DecodeError_clone(&e_conv); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_COption_TypeZDecodeErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) { + LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1); + LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ"); + *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) { LDKSiPrefix o_conv = LDKSiPrefix_from_js(o); LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ"); @@ -9108,6 +9765,7 @@ uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) { LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1); + b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1)); LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ"); *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv); return (uint64_t)ret_ref; @@ -9190,8 +9848,26 @@ void __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3 CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr); } +void __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) { + LDKCVec_BalanceZ _res_constr; + _res_constr.datalen = *((uint32_t*)_res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements"); + else + _res_constr.data = NULL; + uint32_t* _res_vals = (uint32_t*)(_res + 4); + for (size_t j = 0; j < _res_constr.datalen; j++) { + uint32_t _res_conv_9 = _res_vals[j]; + LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1); + FREE((void*)_res_conv_9); + _res_constr.data[j] = _res_conv_9_conv; + } + CVec_BalanceZ_free(_res_constr); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) { LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1); + // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ"); *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9214,44 +9890,115 @@ void __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannel CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) { - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_ok(o); +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() { + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_ok(); return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) { +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) { LDKLightningError e_conv; e_conv.inner = (void*)(e & (~1)); e_conv.is_owned = (e & 1) || (e == 0); e_conv = LightningError_clone(&e_conv); - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_err(e_conv); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); return (uint64_t)ret_conv; } -void __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) { +void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) { if ((_res & 1) != 0) return; - LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1); + LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); FREE((void*)_res); - CResult_boolLightningErrorZ_free(_res_conv); + CResult_NoneLightningErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) { - LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1); - LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); - *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv); +uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) { + LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); + LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); + *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); return (uint64_t)ret_conv; } -uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) { - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1); - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); - *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv); +uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) { + LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_clone(orig_conv); return (uint64_t)ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) { +uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) { + LDKPublicKey a_ref; + CHECK(*((uint32_t*)a) == 33); + memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33); + LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1); + LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ"); + *ret_ref = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv); + return (uint64_t)ret_ref; +} + +void __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + C2Tuple_PublicKeyTypeZ_free(_res_conv); +} + +void __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) { + LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr; + _res_constr.datalen = *((uint32_t*)_res); + if (_res_constr.datalen > 0) + _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements"); + else + _res_constr.data = NULL; + uint32_t* _res_vals = (uint32_t*)(_res + 4); + for (size_t c = 0; c < _res_constr.datalen; c++) { + uint32_t _res_conv_28 = _res_vals[c]; + LDKC2Tuple_PublicKeyTypeZ _res_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_28) & ~1); + FREE((void*)_res_conv_28); + _res_constr.data[c] = _res_conv_28_conv; + } + CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) { + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_ok(o); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) { + LDKLightningError e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + e_conv = LightningError_clone(&e_conv); + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_boolLightningErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) { + LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1); + LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ"); + *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) { + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1); + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ"); + *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv); + return (uint64_t)ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) { LDKChannelAnnouncement a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); @@ -9311,36 +10058,6 @@ void __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint CVec_NodeAnnouncementZ_free(_res_constr); } -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() { - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_ok(); - return (uint64_t)ret_conv; -} - -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) { - LDKLightningError e_conv; - e_conv.inner = (void*)(e & (~1)); - e_conv.is_owned = (e & 1) || (e == 0); - e_conv = LightningError_clone(&e_conv); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_err(e_conv); - return (uint64_t)ret_conv; -} - -void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) { - if ((_res & 1) != 0) return; - LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1); - FREE((void*)_res); - CResult_NoneLightningErrorZ_free(_res_conv); -} - -uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) { - LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1); - LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - void __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) { LDKCVec_PublicKeyZ _res_constr; _res_constr.datalen = *((uint32_t*)_res); @@ -9453,6 +10170,28 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) { + LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1); + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_AccessZ_none() { + LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ"); + *ret_copy = COption_AccessZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_AccessZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) { LDKDirectionalChannelInfo o_conv; o_conv.inner = (void*)(o & (~1)); @@ -9642,7 +10381,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeEr LDKNetworkGraph o_conv; o_conv.inner = (void*)(o & (~1)); o_conv.is_owned = (o & 1) || (o == 0); - o_conv = NetworkGraph_clone(&o_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9665,15 +10404,9 @@ void __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_free(_res_conv); } -uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) { - LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1); - LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ"); - *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv); - return (uint64_t)ret_conv; -} - uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z"); *ret_conv = CResult_NetAddressu8Z_ok(o_conv); return (uint64_t)ret_conv; @@ -9701,6 +10434,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone( uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) { LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1); + o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1)); LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ"); *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -9732,6 +10466,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8 uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) { LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1); + o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1)); LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ"); *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv); return (uint64_t)ret_conv; @@ -10933,6 +11668,7 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) { LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1); + e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1)); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv); return (uint64_t)ret_conv; @@ -10952,6 +11688,28 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) { + LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1); + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_some(o_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_FilterZ_none() { + LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ"); + *ret_copy = COption_FilterZ_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_FilterZ_free(_res_conv); +} + void __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1); @@ -10990,6 +11748,81 @@ uint32_t __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_p return ret_ref; } +void __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + ClosureReason_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) { + LDKClosureReason* orig_conv = (LDKClosureReason*)orig; + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) { + LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_holder_force_closed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_cooperative_closure(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_commitment_tx_confirmed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_processing_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_disconnected_peer(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() { + LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason"); + *ret_copy = ClosureReason_outdated_channel_manager(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) { + LDKClosureReason* obj_conv = (LDKClosureReason*)obj; + LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1); @@ -11024,6 +11857,7 @@ uint32_t __attribute__((visibility("default"))) TS_Event_payment_received(int8_ CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1); + purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -11040,12 +11874,29 @@ uint32_t __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArr return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_Event_payment_failed(int8_tArray payment_hash, jboolean rejected_by_dest) { +uint32_t __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path) { LDKThirtyTwoBytes payment_hash_ref; CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); + LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1); + network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1)); + LDKCVec_RouteHopZ path_constr; + path_constr.datalen = *((uint32_t*)path); + if (path_constr.datalen > 0) + path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements"); + else + path_constr.data = NULL; + uint32_t* path_vals = (uint32_t*)(path + 4); + for (size_t k = 0; k < path_constr.datalen; k++) { + uint32_t path_conv_10 = path_vals[k]; + LDKRouteHop path_conv_10_conv; + path_conv_10_conv.inner = (void*)(path_conv_10 & (~1)); + path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0); + path_conv_10_conv = RouteHop_clone(&path_conv_10_conv); + path_constr.data[k] = path_conv_10_conv; + } LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); - *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest); + *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -11079,12 +11930,25 @@ uint32_t __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint uint32_t __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) { LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1); + fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1)); LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, uint32_t reason) { + LDKThirtyTwoBytes channel_id_ref; + CHECK(*((uint32_t*)channel_id) == 32); + memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32); + LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1); + reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1)); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_channel_closed(channel_id_ref, reason_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) { LDKEvent* obj_conv = (LDKEvent*)obj; LDKCVec_u8Z ret_var = Event_write(obj_conv); @@ -11319,20 +12183,13 @@ uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_handle_erro CHECK(*((uint32_t*)node_id) == 33); memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1); + action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1)); LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_payment_failure_network_update(uint32_t update) { - LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1); - LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); - *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) { LDKPublicKey node_id_ref; CHECK(*((uint32_t*)node_id) == 33); @@ -12397,18 +13254,16 @@ void __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_ } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) { - LDKFilter *chain_source_conv_ptr = NULL; - if (chain_source != 0) { - LDKFilter chain_source_conv; - chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1); - chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *chain_source_conv_ptr = chain_source_conv; + LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ + if (chain_source_conv.tag == LDKCOption_FilterZ_Some) { + // Manually implement clone for Java trait instances } LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1); LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1); LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1); - LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv); + LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -12418,40 +13273,72 @@ uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t ch return ret_ref; } +uint32_tArray __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) { + LDKChainMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_ChannelDetailsZ ignored_channels_constr; + ignored_channels_constr.datalen = *((uint32_t*)ignored_channels); + if (ignored_channels_constr.datalen > 0) + ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + ignored_channels_constr.data = NULL; + uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4); + for (size_t q = 0; q < ignored_channels_constr.datalen; q++) { + uint32_t ignored_channels_conv_16 = ignored_channels_vals[q]; + LDKChannelDetails ignored_channels_conv_16_conv; + ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1)); + ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0); + ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv); + ignored_channels_constr.data[q] = ignored_channels_conv_16_conv; + } + LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + FREE(ret_var.data); + return ret_arr; +} + uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChainMonitor_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChainMonitor_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChainMonitor_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch"); - *ret = ChainMonitor_as_Watch(&this_arg_conv); - return (uint64_t)ret; + LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch"); + *ret_ret = ChainMonitor_as_Watch(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) { LDKChainMonitor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChainMonitor_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) { @@ -12573,13 +13460,13 @@ uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint3 return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_broadcasted(uint32_t a) { +uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) { LDKOutPoint a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = (a & 1) || (a == 0); a_conv = OutPoint_clone(&a_conv); LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); - *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv); + *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } @@ -12625,6 +13512,56 @@ uint32_t __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray return (uint64_t)ret_conv; } +void __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Balance_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) { + LDKBalance* orig_conv = (LDKBalance*)orig; + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) { + LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +jboolean __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) { + LDKBalance* a_conv = (LDKBalance*)a; + LDKBalance* b_conv = (LDKBalance*)b; + jboolean ret_val = Balance_eq(a_conv, b_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) { LDKChannelMonitor this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -12919,6 +13856,23 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_ return ret_ref; } +uint32_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t j = 0; j < ret_var.datalen; j++) { + LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance"); + *ret_conv_9_copy = Balance_clone(&ret_var.data[j]); + uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy; + ret_arr_ptr[j] = ret_conv_9_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -13124,6 +14078,7 @@ void __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_s this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -13189,6 +14144,7 @@ uint32_t __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript CHECK(*((uint32_t*)per_commitment_point_arg) == 33); memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKPublicKey revocation_pubkey_arg_ref; CHECK(*((uint32_t*)revocation_pubkey_arg) == 33); memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33); @@ -13276,6 +14232,7 @@ void __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_se this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1); + val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1)); StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv); } @@ -13319,6 +14276,7 @@ uint32_t __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0); outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv); LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1); + output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1)); LDKThirtyTwoBytes channel_keys_id_arg_ref; CHECK(*((uint32_t*)channel_keys_id_arg) == 32); memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32); @@ -13387,6 +14345,7 @@ uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_st outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0); outpoint_conv = OutPoint_clone(&outpoint_conv); LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1); + output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1)); LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -13442,9 +14401,9 @@ void __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) uint32_t __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) { LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1); - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = Sign_clone(orig_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = Sign_clone(orig_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) { @@ -13732,18 +14691,18 @@ uint32_t __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(u LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); - *ret = InMemorySigner_as_BaseSign(&this_arg_conv); - return (uint64_t)ret; + LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign"); + *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) { LDKInMemorySigner this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign"); - *ret = InMemorySigner_as_Sign(&this_arg_conv); - return (uint64_t)ret; + LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign"); + *ret_ret = InMemorySigner_as_Sign(&this_arg_conv); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) { @@ -13849,9 +14808,9 @@ uint32_t __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface LDKKeysManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); - *ret = KeysManager_as_KeysInterface(&this_arg_conv); - return (uint64_t)ret; + LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); + *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) { @@ -13939,54 +14898,131 @@ uint32_t __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32 return ret_ref; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { - LDKChannelCounterparty this_obj_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) { + LDKCounterpartyForwardingInfo this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ChannelCounterparty_free(this_obj_conv); + CounterpartyForwardingInfo_free(this_obj_conv); } -int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { - LDKChannelCounterparty this_ptr_conv; +int32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); - return ret_arr; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { - LDKChannelCounterparty this_ptr_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK(*((uint32_t*)val) == 33); - memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); - ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); + CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { - LDKChannelCounterparty this_ptr_conv; +int32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; + int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { - LDKChannelCounterparty this_ptr_conv; +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); + CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val); +} + +int16_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) { + LDKCounterpartyForwardingInfo this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) { + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) { + LDKCounterpartyForwardingInfo orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { + LDKChannelCounterparty this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ChannelCounterparty_free(this_obj_conv); +} + +int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); + return ret_arr; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK(*((uint32_t*)val) == 33); + memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); ChannelCounterparty_set_features(&this_ptr_conv, val_conv); } @@ -14005,6 +15041,53 @@ void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspenda ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCounterpartyForwardingInfo val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = CounterpartyForwardingInfo_clone(&val_conv); + ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg) { + LDKPublicKey node_id_arg_ref; + CHECK(*((uint32_t*)node_id_arg) == 33); + memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33); + LDKInitFeatures features_arg_conv; + features_arg_conv.inner = (void*)(features_arg & (~1)); + features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0); + features_arg_conv = InitFeatures_clone(&features_arg_conv); + LDKCounterpartyForwardingInfo forwarding_info_arg_conv; + forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1)); + forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0); + forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv); + LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) { LDKChannelCounterparty orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -14110,6 +15193,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } @@ -14143,6 +15227,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_p this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } @@ -14206,6 +15291,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); } @@ -14224,6 +15310,7 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_s this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1)); ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); } @@ -14300,9 +15387,12 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArr funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1)); LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1)); LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1)); LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -14344,6 +15434,7 @@ uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uin uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) { LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1); + a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1)); LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); *ret_copy = PaymentSendFailure_parameter_error(a_conv); uint64_t ret_ref = (uint64_t)ret_copy; @@ -14689,6 +15780,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_create_inboun this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ"); *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_ref; @@ -14702,6 +15794,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_create_inboun CHECK(*((uint32_t*)payment_hash) == 32); memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1); + min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1)); LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ"); *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id); return (uint64_t)ret_conv; @@ -14711,36 +15804,36 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSen LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *ret = ChannelManager_as_EventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); + *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen"); - *ret = ChannelManager_as_Listen(&this_arg_conv); - return (uint64_t)ret; + LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen"); + *ret_ret = ChannelManager_as_Listen(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm"); - *ret = ChannelManager_as_Confirm(&this_arg_conv); - return (uint64_t)ret; + LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm"); + *ret_ret = ChannelManager_as_Confirm(&this_arg_conv); + return (uint64_t)ret_ret; } jboolean __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) { @@ -14776,9 +15869,9 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMes LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } int8_tArray __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) { @@ -18556,12 +19649,14 @@ void __attribute__((visibility("default"))) TS_LightningError_set_action(uint32 this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1); + val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1)); LightningError_set_action(&this_ptr_conv, val_conv); } uint32_t __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) { LDKStr err_arg_conv = str_ref_to_owned_c(err_arg); LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1); + action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1)); LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -18593,6 +19688,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t t CommitmentUpdate_free(this_obj_conv); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t p = 0; p < ret_var.datalen; p++) { + LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p]; + CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner; + if (ret_conv_15_var.is_owned) { + ret_conv_15_ref |= 1; + } + ret_arr_ptr[p] = ret_conv_15_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18615,6 +19731,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_ CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t t = 0; t < ret_var.datalen; t++) { + LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t]; + CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner; + if (ret_conv_19_var.is_owned) { + ret_conv_19_ref |= 1; + } + ret_arr_ptr[t] = ret_conv_19_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18637,6 +19774,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulf CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t q = 0; q < ret_var.datalen; q++) { + LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q]; + CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner; + if (ret_conv_16_var.is_owned) { + ret_conv_16_ref |= 1; + } + ret_arr_ptr[q] = ret_conv_16_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18659,6 +19817,27 @@ void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr); } +uint32_tArray __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) { + LDKCommitmentUpdate this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv); + uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4); + for (size_t z = 0; z < ret_var.datalen; z++) { + LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z]; + CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner; + if (ret_conv_25_var.is_owned) { + ret_conv_25_ref |= 1; + } + ret_arr_ptr[z] = ret_conv_25_ref; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) { LDKCommitmentUpdate this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -18824,49 +20003,6 @@ uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3 return ret_ref; } -void __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) { - if ((this_ptr & 1) != 0) return; - LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1); - FREE((void*)this_ptr); - HTLCFailChannelUpdate_free(this_ptr_conv); -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) { - LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig; - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_clone(orig_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_update_message(uint32_t msg) { - LDKChannelUpdate msg_conv; - msg_conv.inner = (void*)(msg & (~1)); - msg_conv.is_owned = (msg & 1) || (msg == 0); - msg_conv = ChannelUpdate_clone(&msg_conv); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) { - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) { - LDKPublicKey node_id_ref; - CHECK(*((uint32_t*)node_id) == 33); - memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); - LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); - *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent); - uint64_t ret_ref = (uint64_t)ret_copy; - return ret_ref; -} - void __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1); @@ -19441,15 +20577,6 @@ int8_tArray __attribute__((visibility("default"))) TS_QueryShortChannelIds_writ return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); - *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) { LDKReplyShortChannelIdsEnd obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19461,6 +20588,15 @@ int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_w return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ"); + *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref); + return (uint64_t)ret_conv; +} + int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) { LDKQueryChannelRange this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -19469,15 +20605,6 @@ int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknu return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); - *ret_conv = QueryChannelRange_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) { LDKQueryChannelRange obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19489,6 +20616,15 @@ int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_write(u return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ"); + *ret_conv = QueryChannelRange_read(ser_ref); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = *((uint32_t*)ser); @@ -19509,15 +20645,6 @@ int8_tArray __attribute__((visibility("default"))) TS_ReplyChannelRange_write(u return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) { - LDKu8slice ser_ref; - ser_ref.datalen = *((uint32_t*)ser); - ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ"); - *ret_conv = GossipTimestampFilter_read(ser_ref); - return (uint64_t)ret_conv; -} - int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) { LDKGossipTimestampFilter obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -19529,6 +20656,22 @@ int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_wri return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ"); + *ret_conv = GossipTimestampFilter_read(ser_ref); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageHandler_free(this_ptr_conv); +} + void __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) { LDKIgnoringMessageHandler this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -19551,22 +20694,40 @@ uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Me LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) { LDKIgnoringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } -void __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) { - LDKErroringMessageHandler this_obj_conv; +uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv); + return (uint64_t)ret_ret; +} + +uint32_t __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) { + LDKIgnoringMessageHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler"); + *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; +} + +void __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) { + LDKErroringMessageHandler this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); ErroringMessageHandler_free(this_obj_conv); @@ -19587,18 +20748,18 @@ uint32_t __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_Me LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) { LDKErroringMessageHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); + *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) { @@ -19655,9 +20816,9 @@ uint32_t __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t uint32_t __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) { LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1); - LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); - *ret = SocketDescriptor_clone(orig_conv); - return (uint64_t)ret; + LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); + *ret_ret = SocketDescriptor_clone(orig_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) { @@ -19721,7 +20882,7 @@ void __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_o PeerManager_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) { +uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger, uint32_t custom_message_handler) { LDKMessageHandler message_handler_conv; message_handler_conv.inner = (void*)(message_handler & (~1)); message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0); @@ -19734,7 +20895,8 @@ uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t mes memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32); unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr; LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv); + LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1); + LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -19848,6 +21010,26 @@ int8_tArray __attribute__((visibility("default"))) TS_build_commitment_secret(i return ret_arr; } +int8_tArray __attribute__((visibility("default"))) TS_build_closing_transaction(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = *((uint32_t*)to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + Transaction_free(ret_var); + return ret_arr; +} + uint32_t __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) { LDKPublicKey per_commitment_point_ref; CHECK(*((uint32_t*)per_commitment_point) == 33); @@ -20359,6 +21541,7 @@ void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_trans this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1)); HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv); } @@ -20367,6 +21550,7 @@ uint32_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(j CHECK(*((uint32_t*)payment_hash_arg) == 32); memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32); LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1); + transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1)); LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -21075,6 +22259,145 @@ int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransactio return ret_arr; } +void __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) { + LDKClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ClosingTransaction_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) { + LDKCVec_u8Z to_holder_script_ref; + to_holder_script_ref.datalen = *((uint32_t*)to_holder_script); + to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen); + LDKCVec_u8Z to_counterparty_script_ref; + to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script); + to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen); + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKOutPoint funding_outpoint_conv; + funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1)); + funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0); + funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv); + LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ"); + *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv); + return (uint64_t)ret_conv; +} + +int64_t __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv); + return ret_val; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) { + LDKClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + return ret_arr; +} + +void __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) { + LDKTrustedClosingTransaction this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + TrustedClosingTransaction_free(this_obj_conv); +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + Transaction_free(ret_var); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript); + funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4); + int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) { + LDKTrustedClosingTransaction this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + unsigned char funding_key_arr[32]; + CHECK(*((uint32_t*)funding_key) == 32); + memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32); + unsigned char (*funding_key_ref)[32] = &funding_key_arr; + LDKu8slice funding_redeemscript_ref; + funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript); + funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4); + int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) { LDKCommitmentTransaction this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -21401,6 +22724,14 @@ uint32_t __attribute__((visibility("default"))) TS_InitFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKInitFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_NodeFeatures_empty() { LDKNodeFeatures ret_var = NodeFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21423,6 +22754,14 @@ uint32_t __attribute__((visibility("default"))) TS_NodeFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKNodeFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_empty() { LDKChannelFeatures ret_var = ChannelFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21445,6 +22784,14 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKChannelFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() { LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -21467,6 +22814,14 @@ uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_known() { return ret_ref; } +jboolean __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) { + LDKInvoiceFeatures this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) { LDKInitFeatures this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -21756,6 +23111,27 @@ jboolean __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible return ret_val; } +void __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + CustomMessageReader_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) { + LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1); + LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType"); + *ret_ret = Type_clone(orig_conv); + return (uint64_t)ret_ret; +} + +void __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + Type_free(this_ptr_conv); +} + void __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -21913,6 +23289,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) { + LDKRouteHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHop_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) { + LDKRouteHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHop_eq(&a_conv, &b_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) { LDKRouteHop obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -21940,6 +23335,34 @@ void __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) { Route_free(this_obj_conv); } +ptrArray __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) { + LDKRoute this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv); + ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes"); + uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4); + for (size_t m = 0; m < ret_var.datalen; m++) { + LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m]; + uint32_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes"); + uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4); + for (size_t k = 0; k < ret_conv_12_var.datalen; k++) { + LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k]; + CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner; + if (ret_conv_12_conv_10_var.is_owned) { + ret_conv_12_conv_10_ref |= 1; + } + ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref; + } + FREE(ret_conv_12_var.data); + ret_arr_ptr[m] = ret_conv_12_arr; + } + FREE(ret_var.data); + return ret_arr; +} + void __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) { LDKRoute this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -22024,6 +23447,41 @@ uint32_t __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) { return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) { + LDKRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Route_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) { + LDKRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = Route_eq(&a_conv, &b_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_fees(&this_arg_conv); + return ret_val; +} + +int64_t __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) { + LDKRoute this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int64_t ret_val = Route_get_total_amount(&this_arg_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) { LDKRoute obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -22051,17 +23509,6 @@ void __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj RouteHint_free(this_obj_conv); } -jboolean __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) { - LDKRouteHint a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHint b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) { LDKRouteHint orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -22076,6 +23523,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t ori return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) { + LDKRouteHint o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHint_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) { + LDKRouteHint a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHint b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHint_eq(&a_conv, &b_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) { LDKRouteHintHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -22172,6 +23638,7 @@ void __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_ms this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv); } @@ -22190,6 +23657,7 @@ void __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_ms this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -22202,7 +23670,9 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); fees_arg_conv = RoutingFees_clone(&fees_arg_conv); LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1); + htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1)); LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. @@ -22213,17 +23683,6 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray return ret_ref; } -jboolean __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) { - LDKRouteHintHop a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKRouteHintHop b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) { LDKRouteHintHop orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -22238,6 +23697,25 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) { + LDKRouteHintHop o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RouteHintHop_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) { + LDKRouteHintHop a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKRouteHintHop b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) { LDKPublicKey our_node_id_ref; CHECK(*((uint32_t*)our_node_id) == 33); @@ -22349,25 +23827,72 @@ void __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_ NetworkGraph_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) { - LDKNetworkGraph orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } +void __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) { + LDKReadOnlyNetworkGraph this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ReadOnlyNetworkGraph_free(this_obj_conv); +} + +void __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + NetworkUpdate_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) { + LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig; + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -void __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) { - LDKLockedNetworkGraph this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - LockedNetworkGraph_free(this_obj_conv); +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_update_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) { + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate"); + *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +int8_tArray __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) { + LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj; + LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) { + LDKNetGraphMsgHandler this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler"); + *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) { @@ -22377,19 +23902,11 @@ void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t NetGraphMsgHandler_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) { - LDKThirtyTwoBytes genesis_hash_ref; - CHECK(*((uint32_t*)genesis_hash) == 32); - memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32); - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv); +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_get_network_graph(uint32_t this_ptr) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22399,20 +23916,29 @@ uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_ return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) { - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); +void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_set_network_graph(uint32_t this_ptr, uint32_t val) { + LDKNetGraphMsgHandler this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKNetworkGraph val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) { LDKNetworkGraph network_graph_conv; network_graph_conv.inner = (void*)(network_graph & (~1)); network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0); - network_graph_conv = NetworkGraph_clone(&network_graph_conv); - LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv); + // Warning: we need a move here but no clone is available for LDKNetworkGraph + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances + } + LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); + LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -22426,60 +23952,30 @@ void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_acc LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; - } - NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr); -} - -uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) { - LDKNetGraphMsgHandler this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - -uint32_t __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) { - LDKLockedNetworkGraph this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } - return ret_ref; + NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv); } uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); - return (uint64_t)ret; + LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); + *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv); + return (uint64_t)ret_ret; } uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) { LDKNetGraphMsgHandler this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); - return (uint64_t)ret; + LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); + *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) { @@ -22564,6 +24060,7 @@ void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_ this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv); } @@ -22619,6 +24116,7 @@ void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_ uint32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) { LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1); + htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1)); LDKRoutingFees fees_arg_conv; fees_arg_conv.inner = (void*)(fees_arg & (~1)); fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0); @@ -22806,6 +24304,7 @@ void __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(ui this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1)); ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv); } @@ -22854,6 +24353,7 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t fea two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0); two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv); LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1); + capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1)); LDKChannelAnnouncement announcement_message_arg_conv; announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1)); announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0); @@ -22975,6 +24475,14 @@ uint32_t __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t o return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) { + LDKRoutingFees o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = RoutingFees_hash(&o_conv); + return ret_val; +} + int8_tArray __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) { LDKRoutingFees obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -23369,6 +24877,20 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -23400,15 +24922,13 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_ LDKChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -23419,15 +24939,13 @@ uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_ LDKUnsignedChannelAnnouncement msg_conv; msg_conv.inner = (void*)(msg & (~1)); msg_conv.is_owned = false; - LDKAccess *chain_access_conv_ptr = NULL; - if (chain_access != 0) { - LDKAccess chain_access_conv; - chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1); - chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *chain_access_conv_ptr = chain_access_conv; + LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1); + // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ + if (chain_access_conv.tag == LDKCOption_AccessZ_Some) { + // Manually implement clone for Java trait instances } LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ"); - *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr); + *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv); return (uint64_t)ret_conv; } @@ -23438,6 +24956,16 @@ void __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_ NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent); } +void __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) { + LDKNetworkGraph this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKPublicKey _node_id_ref; + CHECK(*((uint32_t*)_node_id) == 33); + memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33); + NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent); +} + uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) { LDKNetworkGraph this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -23515,9 +25043,9 @@ uint32_t __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persi LDKFilesystemPersister this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist"); - *ret = FilesystemPersister_as_Persist(&this_arg_conv); - return (uint64_t)ret; + LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist"); + *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv); + return (uint64_t)ret_ret; } void __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) { @@ -23534,7 +25062,7 @@ void __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uin ChannelManagerPersister_free(this_ptr_conv); } -uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t peer_manager, uint32_t logger) { +uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t net_graph_msg_handler, uint32_t peer_manager, uint32_t logger) { LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1); LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1); LDKChainMonitor chain_monitor_conv; @@ -23543,11 +25071,14 @@ uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(ui LDKChannelManager channel_manager_conv; channel_manager_conv.inner = (void*)(channel_manager & (~1)); channel_manager_conv.is_owned = false; + LDKNetGraphMsgHandler net_graph_msg_handler_conv; + net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1)); + net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0); LDKPeerManager peer_manager_conv; peer_manager_conv.inner = (void*)(peer_manager & (~1)); peer_manager_conv.is_owned = false; LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); - LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv); + LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23861,6 +25392,12 @@ uint32_t __attribute__((visibility("default"))) TS_Currency_signet() { return ret_conv; } +int64_t __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) { + LDKCurrency* o_conv = (LDKCurrency*)(o & ~1); + int64_t ret_val = Currency_hash(o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) { LDKCurrency* a_conv = (LDKCurrency*)(a & ~1); LDKCurrency* b_conv = (LDKCurrency*)(b & ~1); @@ -23875,6 +25412,28 @@ void __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) { Sha256_free(this_obj_conv); } +uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) { + LDKSha256 orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKSha256 ret_var = Sha256_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +int64_t __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) { + LDKSha256 o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Sha256_hash(&o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) { LDKSha256 a_conv; a_conv.inner = (void*)(a & (~1)); @@ -23886,11 +25445,18 @@ jboolean __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32 return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) { - LDKSha256 orig_conv; +void __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) { + LDKDescription this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + Description_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) { + LDKDescription orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKSha256 ret_var = Sha256_clone(&orig_conv); + LDKDescription ret_var = Description_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23900,11 +25466,12 @@ uint32_t __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) return ret_ref; } -void __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) { - LDKDescription this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - Description_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) { + LDKDescription o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = Description_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) { @@ -23918,11 +25485,18 @@ jboolean __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, u return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) { - LDKDescription orig_conv; +void __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) { + LDKPayeePubKey this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PayeePubKey_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) { + LDKPayeePubKey orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKDescription ret_var = Description_clone(&orig_conv); + LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23932,11 +25506,12 @@ uint32_t __attribute__((visibility("default"))) TS_Description_clone(uint32_t o return ret_ref; } -void __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) { - LDKPayeePubKey this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PayeePubKey_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) { + LDKPayeePubKey o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PayeePubKey_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) { @@ -23950,11 +25525,18 @@ jboolean __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, u return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) { - LDKPayeePubKey orig_conv; +void __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) { + LDKExpiryTime this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ExpiryTime_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) { + LDKExpiryTime orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv); + LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23964,11 +25546,12 @@ uint32_t __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t o return ret_ref; } -void __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) { - LDKExpiryTime this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - ExpiryTime_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) { + LDKExpiryTime o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = ExpiryTime_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) { @@ -23982,11 +25565,18 @@ jboolean __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, ui return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) { - LDKExpiryTime orig_conv; +void __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) { + LDKMinFinalCltvExpiry this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + MinFinalCltvExpiry_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) { + LDKMinFinalCltvExpiry orig_conv; orig_conv.inner = (void*)(orig & (~1)); orig_conv.is_owned = false; - LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv); + LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -23996,11 +25586,12 @@ uint32_t __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t or return ret_ref; } -void __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) { - LDKMinFinalCltvExpiry this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - MinFinalCltvExpiry_free(this_obj_conv); +int64_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) { + LDKMinFinalCltvExpiry o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv); + return ret_val; } jboolean __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) { @@ -24014,20 +25605,6 @@ jboolean __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32 return ret_val; } -uint32_t __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) { - LDKMinFinalCltvExpiry orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv); - CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. - CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. - uint64_t ret_ref = (uint64_t)ret_var.inner; - if (ret_var.is_owned) { - ret_ref |= 1; - } - return ret_ref; -} - void __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1); @@ -24075,6 +25652,12 @@ uint32_t __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tA return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) { + LDKFallback* o_conv = (LDKFallback*)o; + int64_t ret_val = Fallback_hash(o_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) { LDKFallback* a_conv = (LDKFallback*)a; LDKFallback* b_conv = (LDKFallback*)b; @@ -24089,17 +25672,6 @@ void __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t t InvoiceSignature_free(this_obj_conv); } -jboolean __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) { - LDKInvoiceSignature a_conv; - a_conv.inner = (void*)(a & (~1)); - a_conv.is_owned = false; - LDKInvoiceSignature b_conv; - b_conv.inner = (void*)(b & (~1)); - b_conv.is_owned = false; - jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); - return ret_val; -} - uint32_t __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) { LDKInvoiceSignature orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24114,24 +25686,24 @@ uint32_t __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint3 return ret_ref; } -void __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) { - LDKPrivateRoute this_obj_conv; - this_obj_conv.inner = (void*)(this_obj & (~1)); - this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - PrivateRoute_free(this_obj_conv); -} - -jboolean __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) { - LDKPrivateRoute a_conv; +jboolean __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) { + LDKInvoiceSignature a_conv; a_conv.inner = (void*)(a & (~1)); a_conv.is_owned = false; - LDKPrivateRoute b_conv; + LDKInvoiceSignature b_conv; b_conv.inner = (void*)(b & (~1)); b_conv.is_owned = false; - jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv); return ret_val; } +void __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) { + LDKPrivateRoute this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + PrivateRoute_free(this_obj_conv); +} + uint32_t __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) { LDKPrivateRoute orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -24146,6 +25718,25 @@ uint32_t __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t return ret_ref; } +int64_t __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) { + LDKPrivateRoute o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = false; + int64_t ret_val = PrivateRoute_hash(&o_conv); + return ret_val; +} + +jboolean __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) { + LDKPrivateRoute a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = false; + LDKPrivateRoute b_conv; + b_conv.inner = (void*)(b & (~1)); + b_conv.is_owned = false; + jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) { LDKSignedRawInvoice this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -24699,6 +26290,11 @@ uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_descr return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret()); + return ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() { uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets()); return ret_conv; @@ -24719,6 +26315,11 @@ uint32_t __attribute__((visibility("default"))) TS_SemanticError_invalid_signat return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) { LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1); LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1); @@ -24786,6 +26387,7 @@ uint32_t __attribute__((visibility("default"))) TS_create_invoice_from_channelm LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1); LDKCurrency network_conv = LDKCurrency_from_js(network); LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1); + amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1)); LDKStr description_conv = str_ref_to_owned_c(description); LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ"); *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv); diff --git a/ts/bindings.ts b/ts/bindings.ts index d936b46e..c13ea9f6 100644 --- a/ts/bindings.ts +++ b/ts/bindings.ts @@ -211,6 +211,9 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_TrustedClosingTransactionNoneZ_result_ok(long arg); + public static native number LDKCResult_TrustedClosingTransactionNoneZ_get_ok(long arg); + public static native void LDKCResult_TrustedClosingTransactionNoneZ_get_err(long arg); public static native boolean LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(long arg); @@ -270,9 +273,9 @@ public static native long new_empty_slice_vec(); public number htlc_event; HTLCEvent(number htlc_event) { this.htlc_event = htlc_event; } } - export class CommitmentTxBroadcasted extends LDKMonitorEvent { - public number commitment_tx_broadcasted; - CommitmentTxBroadcasted(number commitment_tx_broadcasted) { this.commitment_tx_broadcasted = commitment_tx_broadcasted; } + export class CommitmentTxConfirmed extends LDKMonitorEvent { + public number commitment_tx_confirmed; + CommitmentTxConfirmed(number commitment_tx_confirmed) { this.commitment_tx_confirmed = commitment_tx_confirmed; } } static native void init(); } @@ -292,6 +295,39 @@ public static native long new_empty_slice_vec(); } static { LDKCOption_C2Tuple_usizeTransactionZZ.init(); } public static native LDKCOption_C2Tuple_usizeTransactionZZ LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(long ptr); + public static class LDKNetworkUpdate { + private LDKNetworkUpdate() {} + export class ChannelUpdateMessage extends LDKNetworkUpdate { + public number msg; + ChannelUpdateMessage(number msg) { this.msg = msg; } + } + export class ChannelClosed extends LDKNetworkUpdate { + public number short_channel_id; + public boolean is_permanent; + ChannelClosed(number short_channel_id, boolean is_permanent) { this.short_channel_id = short_channel_id; this.is_permanent = is_permanent; } + } + export class NodeFailure extends LDKNetworkUpdate { + public Uint8Array node_id; + public boolean is_permanent; + NodeFailure(Uint8Array node_id, boolean is_permanent) { this.node_id = node_id; this.is_permanent = is_permanent; } + } + static native void init(); + } + static { LDKNetworkUpdate.init(); } + public static native LDKNetworkUpdate LDKNetworkUpdate_ref_from_ptr(long ptr); + public static class LDKCOption_NetworkUpdateZ { + private LDKCOption_NetworkUpdateZ() {} + export class Some extends LDKCOption_NetworkUpdateZ { + public number some; + Some(number some) { this.some = some; } + } + export class None extends LDKCOption_NetworkUpdateZ { + None() { } + } + static native void init(); + } + static { LDKCOption_NetworkUpdateZ.init(); } + public static native LDKCOption_NetworkUpdateZ LDKCOption_NetworkUpdateZ_ref_from_ptr(long ptr); public static class LDKSpendableOutputDescriptor { private LDKSpendableOutputDescriptor() {} export class StaticOutput extends LDKSpendableOutputDescriptor { @@ -333,26 +369,6 @@ public static native long new_empty_slice_vec(); } static { LDKErrorAction.init(); } public static native LDKErrorAction LDKErrorAction_ref_from_ptr(long ptr); - public static class LDKHTLCFailChannelUpdate { - private LDKHTLCFailChannelUpdate() {} - export class ChannelUpdateMessage extends LDKHTLCFailChannelUpdate { - public number msg; - ChannelUpdateMessage(number msg) { this.msg = msg; } - } - export class ChannelClosed extends LDKHTLCFailChannelUpdate { - public number short_channel_id; - public boolean is_permanent; - ChannelClosed(number short_channel_id, boolean is_permanent) { this.short_channel_id = short_channel_id; this.is_permanent = is_permanent; } - } - export class NodeFailure extends LDKHTLCFailChannelUpdate { - public Uint8Array node_id; - public boolean is_permanent; - NodeFailure(Uint8Array node_id, boolean is_permanent) { this.node_id = node_id; this.is_permanent = is_permanent; } - } - static native void init(); - } - static { LDKHTLCFailChannelUpdate.init(); } - public static native LDKHTLCFailChannelUpdate LDKHTLCFailChannelUpdate_ref_from_ptr(long ptr); public static class LDKMessageSendEvent { private LDKMessageSendEvent() {} export class SendAcceptChannel extends LDKMessageSendEvent { @@ -433,10 +449,6 @@ public static native long new_empty_slice_vec(); public number action; HandleError(Uint8Array node_id, number action) { this.node_id = node_id; this.action = action; } } - export class PaymentFailureNetworkUpdate extends LDKMessageSendEvent { - public number update; - PaymentFailureNetworkUpdate(number update) { this.update = update; } - } export class SendChannelRangeQuery extends LDKMessageSendEvent { public Uint8Array node_id; public number msg; @@ -478,6 +490,9 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_NoneNoneZ_result_ok(long arg); + public static native void LDKCResult_NoneNoneZ_get_ok(long arg); + public static native void LDKCResult_NoneNoneZ_get_err(long arg); public static native long LDKC2Tuple_SignatureCVec_SignatureZZ_new(Uint8Array a, Uint8Array[] b); public static native Uint8Array LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(long ptr); public static native Uint8Array[] LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(long ptr); @@ -495,13 +510,15 @@ public static native long new_empty_slice_vec(); export interface LDKBaseSign { get_per_commitment_point (idx: number): Uint8Array; release_commitment_secret (idx: number): Uint8Array; + validate_holder_commitment (holder_tx: number): number; channel_keys_id (): Uint8Array; sign_counterparty_commitment (commitment_tx: number): number; + validate_counterparty_revocation (idx: number, secret: Uint8Array): number; sign_holder_commitment_and_htlcs (commitment_tx: number): number; sign_justice_revoked_output (justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array): number; sign_justice_revoked_htlc (justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array, htlc: number): number; sign_counterparty_htlc_transaction (htlc_tx: Uint8Array, input: number, amount: number, per_commitment_point: Uint8Array, htlc: number): number; - sign_closing_transaction (closing_tx: Uint8Array): number; + sign_closing_transaction (closing_tx: number): number; sign_channel_announcement (msg: number): number; ready_channel (channel_parameters: number): void; } @@ -529,6 +546,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.BaseSign_release_commitment_secret(this_arg, idx); return decodeArray(nativeResponseValue); } + // LDKCResult_NoneNoneZ BaseSign_validate_holder_commitment LDKBaseSign *NONNULL_PTR this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx + export function BaseSign_validate_holder_commitment(this_arg: number, holder_tx: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BaseSign_validate_holder_commitment(this_arg, holder_tx); + return nativeResponseValue; + } // LDKThirtyTwoBytes BaseSign_channel_keys_id LDKBaseSign *NONNULL_PTR this_arg export function BaseSign_channel_keys_id(this_arg: number): Uint8Array { if(!isWasmInitialized) { @@ -545,6 +570,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.BaseSign_sign_counterparty_commitment(this_arg, commitment_tx); return nativeResponseValue; } + // LDKCResult_NoneNoneZ BaseSign_validate_counterparty_revocation LDKBaseSign *NONNULL_PTR this_arg, uint64_t idx, const uint8_t (*secret)[32] + export function BaseSign_validate_counterparty_revocation(this_arg: number, idx: number, secret: Uint8Array): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BaseSign_validate_counterparty_revocation(this_arg, idx, encodeArray(secret)); + return nativeResponseValue; + } // LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign_sign_holder_commitment_and_htlcs LDKBaseSign *NONNULL_PTR this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx export function BaseSign_sign_holder_commitment_and_htlcs(this_arg: number, commitment_tx: number): number { if(!isWasmInitialized) { @@ -577,12 +610,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.BaseSign_sign_counterparty_htlc_transaction(this_arg, encodeArray(htlc_tx), input, amount, encodeArray(per_commitment_point), htlc); return nativeResponseValue; } - // LDKCResult_SignatureNoneZ BaseSign_sign_closing_transaction LDKBaseSign *NONNULL_PTR this_arg, struct LDKTransaction closing_tx - export function BaseSign_sign_closing_transaction(this_arg: number, closing_tx: Uint8Array): number { + // LDKCResult_SignatureNoneZ BaseSign_sign_closing_transaction LDKBaseSign *NONNULL_PTR this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx + export function BaseSign_sign_closing_transaction(this_arg: number, closing_tx: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BaseSign_sign_closing_transaction(this_arg, encodeArray(closing_tx)); + const nativeResponseValue = wasm.BaseSign_sign_closing_transaction(this_arg, closing_tx); return nativeResponseValue; } // LDKCResult_SignatureNoneZ BaseSign_sign_channel_announcement LDKBaseSign *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg @@ -964,6 +997,64 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_OutPointDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_OutPointDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_OutPointDecodeErrorZ_get_err(long arg); + + + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START + + export interface LDKType { + type_id (): number; + debug_str (): String; + write (): Uint8Array; + } + + export function LDKType_new(impl: LDKType): number { + throw new Error('unimplemented'); // TODO: bind to WASM + } + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END + + + // uint16_t Type_type_id LDKType *NONNULL_PTR this_arg + export function Type_type_id(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Type_type_id(this_arg); + return nativeResponseValue; + } + // LDKStr Type_debug_str LDKType *NONNULL_PTR this_arg + export function Type_debug_str(this_arg: number): String { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Type_debug_str(this_arg); + return nativeResponseValue; + } + // LDKCVec_u8Z Type_write LDKType *NONNULL_PTR this_arg + export function Type_write(this_arg: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Type_write(this_arg); + return decodeArray(nativeResponseValue); + } + public static class LDKCOption_TypeZ { + private LDKCOption_TypeZ() {} + export class Some extends LDKCOption_TypeZ { + public number some; + Some(number some) { this.some = some; } + } + export class None extends LDKCOption_TypeZ { + None() { } + } + static native void init(); + } + static { LDKCOption_TypeZ.init(); } + public static native LDKCOption_TypeZ LDKCOption_TypeZ_ref_from_ptr(long ptr); + public static native boolean LDKCResult_COption_TypeZDecodeErrorZ_result_ok(long arg); + public static native number LDKCResult_COption_TypeZDecodeErrorZ_get_ok(long arg); + public static native number LDKCResult_COption_TypeZDecodeErrorZ_get_err(long arg); public static native boolean LDKCResult_SiPrefixNoneZ_result_ok(long arg); public static native SiPrefix LDKCResult_SiPrefixNoneZ_get_ok(long arg); public static native void LDKCResult_SiPrefixNoneZ_get_err(long arg); @@ -1038,6 +1129,35 @@ public static native long new_empty_slice_vec(); } static { LDKPaymentPurpose.init(); } public static native LDKPaymentPurpose LDKPaymentPurpose_ref_from_ptr(long ptr); + public static class LDKClosureReason { + private LDKClosureReason() {} + export class CounterpartyForceClosed extends LDKClosureReason { + public String peer_msg; + CounterpartyForceClosed(String peer_msg) { this.peer_msg = peer_msg; } + } + export class HolderForceClosed extends LDKClosureReason { + HolderForceClosed() { } + } + export class CooperativeClosure extends LDKClosureReason { + CooperativeClosure() { } + } + export class CommitmentTxConfirmed extends LDKClosureReason { + CommitmentTxConfirmed() { } + } + export class ProcessingError extends LDKClosureReason { + public String err; + ProcessingError(String err) { this.err = err; } + } + export class DisconnectedPeer extends LDKClosureReason { + DisconnectedPeer() { } + } + export class OutdatedChannelManager extends LDKClosureReason { + OutdatedChannelManager() { } + } + static native void init(); + } + static { LDKClosureReason.init(); } + public static native LDKClosureReason LDKClosureReason_ref_from_ptr(long ptr); public static class LDKEvent { private LDKEvent() {} export class FundingGenerationReady extends LDKEvent { @@ -1057,10 +1177,13 @@ public static native long new_empty_slice_vec(); public Uint8Array payment_preimage; PaymentSent(Uint8Array payment_preimage) { this.payment_preimage = payment_preimage; } } - export class PaymentFailed extends LDKEvent { + export class PaymentPathFailed extends LDKEvent { public Uint8Array payment_hash; public boolean rejected_by_dest; - PaymentFailed(Uint8Array payment_hash, boolean rejected_by_dest) { this.payment_hash = payment_hash; this.rejected_by_dest = rejected_by_dest; } + public number network_update; + public boolean all_paths_failed; + public number[] path; + PaymentPathFailed(Uint8Array payment_hash, boolean rejected_by_dest, number network_update, boolean all_paths_failed, number[] path) { this.payment_hash = payment_hash; this.rejected_by_dest = rejected_by_dest; this.network_update = network_update; this.all_paths_failed = all_paths_failed; this.path = path; } } export class PendingHTLCsForwardable extends LDKEvent { public number time_forwardable; @@ -1075,6 +1198,11 @@ public static native long new_empty_slice_vec(); public boolean claim_from_onchain_tx; PaymentForwarded(number fee_earned_msat, boolean claim_from_onchain_tx) { this.fee_earned_msat = fee_earned_msat; this.claim_from_onchain_tx = claim_from_onchain_tx; } } + export class ChannelClosed extends LDKEvent { + public Uint8Array channel_id; + public number reason; + ChannelClosed(Uint8Array channel_id, number reason) { this.channel_id = channel_id; this.reason = reason; } + } static native void init(); } static { LDKEvent.init(); } @@ -1088,9 +1216,42 @@ public static native long new_empty_slice_vec(); public static native Uint8Array LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(long ptr); public static native number[] LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(long ptr); public static native long LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(number[] elems); + public static class LDKBalance { + private LDKBalance() {} + export class ClaimableOnChannelClose extends LDKBalance { + public number claimable_amount_satoshis; + ClaimableOnChannelClose(number claimable_amount_satoshis) { this.claimable_amount_satoshis = claimable_amount_satoshis; } + } + export class ClaimableAwaitingConfirmations extends LDKBalance { + public number claimable_amount_satoshis; + public number confirmation_height; + ClaimableAwaitingConfirmations(number claimable_amount_satoshis, number confirmation_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.confirmation_height = confirmation_height; } + } + export class ContentiousClaimable extends LDKBalance { + public number claimable_amount_satoshis; + public number timeout_height; + ContentiousClaimable(number claimable_amount_satoshis, number timeout_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.timeout_height = timeout_height; } + } + export class MaybeClaimableHTLCAwaitingTimeout extends LDKBalance { + public number claimable_amount_satoshis; + public number claimable_height; + MaybeClaimableHTLCAwaitingTimeout(number claimable_amount_satoshis, number claimable_height) { this.claimable_amount_satoshis = claimable_amount_satoshis; this.claimable_height = claimable_height; } + } + static native void init(); + } + static { LDKBalance.init(); } + public static native LDKBalance LDKBalance_ref_from_ptr(long ptr); + public static native long LDKCVec_BalanceZ_new(number[] elems); public static native boolean LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_NoneLightningErrorZ_result_ok(long arg); + public static native void LDKCResult_NoneLightningErrorZ_get_ok(long arg); + public static native number LDKCResult_NoneLightningErrorZ_get_err(long arg); + public static native long LDKC2Tuple_PublicKeyTypeZ_new(Uint8Array a, number b); + public static native Uint8Array LDKC2Tuple_PublicKeyTypeZ_get_a(long ptr); + public static native number LDKC2Tuple_PublicKeyTypeZ_get_b(long ptr); + public static native long LDKCVec_C2Tuple_PublicKeyTypeZZ_new(number[] elems); public static native boolean LDKCResult_boolLightningErrorZ_result_ok(long arg); public static native boolean LDKCResult_boolLightningErrorZ_get_ok(long arg); public static native number LDKCResult_boolLightningErrorZ_get_err(long arg); @@ -1100,9 +1261,6 @@ public static native long new_empty_slice_vec(); public static native number LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(long ptr); public static native long LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(number[] elems); public static native long LDKCVec_NodeAnnouncementZ_new(number[] elems); - public static native boolean LDKCResult_NoneLightningErrorZ_result_ok(long arg); - public static native void LDKCResult_NoneLightningErrorZ_get_ok(long arg); - public static native number LDKCResult_NoneLightningErrorZ_get_err(long arg); public static native boolean LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(long arg); public static native Uint8Array LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(long arg); public static native number LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(long arg); @@ -1112,6 +1270,43 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_boolPeerHandleErrorZ_result_ok(long arg); public static native boolean LDKCResult_boolPeerHandleErrorZ_get_ok(long arg); public static native number LDKCResult_boolPeerHandleErrorZ_get_err(long arg); + + + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START + + export interface LDKAccess { + get_utxo (genesis_hash: Uint8Array, short_channel_id: number): number; + } + + export function LDKAccess_new(impl: LDKAccess): number { + throw new Error('unimplemented'); // TODO: bind to WASM + } + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END + + + // LDKCResult_TxOutAccessErrorZ Access_get_utxo LDKAccess *NONNULL_PTR this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id + export function Access_get_utxo(this_arg: number, genesis_hash: Uint8Array, short_channel_id: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Access_get_utxo(this_arg, encodeArray(genesis_hash), short_channel_id); + return nativeResponseValue; + } + public static class LDKCOption_AccessZ { + private LDKCOption_AccessZ() {} + export class Some extends LDKCOption_AccessZ { + public number some; + Some(number some) { this.some = some; } + } + export class None extends LDKCOption_AccessZ { + None() { } + } + static native void init(); + } + static { LDKCOption_AccessZ.init(); } + public static native LDKCOption_AccessZ LDKCOption_AccessZ_ref_from_ptr(long ptr); public static native boolean LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(long arg); @@ -1259,6 +1454,52 @@ public static native long new_empty_slice_vec(); +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START + + export interface LDKFilter { + register_tx (txid: Uint8Array, script_pubkey: Uint8Array): void; + register_output (output: number): number; + } + + export function LDKFilter_new(impl: LDKFilter): number { + throw new Error('unimplemented'); // TODO: bind to WASM + } + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END + + + // void Filter_register_tx LDKFilter *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey + export function Filter_register_tx(this_arg: number, txid: Uint8Array, script_pubkey: Uint8Array): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Filter_register_tx(this_arg, encodeArray(txid), encodeArray(script_pubkey)); + // debug statements here + } + // LDKCOption_C2Tuple_usizeTransactionZZ Filter_register_output LDKFilter *NONNULL_PTR this_arg, struct LDKWatchedOutput output + export function Filter_register_output(this_arg: number, output: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Filter_register_output(this_arg, output); + return nativeResponseValue; + } + public static class LDKCOption_FilterZ { + private LDKCOption_FilterZ() {} + export class Some extends LDKCOption_FilterZ { + public number some; + Some(number some) { this.some = some; } + } + export class None extends LDKCOption_FilterZ { + None() { } + } + static native void init(); + } + static { LDKCOption_FilterZ.init(); } + public static native LDKCOption_FilterZ LDKCOption_FilterZ_ref_from_ptr(long ptr); + + + // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START export interface LDKMessageSendEventsProvider { @@ -1296,7 +1537,7 @@ public static native long new_empty_slice_vec(); // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END - // void EventHandler_handle_event LDKEventHandler *NONNULL_PTR this_arg, struct LDKEvent event + // void EventHandler_handle_event LDKEventHandler *NONNULL_PTR this_arg, const struct LDKEvent *NONNULL_PTR event export function EventHandler_handle_event(this_arg: number, event: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -1331,30 +1572,6 @@ public static native long new_empty_slice_vec(); -// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START - - export interface LDKAccess { - get_utxo (genesis_hash: Uint8Array, short_channel_id: number): number; - } - - export function LDKAccess_new(impl: LDKAccess): number { - throw new Error('unimplemented'); // TODO: bind to WASM - } - -// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END - - - // LDKCResult_TxOutAccessErrorZ Access_get_utxo LDKAccess *NONNULL_PTR this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id - export function Access_get_utxo(this_arg: number, genesis_hash: Uint8Array, short_channel_id: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.Access_get_utxo(this_arg, encodeArray(genesis_hash), short_channel_id); - return nativeResponseValue; - } - - - // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START export interface LDKListen { @@ -1439,39 +1656,6 @@ public static native long new_empty_slice_vec(); -// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START - - export interface LDKFilter { - register_tx (txid: Uint8Array, script_pubkey: Uint8Array): void; - register_output (output: number): number; - } - - export function LDKFilter_new(impl: LDKFilter): number { - throw new Error('unimplemented'); // TODO: bind to WASM - } - -// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END - - - // void Filter_register_tx LDKFilter *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey - export function Filter_register_tx(this_arg: number, txid: Uint8Array, script_pubkey: Uint8Array): void { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.Filter_register_tx(this_arg, encodeArray(txid), encodeArray(script_pubkey)); - // debug statements here - } - // LDKCOption_C2Tuple_usizeTransactionZZ Filter_register_output LDKFilter *NONNULL_PTR this_arg, struct LDKWatchedOutput output - export function Filter_register_output(this_arg: number, output: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.Filter_register_output(this_arg, output); - return nativeResponseValue; - } - - - // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START export interface LDKPersist { @@ -1706,7 +1890,6 @@ public static native long new_empty_slice_vec(); handle_node_announcement (msg: number): number; handle_channel_announcement (msg: number): number; handle_channel_update (msg: number): number; - handle_htlc_fail_channel_update (update: number): void; get_next_channel_announcements (starting_point: number, batch_amount: number): number[]; get_next_node_announcements (starting_point: Uint8Array, batch_amount: number): number[]; sync_routing_table (their_node_id: Uint8Array, init: number): void; @@ -1747,14 +1930,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RoutingMessageHandler_handle_channel_update(this_arg, msg); return nativeResponseValue; } - // void RoutingMessageHandler_handle_htlc_fail_channel_update LDKRoutingMessageHandler *NONNULL_PTR this_arg, const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update - export function RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: number, update: number): void { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg, update); - // debug statements here - } // LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler_get_next_channel_announcements LDKRoutingMessageHandler *NONNULL_PTR this_arg, uint64_t starting_point, uint8_t batch_amount export function RoutingMessageHandler_get_next_channel_announcements(this_arg: number, starting_point: number, batch_amount: number): number[] { if(!isWasmInitialized) { @@ -1814,6 +1989,63 @@ public static native long new_empty_slice_vec(); +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START + + export interface LDKCustomMessageReader { + read (message_type: number, buffer: Uint8Array): number; + } + + export function LDKCustomMessageReader_new(impl: LDKCustomMessageReader): number { + throw new Error('unimplemented'); // TODO: bind to WASM + } + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END + + + // LDKCResult_COption_TypeZDecodeErrorZ CustomMessageReader_read LDKCustomMessageReader *NONNULL_PTR this_arg, uint16_t message_type, struct LDKu8slice buffer + export function CustomMessageReader_read(this_arg: number, message_type: number, buffer: Uint8Array): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CustomMessageReader_read(this_arg, message_type, encodeArray(buffer)); + return nativeResponseValue; + } + + + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START + + export interface LDKCustomMessageHandler { + handle_custom_message (msg: number, sender_node_id: Uint8Array): number; + get_and_clear_pending_msg (): number[]; + } + + export function LDKCustomMessageHandler_new(impl: LDKCustomMessageHandler, CustomMessageReader: LDKCustomMessageReader): number { + throw new Error('unimplemented'); // TODO: bind to WASM + } + +// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END + + + // LDKCResult_NoneLightningErrorZ CustomMessageHandler_handle_custom_message LDKCustomMessageHandler *NONNULL_PTR this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id + export function CustomMessageHandler_handle_custom_message(this_arg: number, msg: number, sender_node_id: Uint8Array): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CustomMessageHandler_handle_custom_message(this_arg, msg, encodeArray(sender_node_id)); + return nativeResponseValue; + } + // LDKCVec_C2Tuple_PublicKeyTypeZZ CustomMessageHandler_get_and_clear_pending_msg LDKCustomMessageHandler *NONNULL_PTR this_arg + export function CustomMessageHandler_get_and_clear_pending_msg(this_arg: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CustomMessageHandler_get_and_clear_pending_msg(this_arg); + return nativeResponseValue; + } + + + // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START export interface LDKSocketDescriptor { @@ -2305,6 +2537,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig); return nativeResponseValue; } + // struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); + export function CResult_TrustedClosingTransactionNoneZ_ok(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_TrustedClosingTransactionNoneZ_ok(o); + return nativeResponseValue; + } + // struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); + export function CResult_TrustedClosingTransactionNoneZ_err(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_TrustedClosingTransactionNoneZ_err(); + return nativeResponseValue; + } + // void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); + export function CResult_TrustedClosingTransactionNoneZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_TrustedClosingTransactionNoneZ_free(_res); + // debug statements here + } // struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); export function CResult_CommitmentTransactionDecodeErrorZ_ok(o: number): number { if(!isWasmInitialized) { @@ -2785,6 +3041,38 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.COption_C2Tuple_usizeTransactionZZ_clone(orig); return nativeResponseValue; } + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); + export function COption_NetworkUpdateZ_some(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_NetworkUpdateZ_some(o); + return nativeResponseValue; + } + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); + export function COption_NetworkUpdateZ_none(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_NetworkUpdateZ_none(); + return nativeResponseValue; + } + // void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); + export function COption_NetworkUpdateZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_NetworkUpdateZ_free(_res); + // debug statements here + } + // struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); + export function COption_NetworkUpdateZ_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_NetworkUpdateZ_clone(orig); + return nativeResponseValue; + } // void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); export function CVec_SpendableOutputDescriptorZ_free(_res: number[]): void { if(!isWasmInitialized) { @@ -2993,6 +3281,38 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig); return nativeResponseValue; } + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); + export function CResult_NoneNoneZ_ok(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneNoneZ_ok(); + return nativeResponseValue; + } + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); + export function CResult_NoneNoneZ_err(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneNoneZ_err(); + return nativeResponseValue; + } + // void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); + export function CResult_NoneNoneZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneNoneZ_free(_res); + // debug statements here + } + // struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); + export function CResult_NoneNoneZ_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneNoneZ_clone(orig); + return nativeResponseValue; + } // struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); export function C2Tuple_SignatureCVec_SignatureZZ_clone(orig: number): number { if(!isWasmInitialized) { @@ -3633,6 +3953,70 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_OutPointDecodeErrorZ_clone(orig); return nativeResponseValue; } + // struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); + export function COption_TypeZ_some(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_TypeZ_some(o); + return nativeResponseValue; + } + // struct LDKCOption_TypeZ COption_TypeZ_none(void); + export function COption_TypeZ_none(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_TypeZ_none(); + return nativeResponseValue; + } + // void COption_TypeZ_free(struct LDKCOption_TypeZ _res); + export function COption_TypeZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_TypeZ_free(_res); + // debug statements here + } + // struct LDKCOption_TypeZ COption_TypeZ_clone(const struct LDKCOption_TypeZ *NONNULL_PTR orig); + export function COption_TypeZ_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_TypeZ_clone(orig); + return nativeResponseValue; + } + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); + export function CResult_COption_TypeZDecodeErrorZ_ok(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_COption_TypeZDecodeErrorZ_ok(o); + return nativeResponseValue; + } + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); + export function CResult_COption_TypeZDecodeErrorZ_err(e: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_COption_TypeZDecodeErrorZ_err(e); + return nativeResponseValue; + } + // void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); + export function CResult_COption_TypeZDecodeErrorZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_COption_TypeZDecodeErrorZ_free(_res); + // debug statements here + } + // struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_clone(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR orig); + export function CResult_COption_TypeZDecodeErrorZ_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_COption_TypeZDecodeErrorZ_clone(orig); + return nativeResponseValue; + } // struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o); export function CResult_SiPrefixNoneZ_ok(o: SiPrefix): number { if(!isWasmInitialized) { @@ -4262,39 +4646,111 @@ public static native long new_empty_slice_vec(); if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res); - // debug statements here + const nativeResponseValue = wasm.C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res); + // debug statements here + } + // void CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res); + export function CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res: number[]): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res); + // debug statements here + } + // void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); + export function CVec_BalanceZ_free(_res: number[]): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CVec_BalanceZ_free(_res); + // debug statements here + } + // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); + export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o); + return nativeResponseValue; + } + // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); + export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e); + return nativeResponseValue; + } + // void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); + export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res); + // debug statements here + } + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); + export function CResult_NoneLightningErrorZ_ok(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_ok(); + return nativeResponseValue; + } + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); + export function CResult_NoneLightningErrorZ_err(e: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_err(e); + return nativeResponseValue; + } + // void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); + export function CResult_NoneLightningErrorZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_free(_res); + // debug statements here + } + // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); + export function CResult_NoneLightningErrorZ_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_clone(orig); + return nativeResponseValue; } - // void CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res); - export function CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res: number[]): void { + // struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_clone(const struct LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR orig); + export function C2Tuple_PublicKeyTypeZ_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res); - // debug statements here + const nativeResponseValue = wasm.C2Tuple_PublicKeyTypeZ_clone(orig); + return nativeResponseValue; } - // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); - export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: number): number { + // struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); + export function C2Tuple_PublicKeyTypeZ_new(a: Uint8Array, b: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o); + const nativeResponseValue = wasm.C2Tuple_PublicKeyTypeZ_new(encodeArray(a), b); return nativeResponseValue; } - // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); - export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: number): number { + // void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); + export function C2Tuple_PublicKeyTypeZ_free(_res: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e); - return nativeResponseValue; + const nativeResponseValue = wasm.C2Tuple_PublicKeyTypeZ_free(_res); + // debug statements here } - // void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); - export function CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: number): void { + // void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); + export function CVec_C2Tuple_PublicKeyTypeZZ_free(_res: number[]): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res); + const nativeResponseValue = wasm.CVec_C2Tuple_PublicKeyTypeZZ_free(_res); // debug statements here } // struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); @@ -4369,38 +4825,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CVec_NodeAnnouncementZ_free(_res); // debug statements here } - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); - export function CResult_NoneLightningErrorZ_ok(): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_ok(); - return nativeResponseValue; - } - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); - export function CResult_NoneLightningErrorZ_err(e: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_err(e); - return nativeResponseValue; - } - // void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); - export function CResult_NoneLightningErrorZ_free(_res: number): void { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_free(_res); - // debug statements here - } - // struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); - export function CResult_NoneLightningErrorZ_clone(orig: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.CResult_NoneLightningErrorZ_clone(orig); - return nativeResponseValue; - } // void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); export function CVec_PublicKeyZ_free(_res: Uint8Array[]): void { if(!isWasmInitialized) { @@ -4505,6 +4929,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_boolPeerHandleErrorZ_clone(orig); return nativeResponseValue; } + // struct LDKCOption_AccessZ COption_AccessZ_some(struct LDKAccess o); + export function COption_AccessZ_some(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_AccessZ_some(o); + return nativeResponseValue; + } + // struct LDKCOption_AccessZ COption_AccessZ_none(void); + export function COption_AccessZ_none(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_AccessZ_none(); + return nativeResponseValue; + } + // void COption_AccessZ_free(struct LDKCOption_AccessZ _res); + export function COption_AccessZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_AccessZ_free(_res); + // debug statements here + } // struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); export function CResult_DirectionalChannelInfoDecodeErrorZ_ok(o: number): number { if(!isWasmInitialized) { @@ -4697,14 +5145,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_NetworkGraphDecodeErrorZ_free(_res); // debug statements here } - // struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); - export function CResult_NetworkGraphDecodeErrorZ_clone(orig: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.CResult_NetworkGraphDecodeErrorZ_clone(orig); - return nativeResponseValue; - } // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_ok(struct LDKNetAddress o); export function CResult_NetAddressu8Z_ok(o: number): number { if(!isWasmInitialized) { @@ -5889,6 +6329,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_InvoiceSignOrCreationErrorZ_clone(orig); return nativeResponseValue; } + // struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); + export function COption_FilterZ_some(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_FilterZ_some(o); + return nativeResponseValue; + } + // struct LDKCOption_FilterZ COption_FilterZ_none(void); + export function COption_FilterZ_none(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_FilterZ_none(); + return nativeResponseValue; + } + // void COption_FilterZ_free(struct LDKCOption_FilterZ _res); + export function COption_FilterZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_FilterZ_free(_res); + // debug statements here + } // void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); export function PaymentPurpose_free(this_ptr: number): void { if(!isWasmInitialized) { @@ -5921,6 +6385,86 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.PaymentPurpose_spontaneous_payment(encodeArray(a)); return nativeResponseValue; } + // void ClosureReason_free(struct LDKClosureReason this_ptr); + export function ClosureReason_free(this_ptr: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_free(this_ptr); + // debug statements here + } + // struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); + export function ClosureReason_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_clone(orig); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg); + export function ClosureReason_counterparty_force_closed(peer_msg: String): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_counterparty_force_closed(peer_msg); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_holder_force_closed(void); + export function ClosureReason_holder_force_closed(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_holder_force_closed(); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_cooperative_closure(void); + export function ClosureReason_cooperative_closure(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_cooperative_closure(); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); + export function ClosureReason_commitment_tx_confirmed(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_commitment_tx_confirmed(); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); + export function ClosureReason_processing_error(err: String): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_processing_error(err); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_disconnected_peer(void); + export function ClosureReason_disconnected_peer(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_disconnected_peer(); + return nativeResponseValue; + } + // struct LDKClosureReason ClosureReason_outdated_channel_manager(void); + export function ClosureReason_outdated_channel_manager(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_outdated_channel_manager(); + return nativeResponseValue; + } + // struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); + export function ClosureReason_write(obj: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosureReason_write(obj); + return decodeArray(nativeResponseValue); + } // void Event_free(struct LDKEvent this_ptr); export function Event_free(this_ptr: number): void { if(!isWasmInitialized) { @@ -5961,12 +6505,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Event_payment_sent(encodeArray(payment_preimage)); return nativeResponseValue; } - // struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest); - export function Event_payment_failed(payment_hash: Uint8Array, rejected_by_dest: boolean): number { + // struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path); + export function Event_payment_path_failed(payment_hash: Uint8Array, rejected_by_dest: boolean, network_update: number, all_paths_failed: boolean, path: number[]): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.Event_payment_failed(encodeArray(payment_hash), rejected_by_dest); + const nativeResponseValue = wasm.Event_payment_path_failed(encodeArray(payment_hash), rejected_by_dest, network_update, all_paths_failed, path); return nativeResponseValue; } // struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); @@ -5993,6 +6537,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Event_payment_forwarded(fee_earned_msat, claim_from_onchain_tx); return nativeResponseValue; } + // struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKClosureReason reason); + export function Event_channel_closed(channel_id: Uint8Array, reason: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Event_channel_closed(encodeArray(channel_id), reason); + return nativeResponseValue; + } // struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); export function Event_write(obj: number): Uint8Array { if(!isWasmInitialized) { @@ -6145,14 +6697,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.MessageSendEvent_handle_error(encodeArray(node_id), action); return nativeResponseValue; } - // struct LDKMessageSendEvent MessageSendEvent_payment_failure_network_update(struct LDKHTLCFailChannelUpdate update); - export function MessageSendEvent_payment_failure_network_update(update: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.MessageSendEvent_payment_failure_network_update(update); - return nativeResponseValue; - } // struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); export function MessageSendEvent_send_channel_range_query(node_id: Uint8Array, msg: number): number { if(!isWasmInitialized) { @@ -7121,7 +7665,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChainMonitor_free(this_obj); // debug statements here } - // MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); + // MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); export function ChainMonitor_new(chain_source: number, broadcaster: number, logger: number, feeest: number, persister: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -7129,6 +7673,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChainMonitor_new(chain_source, broadcaster, logger, feeest, persister); return nativeResponseValue; } + // MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); + export function ChainMonitor_get_claimable_balances(this_arg: number, ignored_channels: number[]): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainMonitor_get_claimable_balances(this_arg, ignored_channels); + return nativeResponseValue; + } // struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); export function ChainMonitor_as_Listen(this_arg: number): number { if(!isWasmInitialized) { @@ -7273,12 +7825,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.MonitorEvent_htlcevent(a); return nativeResponseValue; } - // struct LDKMonitorEvent MonitorEvent_commitment_tx_broadcasted(struct LDKOutPoint a); - export function MonitorEvent_commitment_tx_broadcasted(a: number): number { + // struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); + export function MonitorEvent_commitment_tx_confirmed(a: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.MonitorEvent_commitment_tx_broadcasted(a); + const nativeResponseValue = wasm.MonitorEvent_commitment_tx_confirmed(a); return nativeResponseValue; } // void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); @@ -7313,6 +7865,62 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.HTLCUpdate_read(encodeArray(ser)); return nativeResponseValue; } + // void Balance_free(struct LDKBalance this_ptr); + export function Balance_free(this_ptr: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_free(this_ptr); + // debug statements here + } + // struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); + export function Balance_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_clone(orig); + return nativeResponseValue; + } + // struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); + export function Balance_claimable_on_channel_close(claimable_amount_satoshis: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_claimable_on_channel_close(claimable_amount_satoshis); + return nativeResponseValue; + } + // struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); + export function Balance_claimable_awaiting_confirmations(claimable_amount_satoshis: number, confirmation_height: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + return nativeResponseValue; + } + // struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); + export function Balance_contentious_claimable(claimable_amount_satoshis: number, timeout_height: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + return nativeResponseValue; + } + // struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height); + export function Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: number, claimable_height: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + return nativeResponseValue; + } + // bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); + export function Balance_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Balance_eq(a, b); + return nativeResponseValue; + } // void ChannelMonitor_free(struct LDKChannelMonitor this_obj); export function ChannelMonitor_free(this_obj: number): void { if(!isWasmInitialized) { @@ -7457,6 +8065,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelMonitor_current_best_block(this_arg); return nativeResponseValue; } + // MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + export function ChannelMonitor_get_claimable_balances(this_arg: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelMonitor_get_claimable_balances(this_arg); + return nativeResponseValue; + } // void Persist_free(struct LDKPersist this_ptr); export function Persist_free(this_ptr: number): void { if(!isWasmInitialized) { @@ -8150,71 +8766,143 @@ public static native long new_empty_slice_vec(); if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.KeysManager_as_KeysInterface(this_arg); + const nativeResponseValue = wasm.KeysManager_as_KeysInterface(this_arg); + return nativeResponseValue; + } + // void ChannelManager_free(struct LDKChannelManager this_obj); + export function ChannelManager_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelManager_free(this_obj); + // debug statements here + } + // void ChainParameters_free(struct LDKChainParameters this_obj); + export function ChainParameters_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_free(this_obj); + // debug statements here + } + // enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); + export function ChainParameters_get_network(this_ptr: number): Network { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_get_network(this_ptr); + return nativeResponseValue; + } + // void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); + export function ChainParameters_set_network(this_ptr: number, val: Network): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_set_network(this_ptr, val); + // debug statements here + } + // struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); + export function ChainParameters_get_best_block(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_get_best_block(this_ptr); + return nativeResponseValue; + } + // void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); + export function ChainParameters_set_best_block(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_set_best_block(this_ptr, val); + // debug statements here + } + // MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); + export function ChainParameters_new(network_arg: Network, best_block_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_new(network_arg, best_block_arg); + return nativeResponseValue; + } + // struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); + export function ChainParameters_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChainParameters_clone(orig); return nativeResponseValue; } - // void ChannelManager_free(struct LDKChannelManager this_obj); - export function ChannelManager_free(this_obj: number): void { + // void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); + export function CounterpartyForwardingInfo_free(this_obj: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelManager_free(this_obj); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_free(this_obj); // debug statements here } - // void ChainParameters_free(struct LDKChainParameters this_obj); - export function ChainParameters_free(this_obj: number): void { + // uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + export function CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_free(this_obj); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_get_fee_base_msat(this_ptr); + return nativeResponseValue; + } + // void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + export function CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CounterpartyForwardingInfo_set_fee_base_msat(this_ptr, val); // debug statements here } - // enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); - export function ChainParameters_get_network(this_ptr: number): Network { + // uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + export function CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_get_network(this_ptr); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr); return nativeResponseValue; } - // void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); - export function ChainParameters_set_network(this_ptr: number, val: Network): void { + // void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + export function CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_set_network(this_ptr, val); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr, val); // debug statements here } - // struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); - export function ChainParameters_get_best_block(this_ptr: number): number { + // uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + export function CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_get_best_block(this_ptr); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr); return nativeResponseValue; } - // void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); - export function ChainParameters_set_best_block(this_ptr: number, val: number): void { + // void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); + export function CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_set_best_block(this_ptr, val); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr, val); // debug statements here } - // MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); - export function ChainParameters_new(network_arg: Network, best_block_arg: number): number { + // MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); + export function CounterpartyForwardingInfo_new(fee_base_msat_arg: number, fee_proportional_millionths_arg: number, cltv_expiry_delta_arg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_new(network_arg, best_block_arg); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); return nativeResponseValue; } - // struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); - export function ChainParameters_clone(orig: number): number { + // struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); + export function CounterpartyForwardingInfo_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChainParameters_clone(orig); + const nativeResponseValue = wasm.CounterpartyForwardingInfo_clone(orig); return nativeResponseValue; } // void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); @@ -8273,6 +8961,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr, val); // debug statements here } + // struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + export function ChannelCounterparty_get_forwarding_info(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelCounterparty_get_forwarding_info(this_ptr); + return nativeResponseValue; + } + // void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); + export function ChannelCounterparty_set_forwarding_info(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelCounterparty_set_forwarding_info(this_ptr, val); + // debug statements here + } + // MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg); + export function ChannelCounterparty_new(node_id_arg: Uint8Array, features_arg: number, unspendable_punishment_reserve_arg: number, forwarding_info_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelCounterparty_new(encodeArray(node_id_arg), features_arg, unspendable_punishment_reserve_arg, forwarding_info_arg); + return nativeResponseValue; + } // struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); export function ChannelCounterparty_clone(orig: number): number { if(!isWasmInitialized) { @@ -11905,6 +12617,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CommitmentUpdate_free(this_obj); // debug statements here } + // struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + export function CommitmentUpdate_get_update_add_htlcs(this_ptr: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CommitmentUpdate_get_update_add_htlcs(this_ptr); + return nativeResponseValue; + } // void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); export function CommitmentUpdate_set_update_add_htlcs(this_ptr: number, val: number[]): void { if(!isWasmInitialized) { @@ -11913,6 +12633,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CommitmentUpdate_set_update_add_htlcs(this_ptr, val); // debug statements here } + // struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + export function CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CommitmentUpdate_get_update_fulfill_htlcs(this_ptr); + return nativeResponseValue; + } // void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); export function CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: number, val: number[]): void { if(!isWasmInitialized) { @@ -11921,6 +12649,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CommitmentUpdate_set_update_fulfill_htlcs(this_ptr, val); // debug statements here } + // struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + export function CommitmentUpdate_get_update_fail_htlcs(this_ptr: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CommitmentUpdate_get_update_fail_htlcs(this_ptr); + return nativeResponseValue; + } // void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); export function CommitmentUpdate_set_update_fail_htlcs(this_ptr: number, val: number[]): void { if(!isWasmInitialized) { @@ -11929,6 +12665,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CommitmentUpdate_set_update_fail_htlcs(this_ptr, val); // debug statements here } + // struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); + export function CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: number): number[] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr); + return nativeResponseValue; + } // void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); export function CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: number, val: number[]): void { if(!isWasmInitialized) { @@ -11985,46 +12729,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CommitmentUpdate_clone(orig); return nativeResponseValue; } - // void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); - export function HTLCFailChannelUpdate_free(this_ptr: number): void { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.HTLCFailChannelUpdate_free(this_ptr); - // debug statements here - } - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig); - export function HTLCFailChannelUpdate_clone(orig: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.HTLCFailChannelUpdate_clone(orig); - return nativeResponseValue; - } - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_update_message(struct LDKChannelUpdate msg); - export function HTLCFailChannelUpdate_channel_update_message(msg: number): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.HTLCFailChannelUpdate_channel_update_message(msg); - return nativeResponseValue; - } - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent); - export function HTLCFailChannelUpdate_channel_closed(short_channel_id: number, is_permanent: boolean): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - return nativeResponseValue; - } - // struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); - export function HTLCFailChannelUpdate_node_failure(node_id: Uint8Array, is_permanent: boolean): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.HTLCFailChannelUpdate_node_failure(encodeArray(node_id), is_permanent); - return nativeResponseValue; - } // void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); export function ChannelMessageHandler_free(this_ptr: number): void { if(!isWasmInitialized) { @@ -12489,14 +13193,6 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.QueryShortChannelIds_write(obj); return decodeArray(nativeResponseValue); } - // struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); - export function ReplyShortChannelIdsEnd_read(ser: Uint8Array): number { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.ReplyShortChannelIdsEnd_read(encodeArray(ser)); - return nativeResponseValue; - } // struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); export function ReplyShortChannelIdsEnd_write(obj: number): Uint8Array { if(!isWasmInitialized) { @@ -12505,20 +13201,20 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ReplyShortChannelIdsEnd_write(obj); return decodeArray(nativeResponseValue); } - // MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); - export function QueryChannelRange_end_blocknum(this_arg: number): number { + // struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); + export function ReplyShortChannelIdsEnd_read(ser: Uint8Array): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.QueryChannelRange_end_blocknum(this_arg); + const nativeResponseValue = wasm.ReplyShortChannelIdsEnd_read(encodeArray(ser)); return nativeResponseValue; } - // struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); - export function QueryChannelRange_read(ser: Uint8Array): number { + // MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); + export function QueryChannelRange_end_blocknum(this_arg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.QueryChannelRange_read(encodeArray(ser)); + const nativeResponseValue = wasm.QueryChannelRange_end_blocknum(this_arg); return nativeResponseValue; } // struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); @@ -12529,6 +13225,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.QueryChannelRange_write(obj); return decodeArray(nativeResponseValue); } + // struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); + export function QueryChannelRange_read(ser: Uint8Array): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.QueryChannelRange_read(encodeArray(ser)); + return nativeResponseValue; + } // struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); export function ReplyChannelRange_read(ser: Uint8Array): number { if(!isWasmInitialized) { @@ -12545,6 +13249,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ReplyChannelRange_write(obj); return decodeArray(nativeResponseValue); } + // struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); + export function GossipTimestampFilter_write(obj: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.GossipTimestampFilter_write(obj); + return decodeArray(nativeResponseValue); + } // struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); export function GossipTimestampFilter_read(ser: Uint8Array): number { if(!isWasmInitialized) { @@ -12553,13 +13265,13 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.GossipTimestampFilter_read(encodeArray(ser)); return nativeResponseValue; } - // struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); - export function GossipTimestampFilter_write(obj: number): Uint8Array { + // void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); + export function CustomMessageHandler_free(this_ptr: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.GossipTimestampFilter_write(obj); - return decodeArray(nativeResponseValue); + const nativeResponseValue = wasm.CustomMessageHandler_free(this_ptr); + // debug statements here } // void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); export function IgnoringMessageHandler_free(this_obj: number): void { @@ -12593,6 +13305,22 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.IgnoringMessageHandler_as_RoutingMessageHandler(this_arg); return nativeResponseValue; } + // struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + export function IgnoringMessageHandler_as_CustomMessageReader(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.IgnoringMessageHandler_as_CustomMessageReader(this_arg); + return nativeResponseValue; + } + // struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + export function IgnoringMessageHandler_as_CustomMessageHandler(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.IgnoringMessageHandler_as_CustomMessageHandler(this_arg); + return nativeResponseValue; + } // void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); export function ErroringMessageHandler_free(this_obj: number): void { if(!isWasmInitialized) { @@ -12737,12 +13465,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.PeerManager_free(this_obj); // debug statements here } - // MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger); - export function PeerManager_new(message_handler: number, our_node_secret: Uint8Array, ephemeral_random_data: Uint8Array, logger: number): number { + // MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler); + export function PeerManager_new(message_handler: number, our_node_secret: Uint8Array, ephemeral_random_data: Uint8Array, logger: number, custom_message_handler: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PeerManager_new(message_handler, encodeArray(our_node_secret), encodeArray(ephemeral_random_data), logger); + const nativeResponseValue = wasm.PeerManager_new(message_handler, encodeArray(our_node_secret), encodeArray(ephemeral_random_data), logger, custom_message_handler); return nativeResponseValue; } // MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); @@ -12825,6 +13553,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.build_commitment_secret(encodeArray(commitment_seed), idx); return decodeArray(nativeResponseValue); } + // struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); + export function build_closing_transaction(to_holder_value_sat: number, to_counterparty_value_sat: number, to_holder_script: Uint8Array, to_counterparty_script: Uint8Array, funding_outpoint: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, encodeArray(to_holder_script), encodeArray(to_counterparty_script), funding_outpoint); + return decodeArray(nativeResponseValue); + } // struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); export function derive_private_key(per_commitment_point: Uint8Array, base_secret: Uint8Array): number { if(!isWasmInitialized) { @@ -13681,6 +14417,102 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.BuiltCommitmentTransaction_sign(this_arg, encodeArray(funding_key), encodeArray(funding_redeemscript), channel_value_satoshis); return decodeArray(nativeResponseValue); } + // void ClosingTransaction_free(struct LDKClosingTransaction this_obj); + export function ClosingTransaction_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_free(this_obj); + // debug statements here + } + // MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); + export function ClosingTransaction_new(to_holder_value_sat: number, to_counterparty_value_sat: number, to_holder_script: Uint8Array, to_counterparty_script: Uint8Array, funding_outpoint: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, encodeArray(to_holder_script), encodeArray(to_counterparty_script), funding_outpoint); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + export function ClosingTransaction_trust(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_trust(this_arg); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); + export function ClosingTransaction_verify(this_arg: number, funding_outpoint: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_verify(this_arg, funding_outpoint); + return nativeResponseValue; + } + // MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + export function ClosingTransaction_to_holder_value_sat(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_to_holder_value_sat(this_arg); + return nativeResponseValue; + } + // MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + export function ClosingTransaction_to_counterparty_value_sat(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_to_counterparty_value_sat(this_arg); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + export function ClosingTransaction_to_holder_script(this_arg: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_to_holder_script(this_arg); + return decodeArray(nativeResponseValue); + } + // MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); + export function ClosingTransaction_to_counterparty_script(this_arg: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ClosingTransaction_to_counterparty_script(this_arg); + return decodeArray(nativeResponseValue); + } + // void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); + export function TrustedClosingTransaction_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TrustedClosingTransaction_free(this_obj); + // debug statements here + } + // MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); + export function TrustedClosingTransaction_built_transaction(this_arg: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TrustedClosingTransaction_built_transaction(this_arg); + return decodeArray(nativeResponseValue); + } + // MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + export function TrustedClosingTransaction_get_sighash_all(this_arg: number, funding_redeemscript: Uint8Array, channel_value_satoshis: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TrustedClosingTransaction_get_sighash_all(this_arg, encodeArray(funding_redeemscript), channel_value_satoshis); + return decodeArray(nativeResponseValue); + } + // MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + export function TrustedClosingTransaction_sign(this_arg: number, funding_key: Uint8Array, funding_redeemscript: Uint8Array, channel_value_satoshis: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TrustedClosingTransaction_sign(this_arg, encodeArray(funding_key), encodeArray(funding_redeemscript), channel_value_satoshis); + return decodeArray(nativeResponseValue); + } // void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); export function CommitmentTransaction_free(this_obj: number): void { if(!isWasmInitialized) { @@ -13921,6 +14753,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.InitFeatures_known(); return nativeResponseValue; } + // MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); + export function InitFeatures_requires_unknown_bits(this_arg: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InitFeatures_requires_unknown_bits(this_arg); + return nativeResponseValue; + } // MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); export function NodeFeatures_empty(): number { if(!isWasmInitialized) { @@ -13937,6 +14777,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NodeFeatures_known(); return nativeResponseValue; } + // MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); + export function NodeFeatures_requires_unknown_bits(this_arg: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NodeFeatures_requires_unknown_bits(this_arg); + return nativeResponseValue; + } // MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); export function ChannelFeatures_empty(): number { if(!isWasmInitialized) { @@ -13953,6 +14801,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_known(); return nativeResponseValue; } + // MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); + export function ChannelFeatures_requires_unknown_bits(this_arg: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelFeatures_requires_unknown_bits(this_arg); + return nativeResponseValue; + } // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); export function InvoiceFeatures_empty(): number { if(!isWasmInitialized) { @@ -13969,6 +14825,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.InvoiceFeatures_known(); return nativeResponseValue; } + // MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + export function InvoiceFeatures_requires_unknown_bits(this_arg: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_requires_unknown_bits(this_arg); + return nativeResponseValue; + } // MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); export function InitFeatures_supports_payment_secret(this_arg: number): boolean { if(!isWasmInitialized) { @@ -14185,6 +15049,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ShutdownScript_is_compatible(this_arg, features); return nativeResponseValue; } + // void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); + export function CustomMessageReader_free(this_ptr: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CustomMessageReader_free(this_ptr); + // debug statements here + } + // struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); + export function Type_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Type_clone(orig); + return nativeResponseValue; + } + // void Type_free(struct LDKType this_ptr); + export function Type_free(this_ptr: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Type_free(this_ptr); + // debug statements here + } // void RouteHop_free(struct LDKRouteHop this_obj); export function RouteHop_free(this_obj: number): void { if(!isWasmInitialized) { @@ -14289,20 +15177,36 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RouteHop_set_cltv_expiry_delta(this_ptr, val); // debug statements here } - // MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); - export function RouteHop_new(pubkey_arg: Uint8Array, node_features_arg: number, short_channel_id_arg: number, channel_features_arg: number, fee_msat_arg: number, cltv_expiry_delta_arg: number): number { + // MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); + export function RouteHop_new(pubkey_arg: Uint8Array, node_features_arg: number, short_channel_id_arg: number, channel_features_arg: number, fee_msat_arg: number, cltv_expiry_delta_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.RouteHop_new(encodeArray(pubkey_arg), node_features_arg, short_channel_id_arg, channel_features_arg, fee_msat_arg, cltv_expiry_delta_arg); + return nativeResponseValue; + } + // struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); + export function RouteHop_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.RouteHop_clone(orig); + return nativeResponseValue; + } + // uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); + export function RouteHop_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHop_new(encodeArray(pubkey_arg), node_features_arg, short_channel_id_arg, channel_features_arg, fee_msat_arg, cltv_expiry_delta_arg); + const nativeResponseValue = wasm.RouteHop_hash(o); return nativeResponseValue; } - // struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); - export function RouteHop_clone(orig: number): number { + // bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); + export function RouteHop_eq(a: number, b: number): boolean { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHop_clone(orig); + const nativeResponseValue = wasm.RouteHop_eq(a, b); return nativeResponseValue; } // struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); @@ -14329,6 +15233,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Route_free(this_obj); // debug statements here } + // struct LDKCVec_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); + export function Route_get_paths(this_ptr: number): number[][] { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Route_get_paths(this_ptr); + return nativeResponseValue; + } // void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); export function Route_set_paths(this_ptr: number, val: number[][]): void { if(!isWasmInitialized) { @@ -14353,6 +15265,38 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Route_clone(orig); return nativeResponseValue; } + // uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); + export function Route_hash(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Route_hash(o); + return nativeResponseValue; + } + // bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); + export function Route_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Route_eq(a, b); + return nativeResponseValue; + } + // MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); + export function Route_get_total_fees(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Route_get_total_fees(this_arg); + return nativeResponseValue; + } + // MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); + export function Route_get_total_amount(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Route_get_total_amount(this_arg); + return nativeResponseValue; + } // struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); export function Route_write(obj: number): Uint8Array { if(!isWasmInitialized) { @@ -14377,20 +15321,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RouteHint_free(this_obj); // debug statements here } - // bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); - export function RouteHint_eq(a: number, b: number): boolean { + // struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); + export function RouteHint_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHint_eq(a, b); + const nativeResponseValue = wasm.RouteHint_clone(orig); return nativeResponseValue; } - // struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); - export function RouteHint_clone(orig: number): number { + // uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); + export function RouteHint_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHint_clone(orig); + const nativeResponseValue = wasm.RouteHint_hash(o); + return nativeResponseValue; + } + // bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); + export function RouteHint_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.RouteHint_eq(a, b); return nativeResponseValue; } // void RouteHintHop_free(struct LDKRouteHintHop this_obj); @@ -14505,20 +15457,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RouteHintHop_new(encodeArray(src_node_id_arg), short_channel_id_arg, fees_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg); return nativeResponseValue; } - // bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); - export function RouteHintHop_eq(a: number, b: number): boolean { + // struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); + export function RouteHintHop_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHintHop_eq(a, b); + const nativeResponseValue = wasm.RouteHintHop_clone(orig); return nativeResponseValue; } - // struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); - export function RouteHintHop_clone(orig: number): number { + // uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); + export function RouteHintHop_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.RouteHintHop_clone(orig); + const nativeResponseValue = wasm.RouteHintHop_hash(o); + return nativeResponseValue; + } + // bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); + export function RouteHintHop_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.RouteHintHop_eq(a, b); return nativeResponseValue; } // struct LDKCResult_RouteLightningErrorZ get_keysend_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); @@ -14545,70 +15505,110 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_free(this_obj); // debug statements here } - // struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); - export function NetworkGraph_clone(orig: number): number { + // void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); + export function ReadOnlyNetworkGraph_free(this_obj: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetworkGraph_clone(orig); - return nativeResponseValue; + const nativeResponseValue = wasm.ReadOnlyNetworkGraph_free(this_obj); + // debug statements here } - // void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj); - export function LockedNetworkGraph_free(this_obj: number): void { + // void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); + export function NetworkUpdate_free(this_ptr: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.LockedNetworkGraph_free(this_obj); + const nativeResponseValue = wasm.NetworkUpdate_free(this_ptr); // debug statements here } - // void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); - export function NetGraphMsgHandler_free(this_obj: number): void { + // struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); + export function NetworkUpdate_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetGraphMsgHandler_free(this_obj); - // debug statements here + const nativeResponseValue = wasm.NetworkUpdate_clone(orig); + return nativeResponseValue; } - // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger); - export function NetGraphMsgHandler_new(genesis_hash: Uint8Array, chain_access: number, logger: number): number { + // struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); + export function NetworkUpdate_channel_update_message(msg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetGraphMsgHandler_new(encodeArray(genesis_hash), chain_access, logger); + const nativeResponseValue = wasm.NetworkUpdate_channel_update_message(msg); return nativeResponseValue; } - // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph); - export function NetGraphMsgHandler_from_net_graph(chain_access: number, logger: number, network_graph: number): number { + // struct LDKNetworkUpdate NetworkUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent); + export function NetworkUpdate_channel_closed(short_channel_id: number, is_permanent: boolean): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetGraphMsgHandler_from_net_graph(chain_access, logger, network_graph); + const nativeResponseValue = wasm.NetworkUpdate_channel_closed(short_channel_id, is_permanent); return nativeResponseValue; } - // void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access); - export function NetGraphMsgHandler_add_chain_access(this_arg: number, chain_access: number): void { + // struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); + export function NetworkUpdate_node_failure(node_id: Uint8Array, is_permanent: boolean): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetGraphMsgHandler_add_chain_access(this_arg, chain_access); + const nativeResponseValue = wasm.NetworkUpdate_node_failure(encodeArray(node_id), is_permanent); + return nativeResponseValue; + } + // struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); + export function NetworkUpdate_write(obj: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetworkUpdate_write(obj); + return decodeArray(nativeResponseValue); + } + // struct LDKEventHandler NetGraphMsgHandler_as_EventHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); + export function NetGraphMsgHandler_as_EventHandler(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetGraphMsgHandler_as_EventHandler(this_arg); + return nativeResponseValue; + } + // void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); + export function NetGraphMsgHandler_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetGraphMsgHandler_free(this_obj); // debug statements here } - // MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); - export function NetGraphMsgHandler_read_locked_graph(this_arg: number): number { + // struct LDKNetworkGraph NetGraphMsgHandler_get_network_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr); + export function NetGraphMsgHandler_get_network_graph(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.NetGraphMsgHandler_read_locked_graph(this_arg); + const nativeResponseValue = wasm.NetGraphMsgHandler_get_network_graph(this_ptr); return nativeResponseValue; } - // MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg); - export function LockedNetworkGraph_graph(this_arg: number): number { + // void NetGraphMsgHandler_set_network_graph(struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr, struct LDKNetworkGraph val); + export function NetGraphMsgHandler_set_network_graph(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetGraphMsgHandler_set_network_graph(this_ptr, val); + // debug statements here + } + // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKNetworkGraph network_graph, struct LDKCOption_AccessZ chain_access, struct LDKLogger logger); + export function NetGraphMsgHandler_new(network_graph: number, chain_access: number, logger: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.LockedNetworkGraph_graph(this_arg); + const nativeResponseValue = wasm.NetGraphMsgHandler_new(network_graph, chain_access, logger); return nativeResponseValue; } + // void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKCOption_AccessZ chain_access); + export function NetGraphMsgHandler_add_chain_access(this_arg: number, chain_access: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetGraphMsgHandler_add_chain_access(this_arg, chain_access); + // debug statements here + } // struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); export function NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: number): number { if(!isWasmInitialized) { @@ -14993,6 +15993,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RoutingFees_clone(orig); return nativeResponseValue; } + // uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); + export function RoutingFees_hash(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.RoutingFees_hash(o); + return nativeResponseValue; + } // struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); export function RoutingFees_write(obj: number): Uint8Array { if(!isWasmInitialized) { @@ -15241,7 +16249,15 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_new(encodeArray(genesis_hash)); return nativeResponseValue; } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + // MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); + export function NetworkGraph_read_only(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetworkGraph_read_only(this_arg); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); export function NetworkGraph_update_node_from_announcement(this_arg: number, msg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15249,7 +16265,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_update_node_from_announcement(this_arg, msg); return nativeResponseValue; } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); export function NetworkGraph_update_node_from_unsigned_announcement(this_arg: number, msg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15257,7 +16273,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_update_node_from_unsigned_announcement(this_arg, msg); return nativeResponseValue; } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_AccessZ chain_access); export function NetworkGraph_update_channel_from_announcement(this_arg: number, msg: number, chain_access: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15265,7 +16281,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_update_channel_from_announcement(this_arg, msg, chain_access); return nativeResponseValue; } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_AccessZ chain_access); export function NetworkGraph_update_channel_from_unsigned_announcement(this_arg: number, msg: number, chain_access: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15273,7 +16289,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_update_channel_from_unsigned_announcement(this_arg, msg, chain_access); return nativeResponseValue; } - // void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); + // void NetworkGraph_close_channel_from_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); export function NetworkGraph_close_channel_from_update(this_arg: number, short_channel_id: number, is_permanent: boolean): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15281,7 +16297,15 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_close_channel_from_update(this_arg, short_channel_id, is_permanent); // debug statements here } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + // void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent); + export function NetworkGraph_fail_node(this_arg: number, _node_id: Uint8Array, is_permanent: boolean): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.NetworkGraph_fail_node(this_arg, encodeArray(_node_id), is_permanent); + // debug statements here + } + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); export function NetworkGraph_update_channel(this_arg: number, msg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15289,7 +16313,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.NetworkGraph_update_channel(this_arg, msg); return nativeResponseValue; } - // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); + // MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); export function NetworkGraph_update_channel_unsigned(this_arg: number, msg: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -15361,12 +16385,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelManagerPersister_free(this_ptr); // debug statements here } - // MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); - export function BackgroundProcessor_start(persister: number, event_handler: number, chain_monitor: number, channel_manager: number, peer_manager: number, logger: number): number { + // MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); + export function BackgroundProcessor_start(persister: number, event_handler: number, chain_monitor: number, channel_manager: number, net_graph_msg_handler: number, peer_manager: number, logger: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BackgroundProcessor_start(persister, event_handler, chain_monitor, channel_manager, peer_manager, logger); + const nativeResponseValue = wasm.BackgroundProcessor_start(persister, event_handler, chain_monitor, channel_manager, net_graph_msg_handler, peer_manager, logger); return nativeResponseValue; } // MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg); @@ -15649,6 +16673,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Currency_signet(); return nativeResponseValue; } + // uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o); + export function Currency_hash(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Currency_hash(o); + return nativeResponseValue; + } // bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *NONNULL_PTR b); export function Currency_eq(a: number, b: number): boolean { if(!isWasmInitialized) { @@ -15665,20 +16697,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Sha256_free(this_obj); // debug statements here } - // bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); - export function Sha256_eq(a: number, b: number): boolean { + // struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); + export function Sha256_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.Sha256_eq(a, b); + const nativeResponseValue = wasm.Sha256_clone(orig); return nativeResponseValue; } - // struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); - export function Sha256_clone(orig: number): number { + // uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); + export function Sha256_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.Sha256_clone(orig); + const nativeResponseValue = wasm.Sha256_hash(o); + return nativeResponseValue; + } + // bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); + export function Sha256_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Sha256_eq(a, b); return nativeResponseValue; } // void Description_free(struct LDKDescription this_obj); @@ -15689,20 +16729,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Description_free(this_obj); // debug statements here } - // bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); - export function Description_eq(a: number, b: number): boolean { + // struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); + export function Description_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.Description_eq(a, b); + const nativeResponseValue = wasm.Description_clone(orig); return nativeResponseValue; } - // struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); - export function Description_clone(orig: number): number { + // uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o); + export function Description_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.Description_clone(orig); + const nativeResponseValue = wasm.Description_hash(o); + return nativeResponseValue; + } + // bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b); + export function Description_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Description_eq(a, b); return nativeResponseValue; } // void PayeePubKey_free(struct LDKPayeePubKey this_obj); @@ -15713,20 +16761,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.PayeePubKey_free(this_obj); // debug statements here } - // bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); - export function PayeePubKey_eq(a: number, b: number): boolean { + // struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); + export function PayeePubKey_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PayeePubKey_eq(a, b); + const nativeResponseValue = wasm.PayeePubKey_clone(orig); return nativeResponseValue; } - // struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); - export function PayeePubKey_clone(orig: number): number { + // uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o); + export function PayeePubKey_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PayeePubKey_clone(orig); + const nativeResponseValue = wasm.PayeePubKey_hash(o); + return nativeResponseValue; + } + // bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b); + export function PayeePubKey_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.PayeePubKey_eq(a, b); return nativeResponseValue; } // void ExpiryTime_free(struct LDKExpiryTime this_obj); @@ -15737,20 +16793,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ExpiryTime_free(this_obj); // debug statements here } - // bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); - export function ExpiryTime_eq(a: number, b: number): boolean { + // struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); + export function ExpiryTime_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ExpiryTime_eq(a, b); + const nativeResponseValue = wasm.ExpiryTime_clone(orig); return nativeResponseValue; } - // struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); - export function ExpiryTime_clone(orig: number): number { + // uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o); + export function ExpiryTime_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ExpiryTime_clone(orig); + const nativeResponseValue = wasm.ExpiryTime_hash(o); + return nativeResponseValue; + } + // bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b); + export function ExpiryTime_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ExpiryTime_eq(a, b); return nativeResponseValue; } // void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj); @@ -15761,20 +16825,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.MinFinalCltvExpiry_free(this_obj); // debug statements here } - // bool MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b); - export function MinFinalCltvExpiry_eq(a: number, b: number): boolean { + // struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig); + export function MinFinalCltvExpiry_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.MinFinalCltvExpiry_eq(a, b); + const nativeResponseValue = wasm.MinFinalCltvExpiry_clone(orig); return nativeResponseValue; } - // struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig); - export function MinFinalCltvExpiry_clone(orig: number): number { + // uint64_t MinFinalCltvExpiry_hash(const struct LDKMinFinalCltvExpiry *NONNULL_PTR o); + export function MinFinalCltvExpiry_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.MinFinalCltvExpiry_clone(orig); + const nativeResponseValue = wasm.MinFinalCltvExpiry_hash(o); + return nativeResponseValue; + } + // bool MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b); + export function MinFinalCltvExpiry_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.MinFinalCltvExpiry_eq(a, b); return nativeResponseValue; } // void Fallback_free(struct LDKFallback this_ptr); @@ -15817,6 +16889,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.Fallback_script_hash(encodeArray(a)); return nativeResponseValue; } + // uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); + export function Fallback_hash(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.Fallback_hash(o); + return nativeResponseValue; + } // bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b); export function Fallback_eq(a: number, b: number): boolean { if(!isWasmInitialized) { @@ -15833,20 +16913,20 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.InvoiceSignature_free(this_obj); // debug statements here } - // bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b); - export function InvoiceSignature_eq(a: number, b: number): boolean { + // struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); + export function InvoiceSignature_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.InvoiceSignature_eq(a, b); + const nativeResponseValue = wasm.InvoiceSignature_clone(orig); return nativeResponseValue; } - // struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); - export function InvoiceSignature_clone(orig: number): number { + // bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b); + export function InvoiceSignature_eq(a: number, b: number): boolean { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.InvoiceSignature_clone(orig); + const nativeResponseValue = wasm.InvoiceSignature_eq(a, b); return nativeResponseValue; } // void PrivateRoute_free(struct LDKPrivateRoute this_obj); @@ -15857,20 +16937,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.PrivateRoute_free(this_obj); // debug statements here } - // bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); - export function PrivateRoute_eq(a: number, b: number): boolean { + // struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); + export function PrivateRoute_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PrivateRoute_eq(a, b); + const nativeResponseValue = wasm.PrivateRoute_clone(orig); return nativeResponseValue; } - // struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); - export function PrivateRoute_clone(orig: number): number { + // uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); + export function PrivateRoute_hash(o: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PrivateRoute_clone(orig); + const nativeResponseValue = wasm.PrivateRoute_hash(o); + return nativeResponseValue; + } + // bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); + export function PrivateRoute_eq(a: number, b: number): boolean { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.PrivateRoute_eq(a, b); return nativeResponseValue; } // MUST_USE_RES struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ SignedRawInvoice_into_parts(struct LDKSignedRawInvoice this_arg); @@ -16329,6 +17417,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.SemanticError_multiple_descriptions(); return nativeResponseValue; } + // enum LDKSemanticError SemanticError_no_payment_secret(void); + export function SemanticError_no_payment_secret(): SemanticError { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.SemanticError_no_payment_secret(); + return nativeResponseValue; + } // enum LDKSemanticError SemanticError_multiple_payment_secrets(void); export function SemanticError_multiple_payment_secrets(): SemanticError { if(!isWasmInitialized) { @@ -16361,6 +17457,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.SemanticError_invalid_signature(); return nativeResponseValue; } + // enum LDKSemanticError SemanticError_imprecise_amount(void); + export function SemanticError_imprecise_amount(): SemanticError { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.SemanticError_imprecise_amount(); + return nativeResponseValue; + } // bool SemanticError_eq(const enum LDKSemanticError *NONNULL_PTR a, const enum LDKSemanticError *NONNULL_PTR b); export function SemanticError_eq(a: number, b: number): boolean { if(!isWasmInitialized) { diff --git a/ts/enums/SemanticError.ts b/ts/enums/SemanticError.ts index beb99a6d..a296463a 100644 --- a/ts/enums/SemanticError.ts +++ b/ts/enums/SemanticError.ts @@ -4,9 +4,11 @@ LDKSemanticError_MultiplePaymentHashes, LDKSemanticError_NoDescription, LDKSemanticError_MultipleDescriptions, + LDKSemanticError_NoPaymentSecret, LDKSemanticError_MultiplePaymentSecrets, LDKSemanticError_InvalidFeatures, LDKSemanticError_InvalidRecoveryId, LDKSemanticError_InvalidSignature, + LDKSemanticError_ImpreciseAmount, } diff --git a/ts/structs/BackgroundProcessor.ts b/ts/structs/BackgroundProcessor.ts index 232d7f4d..8f3ffdcb 100644 --- a/ts/structs/BackgroundProcessor.ts +++ b/ts/structs/BackgroundProcessor.ts @@ -18,14 +18,15 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.BackgroundProcessor_free(this.ptr); } } - public static BackgroundProcessor constructor_start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, PeerManager peer_manager, Logger logger) { - number ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr); + public static BackgroundProcessor constructor_start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, NetGraphMsgHandler net_graph_msg_handler, PeerManager peer_manager, Logger logger) { + number ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, net_graph_msg_handler == null ? 0 : net_graph_msg_handler.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr); const ret_hu_conv: BackgroundProcessor = new BackgroundProcessor(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(persister); ret_hu_conv.ptrs_to.add(event_handler); ret_hu_conv.ptrs_to.add(chain_monitor); ret_hu_conv.ptrs_to.add(channel_manager); + ret_hu_conv.ptrs_to.add(net_graph_msg_handler); ret_hu_conv.ptrs_to.add(peer_manager); ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; diff --git a/ts/structs/Balance.ts b/ts/structs/Balance.ts new file mode 100644 index 00000000..c672712b --- /dev/null +++ b/ts/structs/Balance.ts @@ -0,0 +1,104 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class Balance extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.Balance_free(this.ptr); } + } + static constr_from_ptr(ptr: number): Balance { + const raw_val: bindings.LDKBalance = bindings.LDKBalance_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKBalance.ClaimableOnChannelClose) { + return new ClaimableOnChannelClose(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKBalance.ClaimableAwaitingConfirmations) { + return new ClaimableAwaitingConfirmations(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKBalance.ContentiousClaimable) { + return new ContentiousClaimable(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout) { + return new MaybeClaimableHTLCAwaitingTimeout(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class ClaimableOnChannelClose extends Balance { + public claimable_amount_satoshis: number; + private constructor(ptr: number, obj: bindings.LDKBalance.ClaimableOnChannelClose) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + } +} +export class ClaimableAwaitingConfirmations extends Balance { + public claimable_amount_satoshis: number; + public confirmation_height: number; + private constructor(ptr: number, obj: bindings.LDKBalance.ClaimableAwaitingConfirmations) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.confirmation_height = obj.confirmation_height; + } +} +export class ContentiousClaimable extends Balance { + public claimable_amount_satoshis: number; + public timeout_height: number; + private constructor(ptr: number, obj: bindings.LDKBalance.ContentiousClaimable) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.timeout_height = obj.timeout_height; + } +} +export class MaybeClaimableHTLCAwaitingTimeout extends Balance { + public claimable_amount_satoshis: number; + public claimable_height: number; + private constructor(ptr: number, obj: bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout) { + super(null, ptr); + this.claimable_amount_satoshis = obj.claimable_amount_satoshis; + this.claimable_height = obj.claimable_height; + } +} + public Balance clone() { + number ret = bindings.Balance_clone(this.ptr); + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public static Balance constructor_claimable_on_channel_close(number claimable_amount_satoshis) { + number ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis); + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Balance constructor_claimable_awaiting_confirmations(number claimable_amount_satoshis, number confirmation_height) { + number ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Balance constructor_contentious_claimable(number claimable_amount_satoshis, number timeout_height) { + number ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Balance constructor_maybe_claimable_htlcawaiting_timeout(number claimable_amount_satoshis, number claimable_height) { + number ret = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height); + Balance ret_hu_conv = Balance.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public boolean eq(Balance b) { + boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + +} diff --git a/ts/structs/BaseSign.ts b/ts/structs/BaseSign.ts index 4977383a..3cfce2c1 100644 --- a/ts/structs/BaseSign.ts +++ b/ts/structs/BaseSign.ts @@ -43,6 +43,13 @@ import * as bindings from '../bindings' // TODO: figure out location return ret; }, + validate_holder_commitment (holder_tx: number): number { + const holder_tx_hu_conv: HolderCommitmentTransaction = new HolderCommitmentTransaction(null, holder_tx); + Result_NoneNoneZ ret = arg.validate_holder_commitment(holder_tx_hu_conv); + result: number = ret != null ? ret.ptr : 0; + return result; + }, + channel_keys_id (): Uint8Array { Uint8Array ret = arg.channel_keys_id(); return ret; @@ -55,6 +62,12 @@ import * as bindings from '../bindings' // TODO: figure out location return result; }, + validate_counterparty_revocation (idx: number, secret: Uint8Array): number { + Result_NoneNoneZ ret = arg.validate_counterparty_revocation(idx, secret); + result: number = ret != null ? ret.ptr : 0; + return result; + }, + sign_holder_commitment_and_htlcs (commitment_tx: number): number { const commitment_tx_hu_conv: HolderCommitmentTransaction = new HolderCommitmentTransaction(null, commitment_tx); Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv); @@ -82,8 +95,9 @@ import * as bindings from '../bindings' // TODO: figure out location return result; }, - sign_closing_transaction (closing_tx: Uint8Array): number { - Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx); + sign_closing_transaction (closing_tx: number): number { + const closing_tx_hu_conv: ClosingTransaction = new ClosingTransaction(null, closing_tx); + Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv); result: number = ret != null ? ret.ptr : 0; return result; }, @@ -109,13 +123,15 @@ import * as bindings from '../bindings' // TODO: figure out location export interface BaseSignInterface { get_per_commitment_point(idx: number): Uint8Array; release_commitment_secret(idx: number): Uint8Array; + validate_holder_commitment(holder_tx: HolderCommitmentTransaction): Result_NoneNoneZ; channel_keys_id(): Uint8Array; sign_counterparty_commitment(commitment_tx: CommitmentTransaction): Result_C2Tuple_SignatureCVec_SignatureZZNoneZ; + validate_counterparty_revocation(idx: number, secret: Uint8Array): Result_NoneNoneZ; sign_holder_commitment_and_htlcs(commitment_tx: HolderCommitmentTransaction): Result_C2Tuple_SignatureCVec_SignatureZZNoneZ; sign_justice_revoked_output(justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array): Result_SignatureNoneZ; sign_justice_revoked_htlc(justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array, htlc: HTLCOutputInCommitment): Result_SignatureNoneZ; sign_counterparty_htlc_transaction(htlc_tx: Uint8Array, input: number, amount: number, per_commitment_point: Uint8Array, htlc: HTLCOutputInCommitment): Result_SignatureNoneZ; - sign_closing_transaction(closing_tx: Uint8Array): Result_SignatureNoneZ; + sign_closing_transaction(closing_tx: ClosingTransaction): Result_SignatureNoneZ; sign_channel_announcement(msg: UnsignedChannelAnnouncement): Result_SignatureNoneZ; ready_channel(channel_parameters: ChannelTransactionParameters): void; @@ -134,6 +150,13 @@ import * as bindings from '../bindings' // TODO: figure out location return ret; } + public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx) { + number ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr & ~1); + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(holder_tx); + return ret_hu_conv; + } + public Uint8Array channel_keys_id() { Uint8Array ret = bindings.BaseSign_channel_keys_id(this.ptr); return ret; @@ -146,6 +169,12 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public Result_NoneNoneZ validate_counterparty_revocation(number idx, Uint8Array secret) { + number ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, secret); + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) { number ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1); Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret); @@ -173,9 +202,10 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } - public Result_SignatureNoneZ sign_closing_transaction(Uint8Array closing_tx) { - number ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx); + public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) { + number ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr & ~1); Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(closing_tx); return ret_hu_conv; } diff --git a/ts/structs/ChainMonitor.ts b/ts/structs/ChainMonitor.ts index 9f09f914..4c1c9ef9 100644 --- a/ts/structs/ChainMonitor.ts +++ b/ts/structs/ChainMonitor.ts @@ -18,11 +18,10 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChainMonitor_free(this.ptr); } } - public static ChainMonitor constructor_new(Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) { - number ret = bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr); + public static ChainMonitor constructor_new(Option_FilterZ chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) { + number ret = bindings.ChainMonitor_new(chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr); const ret_hu_conv: ChainMonitor = new ChainMonitor(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_source); ret_hu_conv.ptrs_to.add(broadcaster); ret_hu_conv.ptrs_to.add(logger); ret_hu_conv.ptrs_to.add(feeest); @@ -30,6 +29,19 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public Balance[] get_claimable_balances(ChannelDetails[] ignored_channels) { + number[] ret = bindings.ChainMonitor_get_claimable_balances(this.ptr, ignored_channels != null ? Arrays.stream(ignored_channels).map(ignored_channels_conv_16 -> ignored_channels_conv_16 == null ? 0 : ignored_channels_conv_16.ptr & ~1).toArray(number[]::new) : null); + Balance[] ret_conv_9_arr = new Balance[ret.length]; + for (int j = 0; j < ret.length; j++) { + number ret_conv_9 = ret[j]; + Balance ret_conv_9_hu_conv = Balance.constr_from_ptr(ret_conv_9); + ret_conv_9_hu_conv.ptrs_to.add(this); + ret_conv_9_arr[j] = ret_conv_9_hu_conv; + } + for (ChannelDetails ignored_channels_conv_16: ignored_channels) { this.ptrs_to.add(ignored_channels_conv_16); }; + return ret_conv_9_arr; + } + public Listen as_Listen() { number ret = bindings.ChainMonitor_as_Listen(this.ptr); Listen ret_hu_conv = new Listen(null, ret); diff --git a/ts/structs/ChannelCounterparty.ts b/ts/structs/ChannelCounterparty.ts index 12911ef8..3c85908e 100644 --- a/ts/structs/ChannelCounterparty.ts +++ b/ts/structs/ChannelCounterparty.ts @@ -48,6 +48,27 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val); } + public CounterpartyForwardingInfo get_forwarding_info() { + number ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr); + const ret_hu_conv: CounterpartyForwardingInfo = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void set_forwarding_info(CounterpartyForwardingInfo val) { + bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + + public static ChannelCounterparty constructor_new(Uint8Array node_id_arg, InitFeatures features_arg, number unspendable_punishment_reserve_arg, CounterpartyForwardingInfo forwarding_info_arg) { + number ret = bindings.ChannelCounterparty_new(node_id_arg, features_arg == null ? 0 : features_arg.ptr & ~1, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr & ~1); + const ret_hu_conv: ChannelCounterparty = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(features_arg); + ret_hu_conv.ptrs_to.add(forwarding_info_arg); + return ret_hu_conv; + } + public ChannelCounterparty clone() { number ret = bindings.ChannelCounterparty_clone(this.ptr); const ret_hu_conv: ChannelCounterparty = new ChannelCounterparty(null, ret); diff --git a/ts/structs/ChannelFeatures.ts b/ts/structs/ChannelFeatures.ts index 1abee174..05694319 100644 --- a/ts/structs/ChannelFeatures.ts +++ b/ts/structs/ChannelFeatures.ts @@ -45,6 +45,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public boolean requires_unknown_bits() { + boolean ret = bindings.ChannelFeatures_requires_unknown_bits(this.ptr); + return ret; + } + public Uint8Array write() { Uint8Array ret = bindings.ChannelFeatures_write(this.ptr); return ret; diff --git a/ts/structs/ChannelManager.ts b/ts/structs/ChannelManager.ts index 6064707d..b8a04707 100644 --- a/ts/structs/ChannelManager.ts +++ b/ts/structs/ChannelManager.ts @@ -114,7 +114,6 @@ import * as bindings from '../bindings' // TODO: figure out location public void broadcast_node_announcement(Uint8Array rgb, Uint8Array alias, NetAddress[] addresses) { bindings.ChannelManager_broadcast_node_announcement(this.ptr, rgb, alias, addresses != null ? Arrays.stream(addresses).map(addresses_conv_12 -> addresses_conv_12.ptr).toArray(number[]::new) : null); - /* TODO 2 NetAddress */; } public void process_pending_htlc_forwards() { diff --git a/ts/structs/ChannelManagerReadArgs.ts b/ts/structs/ChannelManagerReadArgs.ts index 772c721e..b381eb4f 100644 --- a/ts/structs/ChannelManagerReadArgs.ts +++ b/ts/structs/ChannelManagerReadArgs.ts @@ -100,7 +100,7 @@ import * as bindings from '../bindings' // TODO: figure out location ret_hu_conv.ptrs_to.add(tx_broadcaster); ret_hu_conv.ptrs_to.add(logger); ret_hu_conv.ptrs_to.add(default_config); - /* TODO 2 ChannelMonitor */; + for (ChannelMonitor channel_monitors_conv_16: channel_monitors) { ret_hu_conv.ptrs_to.add(channel_monitors_conv_16); }; return ret_hu_conv; } diff --git a/ts/structs/ChannelMonitor.ts b/ts/structs/ChannelMonitor.ts index 2d3cac7c..19dced06 100644 --- a/ts/structs/ChannelMonitor.ts +++ b/ts/structs/ChannelMonitor.ts @@ -140,7 +140,6 @@ import * as bindings from '../bindings' // TODO: figure out location // Warning: We may not free the C tuple object! ret_conv_49_arr[x] = ret_conv_49_conv; } - /* TODO 2 TwoTuple */; this.ptrs_to.add(broadcaster); this.ptrs_to.add(fee_estimator); this.ptrs_to.add(logger); @@ -177,7 +176,6 @@ import * as bindings from '../bindings' // TODO: figure out location // Warning: We may not free the C tuple object! ret_conv_49_arr[x] = ret_conv_49_conv; } - /* TODO 2 TwoTuple */; this.ptrs_to.add(broadcaster); this.ptrs_to.add(fee_estimator); this.ptrs_to.add(logger); @@ -232,4 +230,16 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public Balance[] get_claimable_balances() { + number[] ret = bindings.ChannelMonitor_get_claimable_balances(this.ptr); + Balance[] ret_conv_9_arr = new Balance[ret.length]; + for (int j = 0; j < ret.length; j++) { + number ret_conv_9 = ret[j]; + Balance ret_conv_9_hu_conv = Balance.constr_from_ptr(ret_conv_9); + ret_conv_9_hu_conv.ptrs_to.add(this); + ret_conv_9_arr[j] = ret_conv_9_hu_conv; + } + return ret_conv_9_arr; + } + } diff --git a/ts/structs/ClosingTransaction.ts b/ts/structs/ClosingTransaction.ts new file mode 100644 index 00000000..e32307f1 --- /dev/null +++ b/ts/structs/ClosingTransaction.ts @@ -0,0 +1,63 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export default class ClosingTransaction extends CommonBase { + constructor(_dummy: object, ptr: number) { + super(ptr); + } + + + protected finalize() { + super.finalize(); + + if (this.ptr != 0) { + bindings.ClosingTransaction_free(this.ptr); + } + } + public static ClosingTransaction constructor_new(number to_holder_value_sat, number to_counterparty_value_sat, Uint8Array to_holder_script, Uint8Array to_counterparty_script, OutPoint funding_outpoint) { + number ret = bindings.ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1); + const ret_hu_conv: ClosingTransaction = new ClosingTransaction(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(funding_outpoint); + return ret_hu_conv; + } + + public TrustedClosingTransaction trust() { + number ret = bindings.ClosingTransaction_trust(this.ptr); + const ret_hu_conv: TrustedClosingTransaction = new TrustedClosingTransaction(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) { + number ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1); + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + this.ptrs_to.add(funding_outpoint); + return ret_hu_conv; + } + + public number to_holder_value_sat() { + number ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr); + return ret; + } + + public number to_counterparty_value_sat() { + number ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr); + return ret; + } + + public Uint8Array to_holder_script() { + Uint8Array ret = bindings.ClosingTransaction_to_holder_script(this.ptr); + return ret; + } + + public Uint8Array to_counterparty_script() { + Uint8Array ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr); + return ret; + } + +} diff --git a/ts/structs/ClosureReason.ts b/ts/structs/ClosureReason.ts new file mode 100644 index 00000000..bf2d6fc2 --- /dev/null +++ b/ts/structs/ClosureReason.ts @@ -0,0 +1,138 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class ClosureReason extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.ClosureReason_free(this.ptr); } + } + static constr_from_ptr(ptr: number): ClosureReason { + const raw_val: bindings.LDKClosureReason = bindings.LDKClosureReason_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKClosureReason.CounterpartyForceClosed) { + return new CounterpartyForceClosed(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.HolderForceClosed) { + return new HolderForceClosed(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.CooperativeClosure) { + return new CooperativeClosure(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.CommitmentTxConfirmed) { + return new CommitmentTxConfirmed(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.ProcessingError) { + return new ProcessingError(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.DisconnectedPeer) { + return new DisconnectedPeer(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKClosureReason.OutdatedChannelManager) { + return new OutdatedChannelManager(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class CounterpartyForceClosed extends ClosureReason { + public peer_msg: String; + private constructor(ptr: number, obj: bindings.LDKClosureReason.CounterpartyForceClosed) { + super(null, ptr); + this.peer_msg = obj.peer_msg; + } +} +export class HolderForceClosed extends ClosureReason { + private constructor(ptr: number, obj: bindings.LDKClosureReason.HolderForceClosed) { + super(null, ptr); + } +} +export class CooperativeClosure extends ClosureReason { + private constructor(ptr: number, obj: bindings.LDKClosureReason.CooperativeClosure) { + super(null, ptr); + } +} +export class CommitmentTxConfirmed extends ClosureReason { + private constructor(ptr: number, obj: bindings.LDKClosureReason.CommitmentTxConfirmed) { + super(null, ptr); + } +} +export class ProcessingError extends ClosureReason { + public err: String; + private constructor(ptr: number, obj: bindings.LDKClosureReason.ProcessingError) { + super(null, ptr); + this.err = obj.err; + } +} +export class DisconnectedPeer extends ClosureReason { + private constructor(ptr: number, obj: bindings.LDKClosureReason.DisconnectedPeer) { + super(null, ptr); + } +} +export class OutdatedChannelManager extends ClosureReason { + private constructor(ptr: number, obj: bindings.LDKClosureReason.OutdatedChannelManager) { + super(null, ptr); + } +} + public ClosureReason clone() { + number ret = bindings.ClosureReason_clone(this.ptr); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public static ClosureReason constructor_counterparty_force_closed(String peer_msg) { + number ret = bindings.ClosureReason_counterparty_force_closed(peer_msg); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_holder_force_closed() { + number ret = bindings.ClosureReason_holder_force_closed(); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_cooperative_closure() { + number ret = bindings.ClosureReason_cooperative_closure(); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_commitment_tx_confirmed() { + number ret = bindings.ClosureReason_commitment_tx_confirmed(); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_processing_error(String err) { + number ret = bindings.ClosureReason_processing_error(err); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_disconnected_peer() { + number ret = bindings.ClosureReason_disconnected_peer(); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static ClosureReason constructor_outdated_channel_manager() { + number ret = bindings.ClosureReason_outdated_channel_manager(); + ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public Uint8Array write() { + Uint8Array ret = bindings.ClosureReason_write(this.ptr); + return ret; + } + +} diff --git a/ts/structs/CommitmentUpdate.ts b/ts/structs/CommitmentUpdate.ts index 9117bc23..2c1f0e65 100644 --- a/ts/structs/CommitmentUpdate.ts +++ b/ts/structs/CommitmentUpdate.ts @@ -18,24 +18,72 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.CommitmentUpdate_free(this.ptr); } } + public UpdateAddHTLC[] get_update_add_htlcs() { + number[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr); + UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret.length]; + for (int p = 0; p < ret.length; p++) { + number ret_conv_15 = ret[p]; + const ret_conv_15_hu_conv: UpdateAddHTLC = new UpdateAddHTLC(null, ret_conv_15); + ret_conv_15_hu_conv.ptrs_to.add(this); + ret_conv_15_arr[p] = ret_conv_15_hu_conv; + } + return ret_conv_15_arr; + } + public void set_update_add_htlcs(UpdateAddHTLC[] val) { bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, val != null ? Arrays.stream(val).map(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray(number[]::new) : null); - /* TODO 2 UpdateAddHTLC */; + for (UpdateAddHTLC val_conv_15: val) { this.ptrs_to.add(val_conv_15); }; + } + + public UpdateFulfillHTLC[] get_update_fulfill_htlcs() { + number[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr); + UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret.length]; + for (int t = 0; t < ret.length; t++) { + number ret_conv_19 = ret[t]; + const ret_conv_19_hu_conv: UpdateFulfillHTLC = new UpdateFulfillHTLC(null, ret_conv_19); + ret_conv_19_hu_conv.ptrs_to.add(this); + ret_conv_19_arr[t] = ret_conv_19_hu_conv; + } + return ret_conv_19_arr; } public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) { bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, val != null ? Arrays.stream(val).map(val_conv_19 -> val_conv_19 == null ? 0 : val_conv_19.ptr & ~1).toArray(number[]::new) : null); - /* TODO 2 UpdateFulfillHTLC */; + for (UpdateFulfillHTLC val_conv_19: val) { this.ptrs_to.add(val_conv_19); }; + } + + public UpdateFailHTLC[] get_update_fail_htlcs() { + number[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr); + UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret.length]; + for (int q = 0; q < ret.length; q++) { + number ret_conv_16 = ret[q]; + const ret_conv_16_hu_conv: UpdateFailHTLC = new UpdateFailHTLC(null, ret_conv_16); + ret_conv_16_hu_conv.ptrs_to.add(this); + ret_conv_16_arr[q] = ret_conv_16_hu_conv; + } + return ret_conv_16_arr; } public void set_update_fail_htlcs(UpdateFailHTLC[] val) { bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, val != null ? Arrays.stream(val).map(val_conv_16 -> val_conv_16 == null ? 0 : val_conv_16.ptr & ~1).toArray(number[]::new) : null); - /* TODO 2 UpdateFailHTLC */; + for (UpdateFailHTLC val_conv_16: val) { this.ptrs_to.add(val_conv_16); }; + } + + public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() { + number[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr); + UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret.length]; + for (int z = 0; z < ret.length; z++) { + number ret_conv_25 = ret[z]; + const ret_conv_25_hu_conv: UpdateFailMalformedHTLC = new UpdateFailMalformedHTLC(null, ret_conv_25); + ret_conv_25_hu_conv.ptrs_to.add(this); + ret_conv_25_arr[z] = ret_conv_25_hu_conv; + } + return ret_conv_25_arr; } public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) { bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, val != null ? Arrays.stream(val).map(val_conv_25 -> val_conv_25 == null ? 0 : val_conv_25.ptr & ~1).toArray(number[]::new) : null); - /* TODO 2 UpdateFailMalformedHTLC */; + for (UpdateFailMalformedHTLC val_conv_25: val) { this.ptrs_to.add(val_conv_25); }; } public UpdateFee get_update_fee() { @@ -66,10 +114,10 @@ import * as bindings from '../bindings' // TODO: figure out location number ret = bindings.CommitmentUpdate_new(update_add_htlcs_arg != null ? Arrays.stream(update_add_htlcs_arg).map(update_add_htlcs_arg_conv_15 -> update_add_htlcs_arg_conv_15 == null ? 0 : update_add_htlcs_arg_conv_15.ptr & ~1).toArray(number[]::new) : null, update_fulfill_htlcs_arg != null ? Arrays.stream(update_fulfill_htlcs_arg).map(update_fulfill_htlcs_arg_conv_19 -> update_fulfill_htlcs_arg_conv_19 == null ? 0 : update_fulfill_htlcs_arg_conv_19.ptr & ~1).toArray(number[]::new) : null, update_fail_htlcs_arg != null ? Arrays.stream(update_fail_htlcs_arg).map(update_fail_htlcs_arg_conv_16 -> update_fail_htlcs_arg_conv_16 == null ? 0 : update_fail_htlcs_arg_conv_16.ptr & ~1).toArray(number[]::new) : null, update_fail_malformed_htlcs_arg != null ? Arrays.stream(update_fail_malformed_htlcs_arg).map(update_fail_malformed_htlcs_arg_conv_25 -> update_fail_malformed_htlcs_arg_conv_25 == null ? 0 : update_fail_malformed_htlcs_arg_conv_25.ptr & ~1).toArray(number[]::new) : null, update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1); const ret_hu_conv: CommitmentUpdate = new CommitmentUpdate(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 UpdateAddHTLC */; - /* TODO 2 UpdateFulfillHTLC */; - /* TODO 2 UpdateFailHTLC */; - /* TODO 2 UpdateFailMalformedHTLC */; + for (UpdateAddHTLC update_add_htlcs_arg_conv_15: update_add_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_add_htlcs_arg_conv_15); }; + for (UpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19: update_fulfill_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fulfill_htlcs_arg_conv_19); }; + for (UpdateFailHTLC update_fail_htlcs_arg_conv_16: update_fail_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_htlcs_arg_conv_16); }; + for (UpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25: update_fail_malformed_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_malformed_htlcs_arg_conv_25); }; ret_hu_conv.ptrs_to.add(update_fee_arg); ret_hu_conv.ptrs_to.add(commitment_signed_arg); return ret_hu_conv; diff --git a/ts/structs/Confirm.ts b/ts/structs/Confirm.ts index ce8f5083..409068bf 100644 --- a/ts/structs/Confirm.ts +++ b/ts/structs/Confirm.ts @@ -78,7 +78,6 @@ import * as bindings from '../bindings' // TODO: figure out location } public void transactions_confirmed(Uint8Array header, TwoTuple[] txdata, number height) { bindings.Confirm_transactions_confirmed(this.ptr, header, txdata != null ? Arrays.stream(txdata).map(txdata_conv_30 -> bindings.C2Tuple_usizeTransactionZ_new(txdata_conv_30.a, txdata_conv_30.b)).toArray(number[]::new) : null, height); - /* TODO 2 TwoTuple */; } public void transaction_unconfirmed(Uint8Array txid) { diff --git a/ts/structs/CounterpartyForwardingInfo.ts b/ts/structs/CounterpartyForwardingInfo.ts new file mode 100644 index 00000000..ec452c4c --- /dev/null +++ b/ts/structs/CounterpartyForwardingInfo.ts @@ -0,0 +1,62 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export default class CounterpartyForwardingInfo extends CommonBase { + constructor(_dummy: object, ptr: number) { + super(ptr); + } + + + protected finalize() { + super.finalize(); + + if (this.ptr != 0) { + bindings.CounterpartyForwardingInfo_free(this.ptr); + } + } + public number get_fee_base_msat() { + number ret = bindings.CounterpartyForwardingInfo_get_fee_base_msat(this.ptr); + return ret; + } + + public void set_fee_base_msat(number val) { + bindings.CounterpartyForwardingInfo_set_fee_base_msat(this.ptr, val); + } + + public number get_fee_proportional_millionths() { + number ret = bindings.CounterpartyForwardingInfo_get_fee_proportional_millionths(this.ptr); + return ret; + } + + public void set_fee_proportional_millionths(number val) { + bindings.CounterpartyForwardingInfo_set_fee_proportional_millionths(this.ptr, val); + } + + public number get_cltv_expiry_delta() { + number ret = bindings.CounterpartyForwardingInfo_get_cltv_expiry_delta(this.ptr); + return ret; + } + + public void set_cltv_expiry_delta(number val) { + bindings.CounterpartyForwardingInfo_set_cltv_expiry_delta(this.ptr, val); + } + + public static CounterpartyForwardingInfo constructor_new(number fee_base_msat_arg, number fee_proportional_millionths_arg, number cltv_expiry_delta_arg) { + number ret = bindings.CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg); + const ret_hu_conv: CounterpartyForwardingInfo = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public CounterpartyForwardingInfo clone() { + number ret = bindings.CounterpartyForwardingInfo_clone(this.ptr); + const ret_hu_conv: CounterpartyForwardingInfo = new CounterpartyForwardingInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/CustomMessageHandler.ts b/ts/structs/CustomMessageHandler.ts new file mode 100644 index 00000000..a1efb558 --- /dev/null +++ b/ts/structs/CustomMessageHandler.ts @@ -0,0 +1,91 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export class CustomMessageHandler extends CommonBase { + + bindings_instance?: bindings.LDKCustomMessageHandler; + + constructor(ptr?: number, arg?: bindings.LDKCustomMessageHandler, customMessageReader?: bindings.LDKCustomMessageReader) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKCustomMessageHandler_new(arg, customMessageReader)); + this.ptrs_to.push(arg); + this.ptrs_to.push(customMessageReader); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.CustomMessageHandler_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: CustomMessageHandlerInterface, customMessageReader_impl: CustomMessageReader.CustomMessageReaderInterface): CustomMessageHandler { + const impl_holder: LDKCustomMessageHandlerHolder = new LDKCustomMessageHandlerHolder(); + let structImplementation = { + // todo: in-line interface filling + handle_custom_message (msg: number, sender_node_id: Uint8Array): number { + Type ret_hu_conv = new Type(null, msg); + ret_hu_conv.ptrs_to.add(this); + Result_NoneLightningErrorZ ret = arg.handle_custom_message(ret_hu_conv, sender_node_id); + result: number = ret != null ? ret.ptr : 0; + return result; + }, + + get_and_clear_pending_msg (): number[] { + TwoTuple[] ret = arg.get_and_clear_pending_msg(); + result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_28 -> bindings.C2Tuple_PublicKeyTypeZ_new(ret_conv_28.a, ret_conv_28.b == null ? 0 : ret_conv_28.b.ptr)).toArray(number[]::new) : null; + for (TwoTuple ret_conv_28: ret) { impl_holder.held.ptrs_to.add(ret_conv_28.b); }; + return result; + }, + + + }; + impl_holder.held = new CustomMessageHandler (null, structImplementation, CustomMessageReader.new_impl(CustomMessageReader_impl).bindings_instance); + } + } + + export interface CustomMessageHandlerInterface { + handle_custom_message(msg: Type, sender_node_id: Uint8Array): Result_NoneLightningErrorZ; + get_and_clear_pending_msg(): TwoTuple[]; + + } + + class LDKCustomMessageHandlerHolder { + held: CustomMessageHandler; + } + public Result_NoneLightningErrorZ handle_custom_message(Type msg, Uint8Array sender_node_id) { + number ret = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg == null ? 0 : msg.ptr, sender_node_id); + Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); + this.ptrs_to.add(msg); + return ret_hu_conv; + } + + public TwoTuple[] get_and_clear_pending_msg() { + number[] ret = bindings.CustomMessageHandler_get_and_clear_pending_msg(this.ptr); + TwoTuple[] ret_conv_28_arr = new TwoTuple[ret.length]; + for (int c = 0; c < ret.length; c++) { + number ret_conv_28 = ret[c]; + Uint8Array ret_conv_28_a = bindings.LDKC2Tuple_PublicKeyTypeZ_get_a(ret_conv_28); + number ret_conv_28_b = bindings.LDKC2Tuple_PublicKeyTypeZ_get_b(ret_conv_28); + Type ret_hu_conv = new Type(null, ret_conv_28_b); + ret_hu_conv.ptrs_to.add(this);; + TwoTuple ret_conv_28_conv = new TwoTuple(ret_conv_28_a, ret_hu_conv, () -> { + bindings.C2Tuple_PublicKeyTypeZ_free(ret_conv_28); + }); + ret_hu_conv.ptrs_to.add(ret_conv_28_conv); + ret_conv_28_arr[c] = ret_conv_28_conv; + } + return ret_conv_28_arr; + } + +} diff --git a/ts/structs/CustomMessageReader.ts b/ts/structs/CustomMessageReader.ts new file mode 100644 index 00000000..e8fb7247 --- /dev/null +++ b/ts/structs/CustomMessageReader.ts @@ -0,0 +1,61 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export class CustomMessageReader extends CommonBase { + + bindings_instance?: bindings.LDKCustomMessageReader; + + constructor(ptr?: number, arg?: bindings.LDKCustomMessageReader) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKCustomMessageReader_new(arg)); + this.ptrs_to.push(arg); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.CustomMessageReader_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: CustomMessageReaderInterface): CustomMessageReader { + const impl_holder: LDKCustomMessageReaderHolder = new LDKCustomMessageReaderHolder(); + let structImplementation = { + // todo: in-line interface filling + read (message_type: number, buffer: Uint8Array): number { + Result_COption_TypeZDecodeErrorZ ret = arg.read(message_type, buffer); + result: number = ret != null ? ret.ptr : 0; + return result; + }, + + + }; + impl_holder.held = new CustomMessageReader (null, structImplementation); + } + } + + export interface CustomMessageReaderInterface { + read(message_type: number, buffer: Uint8Array): Result_COption_TypeZDecodeErrorZ; + + } + + class LDKCustomMessageReaderHolder { + held: CustomMessageReader; + } + public Result_COption_TypeZDecodeErrorZ read(number message_type, Uint8Array buffer) { + number ret = bindings.CustomMessageReader_read(this.ptr, message_type, buffer); + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Description.ts b/ts/structs/Description.ts index f13aa519..db55f33b 100644 --- a/ts/structs/Description.ts +++ b/ts/structs/Description.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.Description_free(this.ptr); } } - public boolean eq(Description b) { - boolean ret = bindings.Description_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public Description clone() { number ret = bindings.Description_clone(this.ptr); const ret_hu_conv: Description = new Description(null, ret); @@ -31,6 +25,17 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.Description_hash(this.ptr); + return ret; + } + + public boolean eq(Description b) { + boolean ret = bindings.Description_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + public static Result_DescriptionCreationErrorZ constructor_new(String description) { number ret = bindings.Description_new(description); Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/Event.ts b/ts/structs/Event.ts index ef27cde9..db05d8ae 100644 --- a/ts/structs/Event.ts +++ b/ts/structs/Event.ts @@ -19,8 +19,8 @@ export default class Event extends CommonBase { if (raw_val instanceof bindings.LDKEvent.PaymentSent) { return new PaymentSent(this.ptr, raw_val); } - if (raw_val instanceof bindings.LDKEvent.PaymentFailed) { - return new PaymentFailed(this.ptr, raw_val); + if (raw_val instanceof bindings.LDKEvent.PaymentPathFailed) { + return new PaymentPathFailed(this.ptr, raw_val); } if (raw_val instanceof bindings.LDKEvent.PendingHTLCsForwardable) { return new PendingHTLCsForwardable(this.ptr, raw_val); @@ -31,6 +31,9 @@ export default class Event extends CommonBase { if (raw_val instanceof bindings.LDKEvent.PaymentForwarded) { return new PaymentForwarded(this.ptr, raw_val); } + if (raw_val instanceof bindings.LDKEvent.ChannelClosed) { + return new ChannelClosed(this.ptr, raw_val); + } throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } @@ -69,13 +72,30 @@ export class PaymentSent extends Event { this.payment_preimage = obj.payment_preimage; } } -export class PaymentFailed extends Event { +export class PaymentPathFailed extends Event { public payment_hash: Uint8Array; public rejected_by_dest: boolean; - private constructor(ptr: number, obj: bindings.LDKEvent.PaymentFailed) { + public network_update: Option_NetworkUpdateZ; + public all_paths_failed: boolean; + public path: RouteHop[]; + private constructor(ptr: number, obj: bindings.LDKEvent.PaymentPathFailed) { super(null, ptr); this.payment_hash = obj.payment_hash; this.rejected_by_dest = obj.rejected_by_dest; + const network_update: number = obj.network_update; + Option_NetworkUpdateZ network_update_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(network_update); + network_update_hu_conv.ptrs_to.add(this); + this.network_update = network_update_hu_conv; + this.all_paths_failed = obj.all_paths_failed; + const path: number[] = obj.path; + RouteHop[] path_conv_10_arr = new RouteHop[path.length]; + for (int k = 0; k < path.length; k++) { + number path_conv_10 = path[k]; + const path_conv_10_hu_conv: RouteHop = new RouteHop(null, path_conv_10); + path_conv_10_hu_conv.ptrs_to.add(this); + path_conv_10_arr[k] = path_conv_10_hu_conv; + } + this.path = path_conv_10_arr; } } export class PendingHTLCsForwardable extends Event { @@ -111,6 +131,18 @@ export class PaymentForwarded extends Event { this.fee_earned_msat = fee_earned_msat_hu_conv; this.claim_from_onchain_tx = obj.claim_from_onchain_tx; } +} +export class ChannelClosed extends Event { + public channel_id: Uint8Array; + public reason: ClosureReason; + private constructor(ptr: number, obj: bindings.LDKEvent.ChannelClosed) { + super(null, ptr); + this.channel_id = obj.channel_id; + const reason: number = obj.reason; + ClosureReason reason_hu_conv = ClosureReason.constr_from_ptr(reason); + reason_hu_conv.ptrs_to.add(this); + this.reason = reason_hu_conv; + } } public Event clone() { number ret = bindings.Event_clone(this.ptr); @@ -140,10 +172,11 @@ export class PaymentForwarded extends Event { return ret_hu_conv; } - public static Event constructor_payment_failed(Uint8Array payment_hash, boolean rejected_by_dest) { - number ret = bindings.Event_payment_failed(payment_hash, rejected_by_dest); + public static Event constructor_payment_path_failed(Uint8Array payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path) { + number ret = bindings.Event_payment_path_failed(payment_hash, rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); + for (RouteHop path_conv_10: path) { ret_hu_conv.ptrs_to.add(path_conv_10); }; return ret_hu_conv; } @@ -158,7 +191,6 @@ export class PaymentForwarded extends Event { number ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).map(outputs_conv_27 -> outputs_conv_27.ptr).toArray(number[]::new) : null); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 SpendableOutputDescriptor */; return ret_hu_conv; } @@ -169,6 +201,13 @@ export class PaymentForwarded extends Event { return ret_hu_conv; } + public static Event constructor_channel_closed(Uint8Array channel_id, ClosureReason reason) { + number ret = bindings.Event_channel_closed(channel_id, reason.ptr); + Event ret_hu_conv = Event.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + public Uint8Array write() { Uint8Array ret = bindings.Event_write(this.ptr); return ret; diff --git a/ts/structs/EventHandler.ts b/ts/structs/EventHandler.ts index 1d7c9229..a9d0ee47 100644 --- a/ts/structs/EventHandler.ts +++ b/ts/structs/EventHandler.ts @@ -34,7 +34,6 @@ import * as bindings from '../bindings' // TODO: figure out location // todo: in-line interface filling handle_event (event: number): void { Event event_hu_conv = Event.constr_from_ptr(event); - event_hu_conv.ptrs_to.add(this); arg.handle_event(event_hu_conv); }, @@ -53,7 +52,8 @@ import * as bindings from '../bindings' // TODO: figure out location held: EventHandler; } public void handle_event(Event event) { - bindings.EventHandler_handle_event(this.ptr, event.ptr); + bindings.EventHandler_handle_event(this.ptr, event == null ? 0 : event.ptr & ~1); + this.ptrs_to.add(event); } } diff --git a/ts/structs/ExpiryTime.ts b/ts/structs/ExpiryTime.ts index 7ee0a413..90390158 100644 --- a/ts/structs/ExpiryTime.ts +++ b/ts/structs/ExpiryTime.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ExpiryTime_free(this.ptr); } } - public boolean eq(ExpiryTime b) { - boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public ExpiryTime clone() { number ret = bindings.ExpiryTime_clone(this.ptr); const ret_hu_conv: ExpiryTime = new ExpiryTime(null, ret); @@ -31,6 +25,17 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.ExpiryTime_hash(this.ptr); + return ret; + } + + public boolean eq(ExpiryTime b) { + boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + public static Result_ExpiryTimeCreationErrorZ constructor_from_seconds(number seconds) { number ret = bindings.ExpiryTime_from_seconds(seconds); Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/Fallback.ts b/ts/structs/Fallback.ts index 637597a3..54dca664 100644 --- a/ts/structs/Fallback.ts +++ b/ts/structs/Fallback.ts @@ -76,6 +76,11 @@ export class ScriptHash extends Fallback { return ret_hu_conv; } + public number hash() { + number ret = bindings.Fallback_hash(this.ptr); + return ret; + } + public boolean eq(Fallback b) { boolean ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr & ~1); this.ptrs_to.add(b); diff --git a/ts/structs/GossipTimestampFilter.ts b/ts/structs/GossipTimestampFilter.ts index a6557572..8ef06f40 100644 --- a/ts/structs/GossipTimestampFilter.ts +++ b/ts/structs/GossipTimestampFilter.ts @@ -59,15 +59,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public Uint8Array write() { + Uint8Array ret = bindings.GossipTimestampFilter_write(this.ptr); + return ret; + } + public static Result_GossipTimestampFilterDecodeErrorZ constructor_read(Uint8Array ser) { number ret = bindings.GossipTimestampFilter_read(ser); Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } - public Uint8Array write() { - Uint8Array ret = bindings.GossipTimestampFilter_write(this.ptr); - return ret; - } - } diff --git a/ts/structs/HTLCFailChannelUpdate.ts b/ts/structs/HTLCFailChannelUpdate.ts deleted file mode 100644 index dd5ac447..00000000 --- a/ts/structs/HTLCFailChannelUpdate.ts +++ /dev/null @@ -1,83 +0,0 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -export default class HTLCFailChannelUpdate extends CommonBase { - protected constructor(_dummy: object, ptr: number) { super(ptr); } - protected finalize() { - super.finalize(); - if (this.ptr != 0) { bindings.HTLCFailChannelUpdate_free(this.ptr); } - } - static constr_from_ptr(ptr: number): HTLCFailChannelUpdate { - const raw_val: bindings.LDKHTLCFailChannelUpdate = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr); - if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage) { - return new ChannelUpdateMessage(this.ptr, raw_val); - } - if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.ChannelClosed) { - return new ChannelClosed(this.ptr, raw_val); - } - if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.NodeFailure) { - return new NodeFailure(this.ptr, raw_val); - } - throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface - } - -} -export class ChannelUpdateMessage extends HTLCFailChannelUpdate { - public msg: ChannelUpdate; - private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage) { - super(null, ptr); - const msg: number = obj.msg; - const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg); - msg_hu_conv.ptrs_to.add(this); - this.msg = msg_hu_conv; - } -} -export class ChannelClosed extends HTLCFailChannelUpdate { - public short_channel_id: number; - public is_permanent: boolean; - private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.ChannelClosed) { - super(null, ptr); - this.short_channel_id = obj.short_channel_id; - this.is_permanent = obj.is_permanent; - } -} -export class NodeFailure extends HTLCFailChannelUpdate { - public node_id: Uint8Array; - public is_permanent: boolean; - private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.NodeFailure) { - super(null, ptr); - this.node_id = obj.node_id; - this.is_permanent = obj.is_permanent; - } -} - public HTLCFailChannelUpdate clone() { - number ret = bindings.HTLCFailChannelUpdate_clone(this.ptr); - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - - public static HTLCFailChannelUpdate constructor_channel_update_message(ChannelUpdate msg) { - number ret = bindings.HTLCFailChannelUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1); - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(msg); - return ret_hu_conv; - } - - public static HTLCFailChannelUpdate constructor_channel_closed(number short_channel_id, boolean is_permanent) { - number ret = bindings.HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - - public static HTLCFailChannelUpdate constructor_node_failure(Uint8Array node_id, boolean is_permanent) { - number ret = bindings.HTLCFailChannelUpdate_node_failure(node_id, is_permanent); - HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - -} diff --git a/ts/structs/IgnoringMessageHandler.ts b/ts/structs/IgnoringMessageHandler.ts index 934a3560..6505341f 100644 --- a/ts/structs/IgnoringMessageHandler.ts +++ b/ts/structs/IgnoringMessageHandler.ts @@ -39,4 +39,18 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public CustomMessageReader as_CustomMessageReader() { + number ret = bindings.IgnoringMessageHandler_as_CustomMessageReader(this.ptr); + CustomMessageReader ret_hu_conv = new CustomMessageReader(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public CustomMessageHandler as_CustomMessageHandler() { + number ret = bindings.IgnoringMessageHandler_as_CustomMessageHandler(this.ptr); + CustomMessageHandler ret_hu_conv = new CustomMessageHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + } diff --git a/ts/structs/InitFeatures.ts b/ts/structs/InitFeatures.ts index 40e8662d..4f18b363 100644 --- a/ts/structs/InitFeatures.ts +++ b/ts/structs/InitFeatures.ts @@ -45,6 +45,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public boolean requires_unknown_bits() { + boolean ret = bindings.InitFeatures_requires_unknown_bits(this.ptr); + return ret; + } + public boolean supports_payment_secret() { boolean ret = bindings.InitFeatures_supports_payment_secret(this.ptr); return ret; diff --git a/ts/structs/InvoiceFeatures.ts b/ts/structs/InvoiceFeatures.ts index 02145017..e68a62c1 100644 --- a/ts/structs/InvoiceFeatures.ts +++ b/ts/structs/InvoiceFeatures.ts @@ -45,6 +45,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public boolean requires_unknown_bits() { + boolean ret = bindings.InvoiceFeatures_requires_unknown_bits(this.ptr); + return ret; + } + public boolean supports_payment_secret() { boolean ret = bindings.InvoiceFeatures_supports_payment_secret(this.ptr); return ret; diff --git a/ts/structs/InvoiceSignature.ts b/ts/structs/InvoiceSignature.ts index b85e2b42..f533e27d 100644 --- a/ts/structs/InvoiceSignature.ts +++ b/ts/structs/InvoiceSignature.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.InvoiceSignature_free(this.ptr); } } - public boolean eq(InvoiceSignature b) { - boolean ret = bindings.InvoiceSignature_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public InvoiceSignature clone() { number ret = bindings.InvoiceSignature_clone(this.ptr); const ret_hu_conv: InvoiceSignature = new InvoiceSignature(null, ret); @@ -31,4 +25,10 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public boolean eq(InvoiceSignature b) { + boolean ret = bindings.InvoiceSignature_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/KeysManager.ts b/ts/structs/KeysManager.ts index a21a9a9e..96626d24 100644 --- a/ts/structs/KeysManager.ts +++ b/ts/structs/KeysManager.ts @@ -35,8 +35,6 @@ import * as bindings from '../bindings' // TODO: figure out location public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, Uint8Array change_destination_script, number feerate_sat_per_1000_weight) { number ret = bindings.KeysManager_spend_spendable_outputs(this.ptr, descriptors != null ? Arrays.stream(descriptors).map(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray(number[]::new) : null, outputs != null ? Arrays.stream(outputs).map(outputs_conv_7 -> outputs_conv_7.ptr).toArray(number[]::new) : null, change_destination_script, feerate_sat_per_1000_weight); Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret); - /* TODO 2 SpendableOutputDescriptor */; - /* TODO 2 TxOut */; return ret_hu_conv; } diff --git a/ts/structs/LockedNetworkGraph.ts b/ts/structs/LockedNetworkGraph.ts deleted file mode 100644 index 26fe800a..00000000 --- a/ts/structs/LockedNetworkGraph.ts +++ /dev/null @@ -1,27 +0,0 @@ - - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - - - - export default class LockedNetworkGraph extends CommonBase implements AutoCloseable { - constructor(_dummy: object, ptr: number) { - super(ptr); - } - - - public close() { - - if (this.ptr != 0) { - bindings.LockedNetworkGraph_free(this.ptr); - } - } - public NetworkGraph graph() { - number ret = bindings.LockedNetworkGraph_graph(this.ptr); - const ret_hu_conv: NetworkGraph = new NetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - -} diff --git a/ts/structs/MessageSendEvent.ts b/ts/structs/MessageSendEvent.ts index 608d7965..cf1ce556 100644 --- a/ts/structs/MessageSendEvent.ts +++ b/ts/structs/MessageSendEvent.ts @@ -58,9 +58,6 @@ export default class MessageSendEvent extends CommonBase { if (raw_val instanceof bindings.LDKMessageSendEvent.HandleError) { return new HandleError(this.ptr, raw_val); } - if (raw_val instanceof bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) { - return new PaymentFailureNetworkUpdate(this.ptr, raw_val); - } if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelRangeQuery) { return new SendChannelRangeQuery(this.ptr, raw_val); } @@ -265,16 +262,6 @@ export class HandleError extends MessageSendEvent { this.action = action_hu_conv; } } -export class PaymentFailureNetworkUpdate extends MessageSendEvent { - public update: HTLCFailChannelUpdate; - private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.PaymentFailureNetworkUpdate) { - super(null, ptr); - const update: number = obj.update; - HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update); - update_hu_conv.ptrs_to.add(this); - this.update = update_hu_conv; - } -} export class SendChannelRangeQuery extends MessageSendEvent { public node_id: Uint8Array; public msg: QueryChannelRange; @@ -446,13 +433,6 @@ export class SendReplyChannelRange extends MessageSendEvent { return ret_hu_conv; } - public static MessageSendEvent constructor_payment_failure_network_update(HTLCFailChannelUpdate update) { - number ret = bindings.MessageSendEvent_payment_failure_network_update(update.ptr); - MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - public static MessageSendEvent constructor_send_channel_range_query(Uint8Array node_id, QueryChannelRange msg) { number ret = bindings.MessageSendEvent_send_channel_range_query(node_id, msg == null ? 0 : msg.ptr & ~1); MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret); diff --git a/ts/structs/MessageSendEventsProvider.ts b/ts/structs/MessageSendEventsProvider.ts index 711f0749..fb52212a 100644 --- a/ts/structs/MessageSendEventsProvider.ts +++ b/ts/structs/MessageSendEventsProvider.ts @@ -35,7 +35,6 @@ import * as bindings from '../bindings' // TODO: figure out location get_and_clear_pending_msg_events (): number[] { MessageSendEvent[] ret = arg.get_and_clear_pending_msg_events(); result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_18 -> ret_conv_18.ptr).toArray(number[]::new) : null; - /* TODO 2 MessageSendEvent */; return result; }, diff --git a/ts/structs/MinFinalCltvExpiry.ts b/ts/structs/MinFinalCltvExpiry.ts index 4c007c87..aab2cb4e 100644 --- a/ts/structs/MinFinalCltvExpiry.ts +++ b/ts/structs/MinFinalCltvExpiry.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.MinFinalCltvExpiry_free(this.ptr); } } - public boolean eq(MinFinalCltvExpiry b) { - boolean ret = bindings.MinFinalCltvExpiry_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public MinFinalCltvExpiry clone() { number ret = bindings.MinFinalCltvExpiry_clone(this.ptr); const ret_hu_conv: MinFinalCltvExpiry = new MinFinalCltvExpiry(null, ret); @@ -31,4 +25,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.MinFinalCltvExpiry_hash(this.ptr); + return ret; + } + + public boolean eq(MinFinalCltvExpiry b) { + boolean ret = bindings.MinFinalCltvExpiry_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/MonitorEvent.ts b/ts/structs/MonitorEvent.ts index 49b729e0..535574fa 100644 --- a/ts/structs/MonitorEvent.ts +++ b/ts/structs/MonitorEvent.ts @@ -13,8 +13,8 @@ export default class MonitorEvent extends CommonBase { if (raw_val instanceof bindings.LDKMonitorEvent.HTLCEvent) { return new HTLCEvent(this.ptr, raw_val); } - if (raw_val instanceof bindings.LDKMonitorEvent.CommitmentTxBroadcasted) { - return new CommitmentTxBroadcasted(this.ptr, raw_val); + if (raw_val instanceof bindings.LDKMonitorEvent.CommitmentTxConfirmed) { + return new CommitmentTxConfirmed(this.ptr, raw_val); } throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } @@ -30,14 +30,14 @@ export class HTLCEvent extends MonitorEvent { this.htlc_event = htlc_event_hu_conv; } } -export class CommitmentTxBroadcasted extends MonitorEvent { - public commitment_tx_broadcasted: OutPoint; - private constructor(ptr: number, obj: bindings.LDKMonitorEvent.CommitmentTxBroadcasted) { +export class CommitmentTxConfirmed extends MonitorEvent { + public commitment_tx_confirmed: OutPoint; + private constructor(ptr: number, obj: bindings.LDKMonitorEvent.CommitmentTxConfirmed) { super(null, ptr); - const commitment_tx_broadcasted: number = obj.commitment_tx_broadcasted; - const commitment_tx_broadcasted_hu_conv: OutPoint = new OutPoint(null, commitment_tx_broadcasted); - commitment_tx_broadcasted_hu_conv.ptrs_to.add(this); - this.commitment_tx_broadcasted = commitment_tx_broadcasted_hu_conv; + const commitment_tx_confirmed: number = obj.commitment_tx_confirmed; + const commitment_tx_confirmed_hu_conv: OutPoint = new OutPoint(null, commitment_tx_confirmed); + commitment_tx_confirmed_hu_conv.ptrs_to.add(this); + this.commitment_tx_confirmed = commitment_tx_confirmed_hu_conv; } } public MonitorEvent clone() { @@ -55,8 +55,8 @@ export class CommitmentTxBroadcasted extends MonitorEvent { return ret_hu_conv; } - public static MonitorEvent constructor_commitment_tx_broadcasted(OutPoint a) { - number ret = bindings.MonitorEvent_commitment_tx_broadcasted(a == null ? 0 : a.ptr & ~1); + public static MonitorEvent constructor_commitment_tx_confirmed(OutPoint a) { + number ret = bindings.MonitorEvent_commitment_tx_confirmed(a == null ? 0 : a.ptr & ~1); MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(a); diff --git a/ts/structs/NetGraphMsgHandler.ts b/ts/structs/NetGraphMsgHandler.ts index cfcb2d61..2d6468ed 100644 --- a/ts/structs/NetGraphMsgHandler.ts +++ b/ts/structs/NetGraphMsgHandler.ts @@ -18,37 +18,36 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.NetGraphMsgHandler_free(this.ptr); } } - public static NetGraphMsgHandler constructor_new(Uint8Array genesis_hash, Access chain_access, Logger logger) { - number ret = bindings.NetGraphMsgHandler_new(genesis_hash, chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr); - const ret_hu_conv: NetGraphMsgHandler = new NetGraphMsgHandler(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_access); - ret_hu_conv.ptrs_to.add(logger); + public EventHandler as_EventHandler() { + number ret = bindings.NetGraphMsgHandler_as_EventHandler(this.ptr); + EventHandler ret_hu_conv = new EventHandler(null, ret); + ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } - public static NetGraphMsgHandler constructor_from_net_graph(Access chain_access, Logger logger, NetworkGraph network_graph) { - number ret = bindings.NetGraphMsgHandler_from_net_graph(chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr, network_graph == null ? 0 : network_graph.ptr & ~1); - const ret_hu_conv: NetGraphMsgHandler = new NetGraphMsgHandler(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(chain_access); - ret_hu_conv.ptrs_to.add(logger); - ret_hu_conv.ptrs_to.add(network_graph); + public NetworkGraph get_network_graph() { + number ret = bindings.NetGraphMsgHandler_get_network_graph(this.ptr); + const ret_hu_conv: NetworkGraph = new NetworkGraph(null, ret); + ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } - public void add_chain_access(Access chain_access) { - bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access == null ? 0 : chain_access.ptr); - this.ptrs_to.add(chain_access); + public void set_network_graph(Uint8Array val_genesis_hash) { + bindings.NetGraphMsgHandler_set_network_graph(this.ptr, bindings.NetworkGraph_new(val_genesis_hash)); } - public LockedNetworkGraph read_locked_graph() { - number ret = bindings.NetGraphMsgHandler_read_locked_graph(this.ptr); - const ret_hu_conv: LockedNetworkGraph = new LockedNetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); + public static NetGraphMsgHandler constructor_new(Uint8Array network_graph_genesis_hash, Option_AccessZ chain_access, Logger logger) { + number ret = bindings.NetGraphMsgHandler_new(bindings.NetworkGraph_new(network_graph_genesis_hash), chain_access.ptr, logger == null ? 0 : logger.ptr); + const ret_hu_conv: NetGraphMsgHandler = new NetGraphMsgHandler(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; } + public void add_chain_access(Option_AccessZ chain_access) { + bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access.ptr); + } + public RoutingMessageHandler as_RoutingMessageHandler() { number ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr); RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret); diff --git a/ts/structs/NetworkGraph.ts b/ts/structs/NetworkGraph.ts index 5d2deab2..58e00cfe 100644 --- a/ts/structs/NetworkGraph.ts +++ b/ts/structs/NetworkGraph.ts @@ -18,13 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.NetworkGraph_free(this.ptr); } } - public NetworkGraph clone() { - number ret = bindings.NetworkGraph_clone(this.ptr); - const ret_hu_conv: NetworkGraph = new NetworkGraph(null, ret); - ret_hu_conv.ptrs_to.add(this); - return ret_hu_conv; - } - public Uint8Array write() { Uint8Array ret = bindings.NetworkGraph_write(this.ptr); return ret; @@ -43,6 +36,13 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public ReadOnlyNetworkGraph read_only() { + number ret = bindings.NetworkGraph_read_only(this.ptr); + const ret_hu_conv: ReadOnlyNetworkGraph = new ReadOnlyNetworkGraph(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + public Result_NoneLightningErrorZ update_node_from_announcement(NodeAnnouncement msg) { number ret = bindings.NetworkGraph_update_node_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1); Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); @@ -57,19 +57,17 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } - public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, Access chain_access) { - number ret = bindings.NetworkGraph_update_channel_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr); + public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, Option_AccessZ chain_access) { + number ret = bindings.NetworkGraph_update_channel_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access.ptr); Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); this.ptrs_to.add(msg); - this.ptrs_to.add(chain_access); return ret_hu_conv; } - public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Access chain_access) { - number ret = bindings.NetworkGraph_update_channel_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr); + public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Option_AccessZ chain_access) { + number ret = bindings.NetworkGraph_update_channel_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access.ptr); Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); this.ptrs_to.add(msg); - this.ptrs_to.add(chain_access); return ret_hu_conv; } @@ -77,6 +75,10 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.NetworkGraph_close_channel_from_update(this.ptr, short_channel_id, is_permanent); } + public void fail_node(Uint8Array _node_id, boolean is_permanent) { + bindings.NetworkGraph_fail_node(this.ptr, _node_id, is_permanent); + } + public Result_NoneLightningErrorZ update_channel(ChannelUpdate msg) { number ret = bindings.NetworkGraph_update_channel(this.ptr, msg == null ? 0 : msg.ptr & ~1); Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/NetworkUpdate.ts b/ts/structs/NetworkUpdate.ts new file mode 100644 index 00000000..b7b9e924 --- /dev/null +++ b/ts/structs/NetworkUpdate.ts @@ -0,0 +1,88 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class NetworkUpdate extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.NetworkUpdate_free(this.ptr); } + } + static constr_from_ptr(ptr: number): NetworkUpdate { + const raw_val: bindings.LDKNetworkUpdate = bindings.LDKNetworkUpdate_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKNetworkUpdate.ChannelUpdateMessage) { + return new ChannelUpdateMessage(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKNetworkUpdate.ChannelClosed) { + return new ChannelClosed(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKNetworkUpdate.NodeFailure) { + return new NodeFailure(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class ChannelUpdateMessage extends NetworkUpdate { + public msg: ChannelUpdate; + private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.ChannelUpdateMessage) { + super(null, ptr); + const msg: number = obj.msg; + const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg); + msg_hu_conv.ptrs_to.add(this); + this.msg = msg_hu_conv; + } +} +export class ChannelClosed extends NetworkUpdate { + public short_channel_id: number; + public is_permanent: boolean; + private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.ChannelClosed) { + super(null, ptr); + this.short_channel_id = obj.short_channel_id; + this.is_permanent = obj.is_permanent; + } +} +export class NodeFailure extends NetworkUpdate { + public node_id: Uint8Array; + public is_permanent: boolean; + private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.NodeFailure) { + super(null, ptr); + this.node_id = obj.node_id; + this.is_permanent = obj.is_permanent; + } +} + public NetworkUpdate clone() { + number ret = bindings.NetworkUpdate_clone(this.ptr); + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public static NetworkUpdate constructor_channel_update_message(ChannelUpdate msg) { + number ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1); + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(msg); + return ret_hu_conv; + } + + public static NetworkUpdate constructor_channel_closed(number short_channel_id, boolean is_permanent) { + number ret = bindings.NetworkUpdate_channel_closed(short_channel_id, is_permanent); + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static NetworkUpdate constructor_node_failure(Uint8Array node_id, boolean is_permanent) { + number ret = bindings.NetworkUpdate_node_failure(node_id, is_permanent); + NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public Uint8Array write() { + Uint8Array ret = bindings.NetworkUpdate_write(this.ptr); + return ret; + } + +} diff --git a/ts/structs/NodeAnnouncementInfo.ts b/ts/structs/NodeAnnouncementInfo.ts index 940ca656..16eee31d 100644 --- a/ts/structs/NodeAnnouncementInfo.ts +++ b/ts/structs/NodeAnnouncementInfo.ts @@ -59,7 +59,6 @@ import * as bindings from '../bindings' // TODO: figure out location public void set_addresses(NetAddress[] val) { bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12.ptr).toArray(number[]::new) : null); - /* TODO 2 NetAddress */; } public NodeAnnouncement get_announcement_message() { @@ -79,7 +78,6 @@ import * as bindings from '../bindings' // TODO: figure out location const ret_hu_conv: NodeAnnouncementInfo = new NodeAnnouncementInfo(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(features_arg); - /* TODO 2 NetAddress */; ret_hu_conv.ptrs_to.add(announcement_message_arg); return ret_hu_conv; } diff --git a/ts/structs/NodeFeatures.ts b/ts/structs/NodeFeatures.ts index d1427d1a..d65e11e3 100644 --- a/ts/structs/NodeFeatures.ts +++ b/ts/structs/NodeFeatures.ts @@ -45,6 +45,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public boolean requires_unknown_bits() { + boolean ret = bindings.NodeFeatures_requires_unknown_bits(this.ptr); + return ret; + } + public boolean supports_payment_secret() { boolean ret = bindings.NodeFeatures_supports_payment_secret(this.ptr); return ret; diff --git a/ts/structs/Option_AccessZ.ts b/ts/structs/Option_AccessZ.ts new file mode 100644 index 00000000..8bc1cde3 --- /dev/null +++ b/ts/structs/Option_AccessZ.ts @@ -0,0 +1,53 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class COption_AccessZ extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.COption_AccessZ_free(this.ptr); } + } + static constr_from_ptr(ptr: number): COption_AccessZ { + const raw_val: bindings.LDKCOption_AccessZ = bindings.LDKCOption_AccessZ_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKCOption_AccessZ.Some) { + return new Some(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKCOption_AccessZ.None) { + return new None(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class Some extends COption_AccessZ { + public some: Access; + private constructor(ptr: number, obj: bindings.LDKCOption_AccessZ.Some) { + super(null, ptr); + const some: number = obj.some; + Access ret_hu_conv = new Access(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } +} +export class None extends COption_AccessZ { + private constructor(ptr: number, obj: bindings.LDKCOption_AccessZ.None) { + super(null, ptr); + } +} + public static Option_AccessZ constructor__some(Access o) { + number ret = bindings.COption_AccessZ_some(o == null ? 0 : o.ptr); + Option_AccessZ ret_hu_conv = Option_AccessZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + public static Option_AccessZ constructor__none() { + number ret = bindings.COption_AccessZ_none(); + Option_AccessZ ret_hu_conv = Option_AccessZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Option_FilterZ.ts b/ts/structs/Option_FilterZ.ts new file mode 100644 index 00000000..6082376a --- /dev/null +++ b/ts/structs/Option_FilterZ.ts @@ -0,0 +1,53 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class COption_FilterZ extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.COption_FilterZ_free(this.ptr); } + } + static constr_from_ptr(ptr: number): COption_FilterZ { + const raw_val: bindings.LDKCOption_FilterZ = bindings.LDKCOption_FilterZ_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKCOption_FilterZ.Some) { + return new Some(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKCOption_FilterZ.None) { + return new None(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class Some extends COption_FilterZ { + public some: Filter; + private constructor(ptr: number, obj: bindings.LDKCOption_FilterZ.Some) { + super(null, ptr); + const some: number = obj.some; + Filter ret_hu_conv = new Filter(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } +} +export class None extends COption_FilterZ { + private constructor(ptr: number, obj: bindings.LDKCOption_FilterZ.None) { + super(null, ptr); + } +} + public static Option_FilterZ constructor__some(Filter o) { + number ret = bindings.COption_FilterZ_some(o == null ? 0 : o.ptr); + Option_FilterZ ret_hu_conv = Option_FilterZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + public static Option_FilterZ constructor__none() { + number ret = bindings.COption_FilterZ_none(); + Option_FilterZ ret_hu_conv = Option_FilterZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Option_NetworkUpdateZ.ts b/ts/structs/Option_NetworkUpdateZ.ts new file mode 100644 index 00000000..803b8ea0 --- /dev/null +++ b/ts/structs/Option_NetworkUpdateZ.ts @@ -0,0 +1,59 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class COption_NetworkUpdateZ extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.COption_NetworkUpdateZ_free(this.ptr); } + } + static constr_from_ptr(ptr: number): COption_NetworkUpdateZ { + const raw_val: bindings.LDKCOption_NetworkUpdateZ = bindings.LDKCOption_NetworkUpdateZ_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKCOption_NetworkUpdateZ.Some) { + return new Some(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKCOption_NetworkUpdateZ.None) { + return new None(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class Some extends COption_NetworkUpdateZ { + public some: NetworkUpdate; + private constructor(ptr: number, obj: bindings.LDKCOption_NetworkUpdateZ.Some) { + super(null, ptr); + const some: number = obj.some; + NetworkUpdate some_hu_conv = NetworkUpdate.constr_from_ptr(some); + some_hu_conv.ptrs_to.add(this); + this.some = some_hu_conv; + } +} +export class None extends COption_NetworkUpdateZ { + private constructor(ptr: number, obj: bindings.LDKCOption_NetworkUpdateZ.None) { + super(null, ptr); + } +} + public static Option_NetworkUpdateZ constructor__some(NetworkUpdate o) { + number ret = bindings.COption_NetworkUpdateZ_some(o.ptr); + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Option_NetworkUpdateZ constructor__none() { + number ret = bindings.COption_NetworkUpdateZ_none(); + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public Option_NetworkUpdateZ _clone() { + number ret = bindings.COption_NetworkUpdateZ_clone(this.ptr); + Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Option_TypeZ.ts b/ts/structs/Option_TypeZ.ts new file mode 100644 index 00000000..a9919b60 --- /dev/null +++ b/ts/structs/Option_TypeZ.ts @@ -0,0 +1,60 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class COption_TypeZ extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.COption_TypeZ_free(this.ptr); } + } + static constr_from_ptr(ptr: number): COption_TypeZ { + const raw_val: bindings.LDKCOption_TypeZ = bindings.LDKCOption_TypeZ_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKCOption_TypeZ.Some) { + return new Some(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKCOption_TypeZ.None) { + return new None(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class Some extends COption_TypeZ { + public some: Type; + private constructor(ptr: number, obj: bindings.LDKCOption_TypeZ.Some) { + super(null, ptr); + const some: number = obj.some; + Type ret_hu_conv = new Type(null, some); + ret_hu_conv.ptrs_to.add(this); + this.some = ret_hu_conv; + } +} +export class None extends COption_TypeZ { + private constructor(ptr: number, obj: bindings.LDKCOption_TypeZ.None) { + super(null, ptr); + } +} + public static Option_TypeZ constructor__some(Type o) { + number ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr); + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(o); + return ret_hu_conv; + } + + public static Option_TypeZ constructor__none() { + number ret = bindings.COption_TypeZ_none(); + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public Option_TypeZ _clone() { + number ret = bindings.COption_TypeZ_clone(this.ptr); + Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/PayeePubKey.ts b/ts/structs/PayeePubKey.ts index 0fb9f597..63b24e2d 100644 --- a/ts/structs/PayeePubKey.ts +++ b/ts/structs/PayeePubKey.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.PayeePubKey_free(this.ptr); } } - public boolean eq(PayeePubKey b) { - boolean ret = bindings.PayeePubKey_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public PayeePubKey clone() { number ret = bindings.PayeePubKey_clone(this.ptr); const ret_hu_conv: PayeePubKey = new PayeePubKey(null, ret); @@ -31,4 +25,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.PayeePubKey_hash(this.ptr); + return ret; + } + + public boolean eq(PayeePubKey b) { + boolean ret = bindings.PayeePubKey_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/PaymentSendFailure.ts b/ts/structs/PaymentSendFailure.ts index 803aace9..10fc46c6 100644 --- a/ts/structs/PaymentSendFailure.ts +++ b/ts/structs/PaymentSendFailure.ts @@ -97,7 +97,6 @@ export class PartialFailure extends PaymentSendFailure { number ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? Arrays.stream(a).map(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray(number[]::new) : null); PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 Result_NoneAPIErrorZ */; return ret_hu_conv; } @@ -105,7 +104,6 @@ export class PartialFailure extends PaymentSendFailure { number ret = bindings.PaymentSendFailure_all_failed_retry_safe(a != null ? Arrays.stream(a).map(a_conv_10 -> a_conv_10.ptr).toArray(number[]::new) : null); PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 APIError */; return ret_hu_conv; } @@ -113,7 +111,6 @@ export class PartialFailure extends PaymentSendFailure { number ret = bindings.PaymentSendFailure_partial_failure(a != null ? Arrays.stream(a).map(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray(number[]::new) : null); PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 Result_NoneAPIErrorZ */; return ret_hu_conv; } diff --git a/ts/structs/PeerManager.ts b/ts/structs/PeerManager.ts index b6fd014f..d527dfed 100644 --- a/ts/structs/PeerManager.ts +++ b/ts/structs/PeerManager.ts @@ -18,13 +18,14 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.PeerManager_free(this.ptr); } } - public static PeerManager constructor_new(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, Uint8Array our_node_secret, Uint8Array ephemeral_random_data, Logger logger) { - number ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr); + public static PeerManager constructor_new(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, Uint8Array our_node_secret, Uint8Array ephemeral_random_data, Logger logger, CustomMessageHandler custom_message_handler) { + number ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr, custom_message_handler == null ? 0 : custom_message_handler.ptr); const ret_hu_conv: PeerManager = new PeerManager(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(message_handler_chan_handler_arg); ret_hu_conv.ptrs_to.add(message_handler_route_handler_arg); ret_hu_conv.ptrs_to.add(logger); + ret_hu_conv.ptrs_to.add(custom_message_handler); return ret_hu_conv; } diff --git a/ts/structs/PrivateRoute.ts b/ts/structs/PrivateRoute.ts index cead3cdd..360a457e 100644 --- a/ts/structs/PrivateRoute.ts +++ b/ts/structs/PrivateRoute.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.PrivateRoute_free(this.ptr); } } - public boolean eq(PrivateRoute b) { - boolean ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public PrivateRoute clone() { number ret = bindings.PrivateRoute_clone(this.ptr); const ret_hu_conv: PrivateRoute = new PrivateRoute(null, ret); @@ -31,6 +25,17 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.PrivateRoute_hash(this.ptr); + return ret; + } + + public boolean eq(PrivateRoute b) { + boolean ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + public static Result_PrivateRouteCreationErrorZ constructor_new(RouteHint hops) { number ret = bindings.PrivateRoute_new(hops == null ? 0 : hops.ptr & ~1); Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/QueryChannelRange.ts b/ts/structs/QueryChannelRange.ts index 1b6be47b..27f68bb8 100644 --- a/ts/structs/QueryChannelRange.ts +++ b/ts/structs/QueryChannelRange.ts @@ -64,15 +64,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret; } + public Uint8Array write() { + Uint8Array ret = bindings.QueryChannelRange_write(this.ptr); + return ret; + } + public static Result_QueryChannelRangeDecodeErrorZ constructor_read(Uint8Array ser) { number ret = bindings.QueryChannelRange_read(ser); Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } - public Uint8Array write() { - Uint8Array ret = bindings.QueryChannelRange_write(this.ptr); - return ret; - } - } diff --git a/ts/structs/ReadOnlyNetworkGraph.ts b/ts/structs/ReadOnlyNetworkGraph.ts new file mode 100644 index 00000000..54cb431a --- /dev/null +++ b/ts/structs/ReadOnlyNetworkGraph.ts @@ -0,0 +1,21 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export default class ReadOnlyNetworkGraph extends CommonBase { + constructor(_dummy: object, ptr: number) { + super(ptr); + } + + + protected finalize() { + super.finalize(); + + if (this.ptr != 0) { + bindings.ReadOnlyNetworkGraph_free(this.ptr); + } + } +} diff --git a/ts/structs/ReplyShortChannelIdsEnd.ts b/ts/structs/ReplyShortChannelIdsEnd.ts index ebcb2914..ab431a6a 100644 --- a/ts/structs/ReplyShortChannelIdsEnd.ts +++ b/ts/structs/ReplyShortChannelIdsEnd.ts @@ -50,15 +50,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public Uint8Array write() { + Uint8Array ret = bindings.ReplyShortChannelIdsEnd_write(this.ptr); + return ret; + } + public static Result_ReplyShortChannelIdsEndDecodeErrorZ constructor_read(Uint8Array ser) { number ret = bindings.ReplyShortChannelIdsEnd_read(ser); Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } - public Uint8Array write() { - Uint8Array ret = bindings.ReplyShortChannelIdsEnd_write(this.ptr); - return ret; - } - } diff --git a/ts/structs/Result_COption_TypeZDecodeErrorZ.ts b/ts/structs/Result_COption_TypeZDecodeErrorZ.ts new file mode 100644 index 00000000..10771c75 --- /dev/null +++ b/ts/structs/Result_COption_TypeZDecodeErrorZ.ts @@ -0,0 +1,59 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +public class Result_COption_TypeZDecodeErrorZ extends CommonBase { + private Result_COption_TypeZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_COption_TypeZDecodeErrorZ_free(ptr); } super.finalize(); + } + + static Result_COption_TypeZDecodeErrorZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_COption_TypeZDecodeErrorZ_result_ok(ptr)) { + return new Result_COption_TypeZDecodeErrorZ_OK(null, ptr); + } else { + return new Result_COption_TypeZDecodeErrorZ_Err(null, ptr); + } + } + public static final class Result_COption_TypeZDecodeErrorZ_OK extends Result_COption_TypeZDecodeErrorZ { + public final Option_TypeZ res; + private Result_COption_TypeZDecodeErrorZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + number res = bindings.LDKCResult_COption_TypeZDecodeErrorZ_get_ok(ptr); + Option_TypeZ res_hu_conv = Option_TypeZ.constr_from_ptr(res); + res_hu_conv.ptrs_to.add(this); + this.res = res_hu_conv; + } + } + + public static final class Result_COption_TypeZDecodeErrorZ_Err extends Result_COption_TypeZDecodeErrorZ { + public final DecodeError err; + private Result_COption_TypeZDecodeErrorZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + number err = bindings.LDKCResult_COption_TypeZDecodeErrorZ_get_err(ptr); + const err_hu_conv: DecodeError = new DecodeError(null, err); + err_hu_conv.ptrs_to.add(this); + this.err = err_hu_conv; + } + } + + public static Result_COption_TypeZDecodeErrorZ constructor__ok(Option_TypeZ o) { + number ret = bindings.CResult_COption_TypeZDecodeErrorZ_ok(o.ptr); + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + public static Result_COption_TypeZDecodeErrorZ constructor__err(DecodeError e) { + number ret = bindings.CResult_COption_TypeZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1); + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(e); + return ret_hu_conv; + } + + public Result_COption_TypeZDecodeErrorZ _clone() { + number ret = bindings.CResult_COption_TypeZDecodeErrorZ_clone(this.ptr); + Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.ts b/ts/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.ts index 5c7ad0a5..7d538844 100644 --- a/ts/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.ts +++ b/ts/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.ts @@ -48,7 +48,7 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ extends CommonB public static Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ constructor__ok(TwoTuple[] o) { number ret = bindings.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o != null ? Arrays.stream(o).map(o_conv_38 -> bindings.C2Tuple_BlockHashChannelMonitorZ_new(o_conv_38.a, o_conv_38.b == null ? 0 : o_conv_38.b.ptr & ~1)).toArray(number[]::new) : null); Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret); - /* TODO 2 TwoTuple */; + for (TwoTuple o_conv_38: o) { ret_hu_conv.ptrs_to.add(o_conv_38.b); }; return ret_hu_conv; } diff --git a/ts/structs/Result_NetworkGraphDecodeErrorZ.ts b/ts/structs/Result_NetworkGraphDecodeErrorZ.ts index 1cc929fa..c201f78c 100644 --- a/ts/structs/Result_NetworkGraphDecodeErrorZ.ts +++ b/ts/structs/Result_NetworkGraphDecodeErrorZ.ts @@ -37,10 +37,9 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { } } - public static Result_NetworkGraphDecodeErrorZ constructor__ok(NetworkGraph o) { - number ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1); + public static Result_NetworkGraphDecodeErrorZ constructor__ok(Uint8Array o_genesis_hash) { + number ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(bindings.NetworkGraph_new(o_genesis_hash)); Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(o); return ret_hu_conv; } @@ -51,10 +50,4 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { return ret_hu_conv; } - public Result_NetworkGraphDecodeErrorZ _clone() { - number ret = bindings.CResult_NetworkGraphDecodeErrorZ_clone(this.ptr); - Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret); - return ret_hu_conv; - } - } diff --git a/ts/structs/Result_NoneNoneZ.ts b/ts/structs/Result_NoneNoneZ.ts new file mode 100644 index 00000000..ecc8f2cc --- /dev/null +++ b/ts/structs/Result_NoneNoneZ.ts @@ -0,0 +1,48 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +public class Result_NoneNoneZ extends CommonBase { + private Result_NoneNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_NoneNoneZ_free(ptr); } super.finalize(); + } + + static Result_NoneNoneZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_NoneNoneZ_result_ok(ptr)) { + return new Result_NoneNoneZ_OK(null, ptr); + } else { + return new Result_NoneNoneZ_Err(null, ptr); + } + } + public static final class Result_NoneNoneZ_OK extends Result_NoneNoneZ { + private Result_NoneNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + public static final class Result_NoneNoneZ_Err extends Result_NoneNoneZ { + private Result_NoneNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + public static Result_NoneNoneZ constructor__ok() { + number ret = bindings.CResult_NoneNoneZ_ok(); + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + public static Result_NoneNoneZ constructor__err() { + number ret = bindings.CResult_NoneNoneZ_err(); + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + + public Result_NoneNoneZ _clone() { + number ret = bindings.CResult_NoneNoneZ_clone(this.ptr); + Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Result_TrustedClosingTransactionNoneZ.ts b/ts/structs/Result_TrustedClosingTransactionNoneZ.ts new file mode 100644 index 00000000..a5d353b8 --- /dev/null +++ b/ts/structs/Result_TrustedClosingTransactionNoneZ.ts @@ -0,0 +1,56 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +public class Result_TrustedClosingTransactionNoneZ extends CommonBase { + private Result_TrustedClosingTransactionNoneZ(Object _dummy, long ptr) { super(ptr); } + protected void finalize() throws Throwable { + if (ptr != 0) { bindings.CResult_TrustedClosingTransactionNoneZ_free(ptr); } super.finalize(); + } + + static Result_TrustedClosingTransactionNoneZ constr_from_ptr(long ptr) { + if (bindings.LDKCResult_TrustedClosingTransactionNoneZ_result_ok(ptr)) { + return new Result_TrustedClosingTransactionNoneZ_OK(null, ptr); + } else { + return new Result_TrustedClosingTransactionNoneZ_Err(null, ptr); + } + } + public static final class Result_TrustedClosingTransactionNoneZ_OK extends Result_TrustedClosingTransactionNoneZ { + public final TrustedClosingTransaction res; + private Result_TrustedClosingTransactionNoneZ_OK(Object _dummy, long ptr) { + super(_dummy, ptr); + number res = bindings.LDKCResult_TrustedClosingTransactionNoneZ_get_ok(ptr); + const res_hu_conv: TrustedClosingTransaction = new TrustedClosingTransaction(null, res); + res_hu_conv.ptrs_to.add(this); + this.res = res_hu_conv; + } + } + + public static final class Result_TrustedClosingTransactionNoneZ_Err extends Result_TrustedClosingTransactionNoneZ { + private Result_TrustedClosingTransactionNoneZ_Err(Object _dummy, long ptr) { + super(_dummy, ptr); + } + } + + public static Result_TrustedClosingTransactionNoneZ constructor__ok(TrustedClosingTransaction o) { + number ret = bindings.CResult_TrustedClosingTransactionNoneZ_ok(o == null ? 0 : o.ptr & ~1); + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(o); + // Due to rust's strict-ownership memory model, in some cases we need to "move" + // an object to pass exclusive ownership to the function being called. + // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object + // at the FFI layer, creating a new object which Rust can claim ownership of + // However, in some cases (eg here), there is no way to clone an object, and thus + // we actually have to pass full ownership to Rust. + // Thus, after ret_hu_conv call, o is reset to null and is now a dummy object. + o.ptr = 0; + return ret_hu_conv; + } + + public static Result_TrustedClosingTransactionNoneZ constructor__err() { + number ret = bindings.CResult_TrustedClosingTransactionNoneZ_err(); + Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +} diff --git a/ts/structs/Route.ts b/ts/structs/Route.ts index 29561c2d..7e345a99 100644 --- a/ts/structs/Route.ts +++ b/ts/structs/Route.ts @@ -18,16 +18,33 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.Route_free(this.ptr); } } + public RouteHop[][] get_paths() { + number[][] ret = bindings.Route_get_paths(this.ptr); + RouteHop[][] ret_conv_12_arr = new RouteHop[ret.length][]; + for (int m = 0; m < ret.length; m++) { + number[] ret_conv_12 = ret[m]; + RouteHop[] ret_conv_12_conv_10_arr = new RouteHop[ret_conv_12.length]; + for (int k = 0; k < ret_conv_12.length; k++) { + number ret_conv_12_conv_10 = ret_conv_12[k]; + const ret_conv_12_conv_10_hu_conv: RouteHop = new RouteHop(null, ret_conv_12_conv_10); + ret_conv_12_conv_10_hu_conv.ptrs_to.add(this); + ret_conv_12_conv_10_arr[k] = ret_conv_12_conv_10_hu_conv; + } + ret_conv_12_arr[m] = ret_conv_12_conv_10_arr; + } + return ret_conv_12_arr; + } + public void set_paths(RouteHop[][] val) { bindings.Route_set_paths(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12 != null ? Arrays.stream(val_conv_12).map(val_conv_12_conv_10 -> val_conv_12_conv_10 == null ? 0 : val_conv_12_conv_10.ptr & ~1).toArray(number[]::new) : null).toArray(number[][]::new) : null); - /* TODO 2 RouteHop[] */; + for (RouteHop[] val_conv_12: val) { for (RouteHop val_conv_12_conv_10: val_conv_12) { this.ptrs_to.add(val_conv_12_conv_10); }; }; } public static Route constructor_new(RouteHop[][] paths_arg) { number ret = bindings.Route_new(paths_arg != null ? Arrays.stream(paths_arg).map(paths_arg_conv_12 -> paths_arg_conv_12 != null ? Arrays.stream(paths_arg_conv_12).map(paths_arg_conv_12_conv_10 -> paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr & ~1).toArray(number[]::new) : null).toArray(number[][]::new) : null); const ret_hu_conv: Route = new Route(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - /* TODO 2 RouteHop[] */; + for (RouteHop[] paths_arg_conv_12: paths_arg) { for (RouteHop paths_arg_conv_12_conv_10: paths_arg_conv_12) { ret_hu_conv.ptrs_to.add(paths_arg_conv_12_conv_10); }; }; return ret_hu_conv; } @@ -38,6 +55,27 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.Route_hash(this.ptr); + return ret; + } + + public boolean eq(Route b) { + boolean ret = bindings.Route_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + + public number get_total_fees() { + number ret = bindings.Route_get_total_fees(this.ptr); + return ret; + } + + public number get_total_amount() { + number ret = bindings.Route_get_total_amount(this.ptr); + return ret; + } + public Uint8Array write() { Uint8Array ret = bindings.Route_write(this.ptr); return ret; diff --git a/ts/structs/RouteHint.ts b/ts/structs/RouteHint.ts index 4a605278..a63a6f28 100644 --- a/ts/structs/RouteHint.ts +++ b/ts/structs/RouteHint.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.RouteHint_free(this.ptr); } } - public boolean eq(RouteHint b) { - boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public RouteHint clone() { number ret = bindings.RouteHint_clone(this.ptr); const ret_hu_conv: RouteHint = new RouteHint(null, ret); @@ -31,4 +25,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.RouteHint_hash(this.ptr); + return ret; + } + + public boolean eq(RouteHint b) { + boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/RouteHintHop.ts b/ts/structs/RouteHintHop.ts index eadb9df9..eb888ebe 100644 --- a/ts/structs/RouteHintHop.ts +++ b/ts/structs/RouteHintHop.ts @@ -87,12 +87,6 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } - public boolean eq(RouteHintHop b) { - boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public RouteHintHop clone() { number ret = bindings.RouteHintHop_clone(this.ptr); const ret_hu_conv: RouteHintHop = new RouteHintHop(null, ret); @@ -100,4 +94,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.RouteHintHop_hash(this.ptr); + return ret; + } + + public boolean eq(RouteHintHop b) { + boolean ret = bindings.RouteHintHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/RouteHop.ts b/ts/structs/RouteHop.ts index 2a304422..880cd88a 100644 --- a/ts/structs/RouteHop.ts +++ b/ts/structs/RouteHop.ts @@ -94,6 +94,17 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.RouteHop_hash(this.ptr); + return ret; + } + + public boolean eq(RouteHop b) { + boolean ret = bindings.RouteHop_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + public Uint8Array write() { Uint8Array ret = bindings.RouteHop_write(this.ptr); return ret; diff --git a/ts/structs/RoutingFees.ts b/ts/structs/RoutingFees.ts index 8d62e3f3..2fb461a4 100644 --- a/ts/structs/RoutingFees.ts +++ b/ts/structs/RoutingFees.ts @@ -56,6 +56,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.RoutingFees_hash(this.ptr); + return ret; + } + public Uint8Array write() { Uint8Array ret = bindings.RoutingFees_write(this.ptr); return ret; diff --git a/ts/structs/RoutingMessageHandler.ts b/ts/structs/RoutingMessageHandler.ts index 128294a8..28c867d0 100644 --- a/ts/structs/RoutingMessageHandler.ts +++ b/ts/structs/RoutingMessageHandler.ts @@ -54,22 +54,17 @@ import * as bindings from '../bindings' // TODO: figure out location return result; }, - handle_htlc_fail_channel_update (update: number): void { - HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update); - arg.handle_htlc_fail_channel_update(update_hu_conv); - }, - get_next_channel_announcements (starting_point: number, batch_amount: number): number[] { ThreeTuple[] ret = arg.get_next_channel_announcements(starting_point, batch_amount); result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_63 -> bindings.C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(ret_conv_63.a == null ? 0 : ret_conv_63.a.ptr & ~1, ret_conv_63.b == null ? 0 : ret_conv_63.b.ptr & ~1, ret_conv_63.c == null ? 0 : ret_conv_63.c.ptr & ~1)).toArray(number[]::new) : null; - /* TODO 2 ThreeTuple */; + for (ThreeTuple ret_conv_63: ret) { impl_holder.held.ptrs_to.add(ret_conv_63.a); impl_holder.held.ptrs_to.add(ret_conv_63.b); impl_holder.held.ptrs_to.add(ret_conv_63.c); }; return result; }, get_next_node_announcements (starting_point: Uint8Array, batch_amount: number): number[] { NodeAnnouncement[] ret = arg.get_next_node_announcements(starting_point, batch_amount); result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_18 -> ret_conv_18 == null ? 0 : ret_conv_18.ptr & ~1).toArray(number[]::new) : null; - /* TODO 2 NodeAnnouncement */; + for (NodeAnnouncement ret_conv_18: ret) { impl_holder.held.ptrs_to.add(ret_conv_18); }; return result; }, @@ -120,7 +115,6 @@ import * as bindings from '../bindings' // TODO: figure out location handle_node_announcement(msg: NodeAnnouncement): Result_boolLightningErrorZ; handle_channel_announcement(msg: ChannelAnnouncement): Result_boolLightningErrorZ; handle_channel_update(msg: ChannelUpdate): Result_boolLightningErrorZ; - handle_htlc_fail_channel_update(update: HTLCFailChannelUpdate): void; get_next_channel_announcements(starting_point: number, batch_amount: number): ThreeTuple[]; get_next_node_announcements(starting_point: Uint8Array, batch_amount: number): NodeAnnouncement[]; sync_routing_table(their_node_id: Uint8Array, init: Init): void; @@ -155,11 +149,6 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } - public void handle_htlc_fail_channel_update(HTLCFailChannelUpdate update) { - bindings.RoutingMessageHandler_handle_htlc_fail_channel_update(this.ptr, update == null ? 0 : update.ptr & ~1); - this.ptrs_to.add(update); - } - public ThreeTuple[] get_next_channel_announcements(number starting_point, number batch_amount) { number[] ret = bindings.RoutingMessageHandler_get_next_channel_announcements(this.ptr, starting_point, batch_amount); ThreeTuple[] ret_conv_63_arr = new ThreeTuple[ret.length]; diff --git a/ts/structs/Sha256.ts b/ts/structs/Sha256.ts index bb9bf919..2f97904c 100644 --- a/ts/structs/Sha256.ts +++ b/ts/structs/Sha256.ts @@ -18,12 +18,6 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.Sha256_free(this.ptr); } } - public boolean eq(Sha256 b) { - boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); - return ret; - } - public Sha256 clone() { number ret = bindings.Sha256_clone(this.ptr); const ret_hu_conv: Sha256 = new Sha256(null, ret); @@ -31,4 +25,15 @@ import * as bindings from '../bindings' // TODO: figure out location return ret_hu_conv; } + public number hash() { + number ret = bindings.Sha256_hash(this.ptr); + return ret; + } + + public boolean eq(Sha256 b) { + boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + } diff --git a/ts/structs/TrustedClosingTransaction.ts b/ts/structs/TrustedClosingTransaction.ts new file mode 100644 index 00000000..eb15abc1 --- /dev/null +++ b/ts/structs/TrustedClosingTransaction.ts @@ -0,0 +1,36 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export default class TrustedClosingTransaction extends CommonBase { + constructor(_dummy: object, ptr: number) { + super(ptr); + } + + + protected finalize() { + super.finalize(); + + if (this.ptr != 0) { + bindings.TrustedClosingTransaction_free(this.ptr); + } + } + public Uint8Array built_transaction() { + Uint8Array ret = bindings.TrustedClosingTransaction_built_transaction(this.ptr); + return ret; + } + + public Uint8Array get_sighash_all(Uint8Array funding_redeemscript, number channel_value_satoshis) { + Uint8Array ret = bindings.TrustedClosingTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis); + return ret; + } + + public Uint8Array sign(Uint8Array funding_key, Uint8Array funding_redeemscript, number channel_value_satoshis) { + Uint8Array ret = bindings.TrustedClosingTransaction_sign(this.ptr, funding_key, funding_redeemscript, channel_value_satoshis); + return ret; + } + +} diff --git a/ts/structs/Type.ts b/ts/structs/Type.ts new file mode 100644 index 00000000..8441989f --- /dev/null +++ b/ts/structs/Type.ts @@ -0,0 +1,88 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export class Type extends CommonBase { + + bindings_instance?: bindings.LDKType; + + constructor(ptr?: number, arg?: bindings.LDKType) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKType_new(arg)); + this.ptrs_to.push(arg); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.Type_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: TypeInterface): Type { + const impl_holder: LDKTypeHolder = new LDKTypeHolder(); + let structImplementation = { + // todo: in-line interface filling + type_id (): number { + number ret = arg.type_id(); + return ret; + }, + + debug_str (): String { + String ret = arg.debug_str(); + return ret; + }, + + write (): Uint8Array { + Uint8Array ret = arg.write(); + return ret; + }, + + + }; + impl_holder.held = new Type (null, structImplementation); + } + } + + export interface TypeInterface { + type_id(): number; + debug_str(): String; + write(): Uint8Array; + + } + + class LDKTypeHolder { + held: Type; + } + public number type_id() { + number ret = bindings.Type_type_id(this.ptr); + return ret; + } + + public String debug_str() { + String ret = bindings.Type_debug_str(this.ptr); + return ret; + } + + public Uint8Array write() { + Uint8Array ret = bindings.Type_write(this.ptr); + return ret; + } + + public Type clone() { + number ret = bindings.Type_clone(this.ptr); + Type ret_hu_conv = new Type(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/UnsignedNodeAnnouncement.ts b/ts/structs/UnsignedNodeAnnouncement.ts index 524f81b2..7a013cbc 100644 --- a/ts/structs/UnsignedNodeAnnouncement.ts +++ b/ts/structs/UnsignedNodeAnnouncement.ts @@ -68,7 +68,6 @@ import * as bindings from '../bindings' // TODO: figure out location public void set_addresses(NetAddress[] val) { bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).map(val_conv_12 -> val_conv_12.ptr).toArray(number[]::new) : null); - /* TODO 2 NetAddress */; } public UnsignedNodeAnnouncement clone() { diff --git a/ts/structs/UtilMethods.ts b/ts/structs/UtilMethods.ts index a82e1193..13b2ab63 100644 --- a/ts/structs/UtilMethods.ts +++ b/ts/structs/UtilMethods.ts @@ -31,7 +31,7 @@ ret_hu_conv.ptrs_to.add(arg_tx_broadcaster); ret_hu_conv.ptrs_to.add(arg_logger); ret_hu_conv.ptrs_to.add(arg_default_config); - /* TODO 2 ChannelMonitor */; + for (ChannelMonitor arg_channel_monitors_conv_16: arg_channel_monitors) { ret_hu_conv.ptrs_to.add(arg_channel_monitors_conv_16); }; return ret_hu_conv; } @@ -40,6 +40,12 @@ return ret; } + public static Uint8Array constructor_uild_closing_transaction(number to_holder_value_sat, number to_counterparty_value_sat, Uint8Array to_holder_script, Uint8Array to_counterparty_script, OutPoint funding_outpoint) { + Uint8Array 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 & ~1); + // this.ptrs_to.add(funding_outpoint); + return ret; + } + public static Result_SecretKeyErrorZ constructor_erive_private_key(Uint8Array per_commitment_point, Uint8Array base_secret) { number ret = bindings.derive_private_key(per_commitment_point, base_secret); Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret); @@ -96,8 +102,8 @@ number ret = bindings.get_keysend_route(our_node_id, network == null ? 0 : network.ptr & ~1, payee, first_hops != null ? Arrays.stream(first_hops).map(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray(number[]::new) : null, last_hops != null ? Arrays.stream(last_hops).map(last_hops_conv_11 -> last_hops_conv_11 == null ? 0 : last_hops_conv_11.ptr & ~1).toArray(number[]::new) : null, final_value_msat, final_cltv, logger == null ? 0 : logger.ptr); Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(network); - /* TODO 2 ChannelDetails */; - /* TODO 2 RouteHint */; + for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); }; + for (RouteHint last_hops_conv_11: last_hops) { ret_hu_conv.ptrs_to.add(last_hops_conv_11); }; ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; } @@ -107,8 +113,8 @@ Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(network); ret_hu_conv.ptrs_to.add(payee_features); - /* TODO 2 ChannelDetails */; - /* TODO 2 RouteHint */; + for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); }; + for (RouteHint last_hops_conv_11: last_hops) { ret_hu_conv.ptrs_to.add(last_hops_conv_11); }; ret_hu_conv.ptrs_to.add(logger); return ret_hu_conv; } diff --git a/ts/structs/Watch.ts b/ts/structs/Watch.ts index d2765e3d..bfb13055 100644 --- a/ts/structs/Watch.ts +++ b/ts/structs/Watch.ts @@ -55,7 +55,6 @@ import * as bindings from '../bindings' // TODO: figure out location release_pending_monitor_events (): number[] { MonitorEvent[] ret = arg.release_pending_monitor_events(); result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_14 -> ret_conv_14.ptr).toArray(number[]::new) : null; - /* TODO 2 MonitorEvent */; return result; }, -- 2.39.5